PageSourceSearch

https://sungtaepaek.com/js/module/ModalPlugin.1790659391.js

js sungtaepaek.com collected 2026-09-29 10:43:50 UTC 2,129,405 bytes, 35,027 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            pageMenuSelect += '\
1369                <button type="button" class="btn btn-sm fsm dropdown-toggle" data-toggle="dropdown">\
1370                    <span>' + currentPageMenu + '</span> ' + ($("#nestable").find("[data-id='" + currentPageMenu + "']").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>\
1371                </button>\
1372                <ul class="dropdown-menu" role="menu">\
1373            ';
1374            $(copy_menu_list).each(function(idx) {
1375                var active_cls = '';
1376                var depth_cls = '';
1377                var visible_cls = '';
1378                var visible_svg = '';
1379
1380                var menu_str = this;
1381                if(menu_str == '전체상품') return true;
1382                if(currentPageMenu == this) {
1383                    currentPageMenuIdx = idx;
1384                    active_cls = ' active ';
1385                }
1386
1387                $("#nestable").find(".dd-first, .dd-item:not(.dd-dummy)").each(function () {
1388                    var dd_item_id = $(this).attr("data-id");
1389                    if(!dd_item_id) return true;
1390                    
1391                    dd_item_id = dd_item_id.replace(/ /g, '-');
1392                    if(dd_item_id == menu_str) {
1393                        if($(this).parents(".dd-item").length) {
1394                            depth_cls = ' indent ';
1395                        }        
1396
1397                        if($(this).children(".menu-ctrl").find(".menu-visible").hasClass("invisible")) {
1398                            visible_cls = ' visibleoff ';
1399                            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> ';
1400                        }
1401                    }
1402                });
1403
1404                
1405
1406                // pageMenuSelect += '<option value="' + this + '" ' + (currentPageMenu == this ? ' selected ' : '') + '>
1406' + this + '</option>';
1407                pageMenuSelect += '<li class="gallery-name ' + active_cls + depth_cls + visible_cls +' " data-page="' + menu_str + '">' + '<span>' + menu_str + '</span>' +  visible_svg + '</li>';
1408            });
1409            pageMenuSelect += '</ul>';
1410            $center_area.find(".page-list-area .btn-group").append(pageMenuSelect);
1411        } else {
1412            currentPageMenuIdx = 0;
1413        }
1414
1415        if(reorderFIXED) {
1416            if(el_fixed[2] == 't') {
1417                $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>');
1418            } else if(el_fixed[2] == 'b') {
1419                $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>');
1420            }
1421        } else if(VIEW) {
1422            $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>');
1423        }
1424
1425        setTimeout(function() {
1426
1427            if(typeof pageList[currentPageMenuIdx] == 'undefined' || typeof pageListChangeFlag[currentPageMenuIdx] == 'undefined') {
1428               
1429                $('.new-dsgn-body .contents[data-page="' + currentPageMenu + '"]').remove();
1430                var pageIndex = 0;
1431                PAGE = currentPageMenu.toString();
1432                var dsgn_body_clone = $('.dsgn-body').clone().empty().addClass('contents');
1433                $('.dsgn-body').removeClass('dsgn-body').addClass('prev-dsgn-body');
1434                $('.new-dsgn-body .elements').append(dsgn_body_clone);
1435                
1436                showPageCallback(showPage); 
1437                
1438                $('.new-dsgn-body .contents.dsgn-body').removeClass('dsgn-body').attr('data-page', currentPageMenu);
1439                $('.prev-dsgn-body').removeClass('prev-dsgn-body').addClass('dsgn-body');
1440                PAGE = prevPAGE ? prevPAGE.toString() : '';
1441             
1442                pageList[currentPageMenuIdx] = [];
1443                $.each($('.new-dsgn-body .contents[data-page="' + currentPageMenu + '"] .element'),function(i,v) {
1444                    if( $(v).hasClass('el-menu') || 
1445                        $(v).hasClass('el-footer') || 
1446                        $(v).hasClass('add-footer-information') ||
1447                        $(v).hasClass('cl-s-product-detail') ||
1448                        $(v).hasClass('cl-s-product-review') ||
1449                        $(v).hasClass('cl-s-product-qna') || 
1450                        $(v).hasClass('cl-s-product-info-notice') ||
1451                        $(v).hasClass('el-fixedcontact')
1452                    ) {
1453                        return true;
1454                    }
1455
1456                    if(reorderFIXED) {
1457                        if($(v).hasClass('el-fixedblock')) {
1458                            if($(v).attr('data-posby') != el_fixed[2]) return true;
1459                        } else return true;
1460                    } else {
1461                        if($(v).hasClass('el-fixedblock')) return true;
1462                    }
1463                    
1464                    if ($(v).hasClass('addEL-wrap')) {
1465                        return true;
1466                    } 
1467                    
1468                    pageList[currentPageMenuIdx][pageIndex] = (LUX && $(v).is('.lux-product-block')) ? 'lux-product-block' : $(v).data('id');
1469
1470                    $(v).find('.hideBlockWrap .blockOn').hide();
1471                    if($(v).find('.hideBlockWrap').length > 0) $(v).addClass('block_checkOnOff');
1472                    pageIndex++;
1473                });
1474                pageListChangeFlag[currentPageMenuIdx] = true;
1475            }
1476
1477            PAGE = prevPAGE ? prevPAGE.toString() : '';
1478
1479            var $empty = $('<div class="render sort-empty" data-result-page="' + currentPageMenu + '">&nbsp;</div>'),
1480                $pageLine = $('<div class="sort-page-line"></div>'),
1481                pageName = currentPageMenu.replace(/,/,'/'),
1482                menulist_index = $.inArray(pageName,MENULIST),
1483                pageNameOrg = pageName=='INTRO' ? pageName : $('#nestable').find('.dd-item').eq(menulist_index-1).attr('data-id'),
1484                $pageInfo = $('<div class="sort-page-info">' + pageNameOrg + '</div>'),
1485                isLink = pageName=='INTRO' || menulist_index == -1 ? false : $('#nestable').find('.dd-item').eq(menulist_index-1).find('.menu-link').first().hasClass('active');
1486                
1487            if(pageName.indexOf('/')>-1 || reorderFIXED) $pageInfo.addClass('hide');
1488
1489            // $empty.append($pageLine);
1490            // $empty.append($pageInfo);
1491
1492            $empty = (isLink) ? $empty.addClass('use-link') : $empty;
1493                // if(!isLink) $sort.append($empty);
1494
1495            $(pageList[currentPageMenuIdx]).each(function(i,v) {
1496                if(v == 'lux-product-block') {
1497                    var element_selector = ($('.new-dsgn-body .lux-product-block').hasClass('reorderBlock')) ? 'reorderBlock' : 'element',
1498                        $ndb_el = $('.new-dsgn-body .lux-product-block.' + element_selector);
1499                } else {
1500                    var element_selector = ($('.new-dsgn-body [data-id="'+v + '"][data-type]').hasClass('reorderBlock')) ? 'reorderBlock' : 'element',
1501                        $ndb_el = $('.new-dsgn-body .' + element_selector + '[data-id="'+v + '"]');
1502                }
1503
1504                $ndb_el.removeClass('element')
1505                        .removeClass('el-active')
1506                        .removeClass('active')
1507                        .removeClass('emptyGallery')
1508                        .removeClass('el-fixedblock')
1509                        .removeAttr('data-parallax')
1510                        .addClass('render')
1511                        .addClass('reorderBlock')
1512                        .attr('data-reorder-page',currentPageMenu);
1513
1514                var $el = $ndb_el.clone();
1515                var isLink = $('#nestable .dd-item[data-id="'+pageNameOrg+'"] > span > .menu-link').hasClass('active');
1516                if($el.is('[data-parallax="true"]')) {
1517                    $el.css('background-attachment','inherit');
1518                }
1519
1520                if(elIndex==0) {
1521                    $el.css('margin','0px');
1522                    if(VIEW && ($el.attr('data-type')=='project' || $el.attr('data-type')=='product')) return true;//$el.addClass('unsort').hide();
1523                }
1524                if($el.attr('data-msny')=='true' && $el.find('.container').hasClass('full-width')) {
1525                    $el.css('padding-left',$('header.sidebar').width()+'px');
1526                }
1527
1528                if($ndb_el.css('background-color')=='rgba(0, 0, 0, 0)' || $ndb_el.css('background-color')=='transparent') {
1529                    $el.css('background-color', '#fff');
1530                }
1531
1532                $el.find('[data-edit="true"]').removeAttr('data-edit');
1533                $el.css('position','relative');
1534                $el.css('min-height','0px');
1535                $el.css('margin-bottom','120px');
1536
1537                if($el.attr('data-layout')=="true") $el.css('overflow','');
1538
1539                if(v == 'lux-product-block') {
1540                    $el.html('<div class="lux-product-sample"><h1>본사 상품 상세 정보 블럭</h1></div>');
1541                }
1542                if(!isLink) $sort.append($el);
1543                elIndex++;
1544
1545            });
1546            var $last = $('<div class="sort-empty guide-text" style="display: none;">' + $.lang[LANG]['config.blockmove.movehere'] + '</div>');
1547            if(pageList[currentPageMenuIdx].length == 0 || typeof pageList[currentPageMenuIdx] == 'undefined') $last.show();
1548            $sort.append($last);
1549            $scale.append($sort);
1550
1551            $scale.css('height', 'auto');
1552
1553            var target_contents = $('.new-dsgn-body .elements .contents[data-page="' + currentPageMenu + '"]');
1554            var setting_height = target_contents.height() / 5 + $(".page-list-area").outerHeight() + 120;
1555
1556            $scale.height(setting_height);
1557            $center_area.height(setting_height);
1558
1559            $center_area.find('.reorderBlock[data-msny="true"]').each(function() {
1560                var cnt = 0;
1561                var total = $(this).find(".row").data("view");
1562                var target = this;
1563                $(target).imagesLoaded().progress(function(imgload, image) {
1564                    cnt ++;
1565                    if(total == cnt || cnt == $(target).find(".row .gallery-item").length) {
1566                        setTimeout(function() {
1567                            $(target).find(".row").masonry();    
1568                        }, 1)
1569                    }
1570                });
1571            });
1572
1573            if($center_area.find('[data-map_kind="kakao"]').length && (typeof kakao == 'undefined' || typeof kakao.maps == 'undefined' || 
1573kakao.maps == null || VALIDPLAN == '')) {
1574                $center_area.find('[data-map_kind="kakao"]').html('지도연결해제됨. Javascript키 확인');
1575                    $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>');
1576            } else {
1577                $center_area.find('[data-map_kind="kakao"]').each(function() {
1578                    var container = this;
1579                    var lat = $(this).data("lat");
1580                    var lng = $(this).data("lng");
1581                    var options = { center: new kakao.maps.LatLng(lat, lng), level: 3};
1582                    var c_map = new kakao.maps.Map(container, options);
1583                    var marker = new kakao.maps.Marker({ position: new kakao.maps.LatLng(lat, lng), map: c_map});
1584                    var zoomInOut = $(this).data("zoominout");
1585                    var mapTitle = $(this).data("maptitle");
1586                    var mapContent = $(this).data("mapcontent");
1587                    var useTitle = $(this).data("usetitle");
1588                    var useContent = $(this).data("usecontent");
1589                    if(typeof zoomInOut == 'undefined' || !zoomInOut) zoomInOut = false;
1590                    if(typeof mapTitle == 'undefined' || !mapTitle) mapTitle = '';
1591                    if(typeof mapContent == 'undefined' || !mapContent) mapContent = '';
1592                    if(typeof useTitle == 'undefined' || !useTitle) useTitle = false;
1593                    if(typeof useContent == 'undefined' || !useContent) useContent = false;
1594
1595                    if(zoomInOut == true) {
1596                        // var mapTypeControl = new kakao.maps.MapTypeControl();
1597                        // c_map.addControl(mapTypeControl, kakao.maps.ControlPosition.TOPRIGHT);
1598                        // var zoomControl = new kakao.maps.ZoomControl();
1599                        // c_map.addControl(zoomControl, kakao.maps.ControlPosition.RIGHT);
1600                        var zoomControlHtml = '';
1601                        zoomControlHtml += '\
1602                            <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);">\
1603                                <div class="btn-zoom-control" data-inout="I" style="cursor: pointer; width: 30px; height: 30px;">\
1604                                    <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>\
1605                                </div>\
1606                                <div class="slider-wrap-container" style="height: 130px;">\
1607                                    <div class="slider-wrap small" style="text-align: center; height: 100%;">\
1608                                        <div style="max-height: 100%;" class="zoom-control-slider"></div>\
1609                                    </div>\
1610                                </div>\
1611                                <div class="btn-zoom-control" data-inout="O" style="cursor: pointer; width: 30px; height: 30px;">\
1612                                    <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>\
1613                                </div>\
1614                            </div>\
1615                        ';
1616                        var $zoomController = $(zoomControlHtml);
1617                        $(container).append($zoomController);
1618                        var zoom_slider = $zoomController.find('.zoom-control-slider').slider({
1619                            'orientation': 'vertical',
1620                            'min' : 1,
1621                            'max' : 14,
1622                            'step' : 1,
1623                            'value' : 3,
1624                            'handle' : 'square',
1625                            // 'reversed' : true,
1626                            'tooltip' : 'hide',
1627                        }).on('slide', function(data) {
1628                            c_map.setLevel(data.value);
1629                            c_map.setCenter(marker.getPosition());
1630                        }).on('slideStop', function(data) {
1631                            c_map.setLevel(data.value);
1632                            c_map.setCenter(marker.getPosition());
1633                        });
1634
1635                        $zoomController.find('.btn-zoom-control').on('click', function() {
1636                            if($(this).data('inout') == 'I') {
1637                                c_map.setLevel(c_map.getLevel() - 1);
1638                                zoom_slider.slider('setValue', c_map.getLevel());
1639                            } else if($(this).data('inout' == 'O')) {
1640                                c_map.setLevel(c_map.getLevel() + 1);
1641                                zoom_slider.slider('setValue', c_map.getLevel());
1642                            }
1643                        });
1644
1645                        kakao.maps.event.addListener(c_map, 'zoom_changed', function() {
1646                            zoom_slider.slider('setValue', c_map.getLevel());
1647                        });
1648                    }
1649                        
1650                    if((useTitle == true || useContent == true) && (mapTitle || mapContent)) {
1651                        var iwContent = '';
1652                        if(useTitle == true && mapTitle) {
1653                            iwContent = '<div class="title">' + mapTitle + '</div>';
1654                        }
1655                        if(useContent == true && mapContent) {
1656                            iwContent += '<div class="content">' + mapContent + '</div>';
1657                        }
1658
1659                        if(iwContent) {
1660                            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>
1660' + iwContent + '</div>';
1661                            var infoWindow = $(iwContent);
1662                            $(container).append(infoWindow);
1663                            // infoWindow.css('bottom', 'calc(-100% + ' + (infoWindow.outerHeight() + 36) + 'px)');  
1664                        }
1665                    }
1666
1667                    $(window).on("resize", function() {
1668                        c_map.setCenter(marker.getPosition());
1669                    });
1670                });
1671            }
1672    
1673            if($center_area.find('[data-map_kind="naver"]').length && (typeof naver == 'undefined' || typeof naver.maps == 'undefined' || naver.maps == null || VALIDPLAN == '')) {
1674                $center_area.find('[data-map_kind="naver"]').html('지도연결해제됨. Client ID 확인');
1675                    $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>');
1676            } else {
1677                $center_area.find('[data-map_kind="naver"]').each(function() {
1678                    var container = this;
1679                    var lat = $(this).data("lat");
1680                    var lng = $(this).data("lng");
1681                    var options = { center: new naver.maps.LatLng(lat, lng), zoom: 17};
1682                    var zoomInOut = $(this).data("zoominout");
1683                    var mapTitle = $(this).data("maptitle");
1684                    var mapContent = $(this).data("mapcontent");
1685                    var useTitle = $(this).data("usetitle");
1686                    var useContent = $(this).data("usecontent");
1687                    if(typeof zoomInOut == 'undefined' || !zoomInOut) zoomInOut = false;
1688                    if(typeof mapTitle == 'undefined' || !mapTitle) mapTitle = '';
1689                    if(typeof mapContent == 'undefined' || !mapContent) mapContent = '';
1690                    if(typeof useTitle == 'undefined' || !useTitle) useTitle = false;
1691                    if(typeof useContent == 'undefined' || !useContent) useContent = false;
1692
1693                    var c_map = new naver.maps.Map(container, options);
1694                    var marker = new naver.maps.Marker({ position: new naver.maps.LatLng(lat, lng), map: c_map});
1695
1696                    if(zoomInOut == true) {
1697                        // options.zoomControl = true;
1698                        // options.zoomControlOptions = {
1699                        //     position: naver.maps.Position.RIGHT_CENTER
1700                        // };
1701
1702                        var zoomControlHtml = '';
1703                        zoomControlHtml += '\
1704                            <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);">\
1705                                <div class="btn-zoom-control" data-inout="I" style="cursor: pointer; width: 30px; height: 30px;">\
1706                                    <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>\
1707                                </div>\
1708                                <div class="slider-wrap-container" style="height: 130px;">\
1709                                    <div class="slider-wrap small" style="text-align: center; height: 100%;">\
1710                                        <div style="max-height: 100%;" class="zoom-control-slider"></div>\
1711                                    </div>\
1712                                </div>\
1713                                <div class="btn-zoom-control" data-inout="O" style="cursor: pointer; width: 30px; height: 30px;">\
1714                                    <svg style="fill: #6b6b6b; margin: 3px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
1714<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>\
1715                                </div>\
1716                            </div>\
1717                        ';
1718                        var $zoomController = $(zoomControlHtml);
1719                        $(container).append($zoomController);
1720                        var zoom_slider = $zoomController.find('.zoom-control-slider').slider({
1721                            'orientation': 'vertical',
1722                            'min' : 6,
1723                            'max' : 21,
1724                            'step' : 1,
1725                            'value' : 17,
1726                            'handle' : 'square',
1727                            'reversed' : true,
1728                            'tooltip' : 'hide',
1729                        }).on('slide', function(data) {
1730                            c_map.setZoom(data.value);
1731                            c_map.setCenter(marker.getPosition());
1732                        }).on('slideStop', function(data) {
1733                            c_map.setZoom(data.value);
1734                            c_map.setCenter(marker.getPosition());
1735                        });
1736                        $zoomController.find('.btn-zoom-control').on('click', function() {
1737                            if($(this).data('inout') == 'I') {
1738                                c_map.setZoom(c_map.getZoom() + 1);
1739                                zoom_slider.slider('setValue', c_map.getZoom());
1740                            } else if($(this).data('inout' == 'O')) {
1741                                c_map.setZoom(c_map.getZoom() - 1);
1742                                zoom_slider.slider('setValue', c_map.getZoom());
1743                            }
1744                        });
1745
1746                        naver.maps.Event.addListener(c_map, 'zoom_changed', function(zoom) {
1747                            zoom_slider.slider('setValue', c_map.getZoom());
1748                        });
1749                    }
1750
1751                    if((useTitle == true || useContent == true) && (mapTitle || mapContent)) {
1752                        var iwContent = '';
1753                        if(useTitle == true && mapTitle) {
1754                            iwContent = '<div class="title">' + mapTitle + '</div>';
1755                        }
1756                        if(useContent == true && mapContent) {
1757                            iwContent += '<div class="content">' + mapContent + '</div>';
1758                        }
1759
1760                        if(iwContent) {
1761                            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>';
1762                            var infoWindow = $(iwContent);
1763                            $(container).append(infoWindow);
1764                            // infoWindow.css('bottom', 'calc(-100% + ' + (infoWindow.outerHeight() + 36) + 'px)');  
1765                        }
1766                    }
1767                    $(window).on("resize", function() {
1768                        c_map.setCenter(marker.getPosition());
1769                    });
1770
1771                    c_map.setSize(new naver.maps.Size($(container).outerWidth(), $(container).outerHeight()));
1772                });
1773            }
1774
1775            // $.each($('.sort-empty'),function(i,v) {
1776            //     if($(this).next().hasClass('sort-empty') && !$(this).next().hasClass('page')) {
1777            //         var $empty = $('<div class="sort-empty page">PAGE EMPTY</div>');
1778            //         //var $empty = ($(this).hasClass('use-link')) ?  $('<div class="sort-empty page">PAGE LINKED</div>') :  $('<div class="sort-empty page">PAGE EMPTY</div>');
1779            //         if(!$(this).hasClass('page')) $(this).after($empty);
1780            //     }
1781            // });
1782
1783            // $('.reorderModal').scrollTo('.reorderBlock[data-id="' + selectID + '"]',{offset:-200});
1784            // $('.reorderBlock[data-id="' + selectID + '"]').addClass('active');
1785
1786            // reorder page click
1787            $center_area.find(".page-list-area .gallery-name").on("click", function() {
1788                $.reorderON($(this).data('page'));
1789            });
1790            $center_area.find('.video-gallery-url').attr('data-gallery','');
1791            
1792            // reorder gallery gjs setting
1793            $('.reorderModal .center-area .reorderBlock[data-type="gallery"] input.gjs').parents('.element[data-type="gallery"]').each(function() {
1794                setGalleryJS('reorder-block',$(this));
1795            });
1796
1797            blockSortable();
1798            $.processOFF();
1799        });
1800    }
1801
1802    jQuery.reorderOFF = function() {
1803        window.basketBlockHtml = '';
1804        window.pageList = [];
1805        window.pageListChangeFlag = [];
1806        $(".new-dsgn-body").remove();
1807        $('.reorderModal').fadeOut(function() {
1808            $(this).remove();
1809            reorderFIXED = '';
1810        });
1811    }
1812
1813    jQuery.viewON = function() {
1814        var $view = $('<div class="viewModal"></div>');
1815
1816        if ($('.viewModal').length < 1) {
1817            $view.css({
1818                'position' : 'fixed',
1819                'width' : '100%',
1820                'height' : '100%',
1821                'background' : '#FFF url(https://storage.googleapis.com/i.addblock.net/preloader2.gif) center center no-repeat',
1822                'z-index' : '10000000000',
1823                'display' : 'none',
1824                'overflow' : 'auto'
1825            });
1826            $('body').prepend($view);
1827            var $content = $('<div class="content"></div>'),
1828                $h1 = $('<h1></h1>').css({
1829                    'position' : 'absolute',
1830                    'z-index' : '100001',
1831                    'right' : '0px'
1832                }),
1833                $close = $('<div class="pull-right"><i class="fa fa-times"></i></div>').css({
1834                    'margin-right' : '18px',
1835                    'margin-top' : '-16px',
1836                    'background-color': '#556273',
1837                    'color': '#fff',
1838                    'font-size': '18px',
1839                    'padding': '6px 9px',
1840                    'cursor': 'pointer',
1841                    'border-radius' : '20px'
1842                }),
1843                $iframe = $('<iframe src="http://' + SID + '.' + HOST + '/render/' + PAGE + '"></iframe>');
1844
1845            $iframe.css({
1846                'position' : 'absolute',
1847                'top' : '0',
1848                'left' : '0',
1849                'width' : '100%',
1850                'height' : '100%',
1851                'z-index' : '100000',
1852                'border' : 'none'
1853            });
1854
1855
1856            $close.on('click',function() {
1857                $.viewOFF();
1858            });
1859            $content.append($h1).append($iframe);
1860            $h1.append($close);
1861            $view.append($content);
1862            $view.fadeIn();
1863        }
1864    }
1865
1866    jQuery.viewOFF = function() {
1867        $('.viewModal').fadeOut(function() {
1868            $(this).remove();  
1869        });
1870    }
1871
1872    jQuery.historyON = function() {
1873        viewmode('view');
1874    }
1875
1876    $.fn.showUpgradePlanModal = function(sid, plan, upgrade_plan, fn) {
1877        if($('.site-upgrade-wrap').length > 0 || typeof checkUpgradeModal != "undefined" && checkUpgradeModal) return false;
1878        var checkUpgradeModal = true;
1879
1880        var check_plan = (!plan || plan == 'FR' || plan == 'FREE') ? false : true,
1881            log_fn = (!fn) ? '' : '.' + fn,
1882            log_plan = (!upgrade_plan) ? '' : '.' + upgrade_plan,
1883            upgrade_plan = (!upgrade_plan) ? '' : '/plan/' + upgrade_plan,
1884            upgrade_url = (!upgrade_plan) ? '/upgrade' : ((check_plan) ? '/upgrade/change/site/' + sid + upgrade_plan : '/upgrade/buy/site/' + sid + upgrade_plan),
1885            modal_title = $.lang[LANG]['config.upgrade-plan' + log_plan + log_fn + '.title'],
1886            modal_description =  $.lang[LANG]['config.upgrade-plan' + log_plan + log_fn + '.description'],
1887            str = '\
1888                <div class="site-upgrade-wrap">\
1889                    <p class="description">' + modal_description + '</p>\
1890                    <div class="btn-box">\
1891                        <a href="' + upgrade_url + '"><i class="fa fa-level-up"></i>'+$.lang[LANG]['config.upgrade-plan.btn']+'</a>\
1892                    </div>\
1893                </div>\
1894            '; 
1895
1896        var modal = $(this).showModalFlat(modal_title, str, false, false, '', '', '', '', '', '', '', function() {
1897            checkUpgradeModal = false;
1898        });
1899    }
1900
1901    $.fn.showModal = function (header, content, footer, cancel, confirm, callback, backdrop) {
1902        $('.editor-navbar').css('z-index','1030');
1903        var HTML = '<div class="modal modal-default fade" id="generic-modal">' +
1904            '   <div class="modal-dialog" style="padding-top:5%;">' +
1905            '       <div class="modal-content">' +
1906            '           <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>' +
1907            '           <div class="modal-body">' +
1908            '               <h3 class="modal-title">' + header +
1909            '               </h3>' + content +
1910            '           </div>';
1911            if(footer==true) { 
1912                HTML = HTML + '<div class="modal-footer">';
1913                if(cancel == true) {
1914                    HTML = HTML + '<button type="button" class="btn btn-default btn-sm" data-dismiss="modal">취소</button>';
1915                } else if(confirm == true) {
1916                    HTML = HTML + '<button type="button" class="btn btn-primary btn-sm ok-button-dialog">확인1</button>';
1917                }
1918                HTML = HTML +
1919                '       </div>';
1920            }
1921            HTML = HTML +
1922            '       </div>' +
1923            '   </div>' +
1924            '</div>';
1925
1926        var container = $('<div class="generic-modal"></div>').html(HTML);
1927        $('body').append(container);
1928        var newInstance = jQuery.extend(true, {}, container);
1929        newInstance.find('.ok-button-dialog').bind('click', function () {
1930            callback();
1931        });
1932        var modalElement = newInstance.find('#generic-modal');
1933        if(backdrop) modalElement.modal({ backdrop : 'static', keboard : false});
1934        else modalElement.modal();
1935
1936        modalElement.on('hidden.bs.modal', function(e) {
1937            // $('.editor-navbar').css('z-index','1040');
1938            $('.generic-modal').remove();
1939            $('.modal-backdrop').remove();
1940        });
1941
1942        return modalElement;
1943    }
1944
1945
1946    $.fn.showModalFlat = function (header, content, footer, confirm, callback, closetext, oktext, size, backdrop, closecallback, showcallback, hidecallback, buttontop) {
1947    /**
1948     * @param header
1949     * @param content
1950     * @param footer
1951     * @param confirm
1952     * @param callback
1953     * @param closetext
1954     * @param oktext
1955     * @param size
1956     * @param backdrop
1957     * @param closecallback
1958     * @param showcallback
1959     * @param hidecallback
1960     * */
1961        // if($('#flat-modal.event').length) return;
1962
1963        size = (typeof size == 'undefined') ? '' : size;
1964
1965        var buttontop = (typeof buttontop != 'undefined' && buttontop) ? buttontop : false;
1966        var reg_zindex = /\bzindex(\d+)\b/;
1967        var matches = size.match(reg_zindex);
1968        var zindex = (matches) ? matches[1] * 1 : -1;
1969
1970        if(!matches && $('.bc-modal.open').length > 0)  zindex = 1043;
1971
1972        if(size.indexOf(',') > -1) {
1973            var modal_name = size.split(',');
1974            var modal_class = '';
1975
1976            size = modal_name[0];
1977            modal_class = modal_name[1];
1978        }
1979
1980        var noBackdrop = (typeof backdrop != 'undefined' && backdrop === 'none') ? true : false;
1981        backdrop = (typeof backdrop != 'undefined' && backdrop === true) ? true : false;
1982
1983        // $('.editor-navbar').css('z-index','1030');
1984
1985        var checkCLBtnMode = (size.indexOf('cl-s-btn') > -1) ? true : false,
1986            close_btn = $.lang[LANG]['config.close'],
1987            close_btn_class = 'btn-default',
1988            ok_btn = $.lang[LANG]['config.ok'],
1989            ok_btn_class = 'btn-primary',
1990            btn_html = '';
1991
1992        if( closetext == 'cancel') {
1993            close_btn = $.lang[LANG]['config.cancel'];
1994        } else if( closetext == 'close' ) {
1995            close_btn = $.lang[LANG]['config.close'];
1996        } else if( closetext == 'ok' || closetext == 'notice.ok' ) {
1997            close_btn = $.lang[LANG]['config.'+closetext];
1998            close_btn_class = 'btn-primary ok-button-dialog';
1999        } else if( closetext == 'move.cancel' ) {
2000            close_btn = $.lang[LANG]['config.'+closetext];
2001            close_btn_class = 'closemodal';
2002        } else if ( typeof closetext != 'undefined') {
2003            if( closetext.match(/\./g) !== null ) close_btn = $.lang[LANG][closetext];
2004            else if(closetext.length > 0) close_btn = closetext;
2005        }
2006        
2007        if( oktext == 'save' ) {
2008            ok_btn = $.lang[LANG]['config.save'];
2009        } else if( oktext == 'send' ) {
2010            ok_btn = $.lang[LANG]['config.send'];
2011        } else if( oktext == 'ok' ) {
2012            ok_btn = $.lang[LANG]['config.ok'];
2013        } else if( oktext == 'move.ok' ) {
2014            ok_btn = $.lang[LANG]['config.'+oktext];
2015            ok_btn_class = 'btn-primary ok-button-dialog movetocreatorlink';
2016        } else if( oktext == 'move.ok2' ) {
2017            ok_btn = $.lang[LANG]['config.'+oktext];
2018            ok_btn_class = 'btn-primary ok-button-dialog movetocreatorlink';
2019        } else if( oktext == 'move.domain' ) {
2020            ok_btn = $.lang[LANG]['config.'+oktext];
2021            ok_btn_class = 'btn-primary ok-button-dialog movedomain';
2022        } else if ( typeof oktext != 'undefined') {
2023            if( oktext.match(/\./g) !== null ) ok_btn = $.lang[LANG][oktext];
2024            else if(oktext.length > 0) ok_btn = oktext;
2025        } 
2026        var flat_modal_cnt = $('.modal-default').length,
2027            flat_modal_id = (flat_modal_cnt == 0) ? 'flat-modal': 'flat-modal'+flat_modal_cnt,
2028            btn_html_close = '<button type="button" class="btn '+ close_btn_class +' btn-sm close-button-dialog" data-dismiss="modal">' + close_btn + '</button>';             
2029
2030        if(confirm == true) {
2031            if(checkCLBtnMode) {
2032                var btn_html_ok = '<button type="button" class="btn '+ ok_btn_class +' btn-sm ok-button-dialog">' + ok_btn + '</button>';                
2033                btn_html_ok = (buttontop && (oktext == '')) ? '' : btn_html_ok;
2034                btn_html = btn_html_ok + btn_html_close;
2035            } else {
2036                btn_html = btn_html_close + '<button type="button" class="btn '+ ok_btn_class +' btn-sm ok-button-dialog">' + ok_btn + '</button>';
2037            }
2038        } else btn_html = btn_html_close;
2039
2040        var HTML = '<div class="modal modal-default fade" id="'+flat_modal_id+'">' +
2041            '   <div class="modal-dialog '+size+'">' +
2042            '       <div class="modal-content" data-buttontop="'+buttontop+'">' +
2043            '           <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
2043-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>' +
2044            '           <div class="modal-body">';
2045            HTML += (buttontop) ? '\
2046                            <div class="modal-top">\
2047                                <div class="modal-title-wrap">\
2048                                    <h3 class="modal-title">' + header + '</h3>\
2049                                </div>\
2050                                <div class="modal-title-button">' + btn_html_close + btn_html_ok + '</div>\
2051                            </div>' : '<h3 class="modal-title">' + header + '</h3>';
2052            HTML += content +'\
2053                        </div>';
2054            if(footer==true) {
2055                HTML = HTML + 
2056                '      <div class="modal-footer">';
2057                HTML = HTML + btn_html + 
2058                '      </div>';
2059            }
2060            HTML = HTML +
2061            '       </div>' +
2062            '   </div>' +
2063            '</div>';
2064
2065        var time = new Date().getTime();
2066        var container = $('<div class="flat-modal"></div>').html(HTML);
2067        
2068        if(typeof modal_class != "undefined" && modal_class) container.addClass(modal_class);
2069        if(size && size.indexOf('cl-modal') > 0 || (size && size.indexOf('cl-cmmodal') > -1)) {
2070            var mobile_close_btn = '\
2071                    <button class="cl-mobile-btn close" data-dismiss="modal" aria-label="Close">\
2072                        <span aria-hidden="true">\
2073                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
2074                                <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 "/>\
2075                            </svg>\
2076                        </span>\
2077                    </button>\
2078                    ';
2079
2080            container.find('.modal').prepend(mobile_close_btn);
2081            
2082            if(confirm==false && (closetext=='close' || closetext=='cancel')) container.find('.close-button-dialog').addClass('clostbtnfalse'); //닫기 버튼 하나일 경우 공통 class
2083            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 버튼 하나일경우
2084
2085            if(size.indexOf('cl-modal') > -1) container.addClass('cl-flat-modal');
2086            else if(size.indexOf('cl-cmmodal') > -1) container.addClass('cl-common-modal');
2087            if(size.indexOf('cl-alert') > -1) container.addClass('cl-alert-modal');
2088
2089            if(size.indexOf('confirm-resource-folder-delete') && size.indexOf('modal-over-1') > -1) container.addClass('modal-over-1');
2090
2091            if(size.indexOf('pg-modal') > -1) container.addClass('pg-modal-wrap'); 
2092            else if(size.indexOf('cl-common-notice') > -1) {  //공통 notice icon 추가
2093                var svg = '\
2094                    <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"/>\
2095                        <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"/>\
2096                    </svg>\
2097                    ';
2098                container.find('.modal-title').before(svg);
2099                if(size.indexOf('modal-over-1') > -1) container.addClass('modal-over-1');
2100            } else if(size.indexOf('guidePopup') > -1) {
2101                container.find('.modal-title').not('.guidetitle').remove();
2102                container.addClass('guidePopup-wrap');
2103            } else if(size.indexOf('modal-product-badge') > -1) {
2104                container.addClass('modal-product-badge-wrap');
2105                if(size.indexOf('cl-change-badge-design') > -1) {
2106                    container.addClass('modal-change-badge-design-wrap');
2107                }
2108            } else if(size.indexOf('cl-delete-badge-image') > -1) {
2109                container.addClass('modal-delete-badge-image');
2110            } else if(size.indexOf('modal-addFranchiseBar') > -1) {
2111                container.addClass('modal-addFranchiseBar-wrap');
2112            }
2113        }
2114
2115        $('body').append(container);
2116        var newInstance = jQuery.extend(true, {}, container);
2117        var modalElement = newInstance.find('#'+flat_modal_id);
2118        if(noBackdrop) modalElement.modal({ backdrop : false});
2119        else if(backdrop) modalElement.modal({ backdrop : 'static'});
2120        else modalElement.modal();
2121
2122        if(zindex > -1) {
2123            modalElement.css('z-index', zindex);
2124            modalElement.closest('.flat-modal').next('.modal-backdrop').attr('style','z-index: '+(zindex-1)+'!important;');
2125        }
2126
2127        newInstance.find('.ok-button-dialog').bind('click', function () {
2128            if(typeof callback == 'function')
2129                callback();
2130        });
2131
2132        newInstance.find('.close-button-dialog').bind('click', function () {
2133            if(typeof closecallback == 'function') {
2134                closecallback();
2135            }
2136        });
2137
2138        modalElement.on('shown.bs.modal', function(e) {
2139            if($('#ch-plugin').length > 0) $('#ch-plugin').attr('style','z-index: 1 !important; pointer-events: none !important;');
2140            var modal = document.querySelector('.modal');
2141            // modal.style.position = 'absolute';
2142            // setTimeout(function() {
2143                modal.style.position = 'fixed';
2144            // },0);
2145            if(typeof showcallback == 'function') showcallback();
2146        });
2147
2148        modalElement.on('hide.bs.modal', function(e) {
2149            if($(this).find('input:focus').length > 0) {
2150                e.preventDefault();
2151                return false;
2152            }
2153        });
2154        
2155        modalElement.on('hidden.bs.modal', function(e) {
2156            if(typeof isEDIT != 'undefined' && isEDIT === false) editEL = '';
2157            if(typeof hidecallback == 'function') hidecallback();
2158            var flat_modal_id = $(this).attr('id');
2159            // $('.editor-navbar').css('z-index','1040');
2160            var this_modal = $('#'+flat_modal_id).closest('.flat-modal');
2161            this_modal.next('.modal-backdrop').remove();
2162            this_modal.remove();
2163
2164            if($('.modal-backdrop').length) {
2165                setTimeout(function() {
2166                    $('body').addClass('modal-open');    
2167                },10);                
2168            }
2169            $('body').removeClass('no-fixed');
2170            if($('#ch-plugin').length > 0) $('#ch-plugin').attr('style','z-index: 10000000 !important; pointer-events: auto !important;');
2171        });
2172
2173        return modalElement;
2174    }
2175
2176    $.fn.showPopupModal = function (data,sid) {
2177        // console.log('showPopupModal');
2178        
2179        var img_count = data.length,
2180            img_w = new Array(), 
2181            img_h = new Array(), 
2182            counter = 0,
2183            sid = (typeof sid != 'undefined') ? sid : SID,
2184            popup_data = new Array();
2185
2186        $('#el-empty').html('');
2187        $.each(data,function(i,v) {
2188            var check_img = v.popupimg + '?' + new Date().getTime();
2189            var $img = $('<img/>').attr('src',check_img);
2190            $img.error(function() {
2191                data[i]['popupimg'] = '//storage.googleapis.com/i.addblock.net/img_broken_fill_500.png';
2192                $(this).attr('src', '//storage.googleapis.com/i.addblock.net/img_broken_fill_500.png');
2193            });
2194            $('#el-empty').append($img);
2195        });
2196
2197        var $imgs = $('#el-empty img');
2198        $.each($imgs,function(i,v) {
2199            $(this).one('load',function() {
2200                counter++;
2201                img_w[i] = this.width;
2202                img_h[i] = this.height;
2203                if(counter == img_count) getPopupFunction();
2204            });
2205            if(this.complete) $(this).load();
2206        });
2207
2208        function getPopupFunction() {
2209            $('#el-empty').html('');
2210            var html = '',
2211                display = new Array();
2212
2213            $.each(data, function(i,o) {
2214                var isCookie = ($.cookie(sid + 'Popup' + i)) ? 'style= display:none;' : '';
2215                display.push(isCookie);
2216
2217                var plink = (typeof o.popuplink != 'undefined' && o.popuplink != 'javascript:;' && o.popuplink.length > 0) ? o.popuplink : 'javascript:;',
2218                    plink_target = (typeof o.popuplink_target != 'undefined' && o.popuplink_target === true) ? 'target="_blank"' : '',
2219                    link_option = '';
2220
2221                if(typeof o.popuplink == 'undefined') o.popuplink = '';
2222                if(typeof o.popuplink_target == 'undefined') o.popuplink_target = '';
2223                if(typeof o.popuptime == 'undefined') o.popuptime = '';
2224
2225                if(plink != '' && plink != 'javascript:;') {
2226                    if(checkBase64Encode(plink)) plink = Base64.decode(plink);
2227                    var _menuList = (PAGE_MODE == 'c') ? MENULIST : property.MENULIST;
2228                    
2229                    if(plink.match(/^\@/g) !== null) {                                                  // link-type: link-bookmark ==> a[attr-bookmark]
2230                        var _settings = (PAGE_MODE == 'c') ? SETTINGS : property.SETTINGS,
2231                            bookmark_seq = plink.replace(/^\@/g,'');
2232                            
2233                        if(typeof _settings == 'undefined' || typeof _settings.blockBookmarkList == 'undefined' || _settings.blockBookmarkList['bookmark' + bookmark_seq] == 'undefined') {
2234                            plink = '';
2235                            link_option = '';
2236                        } else {
2237                            link_option = 'attr-bookmark="' + bookmark_seq + '"';
2238                        }
2239                    } else if(plink.match(/^flink\@[0-9]/gi) !== null) {                                // link-type: link-file     ==> a[attr-flink]
2240                        link_option = 'attr-flink="' + plink.replace(/^flink\@/gi,'') + '"';
2241                        plink_target = '';
2242                    } else if(_menuList.indexOf(plink.replace(/^\//g,"").replace(/ /g,"-")) > -1) {     // link-type: link-menu     ==> a[data-user-link]
2243                        link_option = 'data-user-link="' + plink + '"';
2244                    } else {                                                                            // link-type: link-out      ==> a[attr-link]
2245                        link_option = 'attr-link="' + plink + '"';
2246                    }
2247
2248                    plink = (PAGE_MODE == 'c') ? makeLinkUrl(plink, ONE, VIEW) : makeLinkUrl(plink, property.ONE, property.VIEW);
2249                }
2250
2251                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] + '>' + 
2252                '   <div class="popup-content">' +
2253                '       <div class="popup-header">' +
2254                '           <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>' +
2255                '       </div>' +
2256                '       <div class="popup-body">' +
2257                '          <a href="' + plink + '" ' + plink_target  + ' ' + link_option + '>' +
2258                '             <div class="img-wrap">' +
2259                '               <img src="' + o.popupimg + '" alt="" class="img-responsive img-popup" />' +
2260                '             </div>' +
2261                '          </a>' +
2262                '       </div>' +
2263                '       <div class="popup-footer clearfix">' +
2264                '           <ul class="text-center">' +
2265                '               <li class="sitePopupTodayHide">' +
2266                '                   <input type="checkbox" value="" class="hide">' +
2267                '                   ' + $.lang[LANG]['editor.popup.close-24hours'] + 
2268                '               </li>' +
2269                '               <li class="sitePopupClose">' + $.lang[LANG]['config.close'] + '</li>' +
2270                '           </ul>' +
2271                '       </div>' +
2272                '   </div>' +
2273                '</div>';
2274                if(data.length == (i+1) )  setPopupFunction(html,display);
2275            });
2276
2277        }
2278
2279        function setPopupFunction(html, display) {
2280
2281            var container = $('<div class="popup"></div>').html('<div class="popup-modal">' + html + '</div>');
2282            if($('.dsgn-body').find('.popup').length > 0 )  { 
2283                $('.dsgn-body').find('.popup').replaceWith(container);
2284            } else { 
2285                $('.dsgn-body').append(container); 
2286            }
2287
2288            var newInstance = jQuery.extend(true, {}, container);
2289            var sitePopupElement  = newInstance.find('.popup-modal');
2290
2291            var total_w = 0,
2292                add_w = 0, 
2293                d_top = $('.header.el-menu > header').outerHeight() + 15, 
2294                d_left = 0,
2295                x = 0, y = 0, y_r = 0;
2296
2297            var checkDsgnDodyW = $('.dsgn-body').width() + $('.dsgn-body').css('padding-left').replace('px','') * 1;
2298            if($('.header.el-menu').hasClass('sidebar') && checkDsgnDodyW > 752 ) d_top = 15;
2299
2300            for(i=0; i<img_w.length; i++) {
2301                if(parseInt(img_w[i]) > $('.dsgn-body').width()-30 ) {
2302                    img_w[i] = $('.dsgn-body').width()-30;
2303                }
2304                if(display[i]) { 
2305                    continue;
2306                } else {
2307                    total_w = total_w + parseInt(img_w[i]) + 30;
2308                }
2309            }
2310           
2311            var isOverflow = ($('.dsgn-body').width() < total_w) ? true : false,
2312                display_i = -1;
2313            
2314            if(isOverflow) { sitePopupElement.addClass('popupimg-overflow-y');
2315            } else { sitePopupElement.removeClass('popupimg-overflow-y'); }
2316
2317            $.each(img_w, function(i,v) {
2318                if(display[i]) {
2319                    return true;
2320                } else {
2321                    display_i++;
2322                }
2323
2324                if(isOverflow) {
2325                    x = (display_i==0) ? d_top : d_top + (display_i*30);
2326                    y = d_left + ((display_i+1)*30);
2327                    y_r = 120 - y;
2328
2329                    img_w[i] = 'auto';
2330                } else {
2331                    d_left = ($('.dsgn-body').width() - total_w)/2;
2332
2333                    x = d_top;
2334                    y = d_left + add_w + (i*15);
2335                }
2336                add_w = add_w + v;
2337
2338                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]};
2339                sitePopupElement.find('#'+sid +'Popup'+ i).css(css_val);
2340            });
2341            return sitePopupElement;
2342        }
2343    }
2344
2345    jQuery.guideVideoON = function() {
2346        // 편집 모드를 처음으로 보는 경우가 아니면 ( 주요기능을 이미 둘려봤으면 )
2347        if( LANG == 'ko' || typeof SETTINGS.showGuide != 'undefined')
2348            return false;
2349
2350        hideElementListPanel();
2351        var $guideVideoModal = $('<div class="guideVideoModal config-modal"></div>'),
2352            $content = $('<div class="content"></div>');
2353
2354        if ($('.guideVideoModal').length < 1) {
2355            $('body').prepend($guideVideoModal);
2356            $content.css({
2357                "width" : "100%",
2358                "height" : "100%",
2359                "background-color" : "rgba(0,0,0,0.6)",
2360                "display" : "none"
2361            });
2362
2363            $guideVideoModal.append($content);
2364            $guideVideoModal.css({
2365                "display": "inherit",
2366                "position": "fixed",
2367                "z-index": "99999999",
2368                "top": "0",
2369                "left": "0",
2370                "width": "100%",
2371                "height": "100%",
2372                "text-align": "center",
2373                "background-color" : "transparent"
2374            });
2375            $guideVideoModal.fadeIn();
2376
2377            var $guideVideo = $('<div class="guideVideo">'),
2378                $close = $('<div class="close"><img src="https://storage.googleapis.com/i.addblock.net/fa-close-modal.png" alt="close" /></div>'),
2379                $close2 = $('<button type="button" class="btn btn-primary btn-sm ok-button-dialog">' + $.lang[LANG]['config.ok'] + '</button>');
2380                $header = $('<div class="header"><h2>' + $.lang[LANG]["editor.guide.tutorial-video"] + '</h2></div>'),
2381                $body = $('<div class="body"></div>'),
2382                $contentbox = $('<div class="contentbox"></div>'),
2383                $tutorialVideo = $('<div class="tutorial-video"></div>'),
2384                $videoWrap = $('<div class="video-wrap guideVideo-stopPlay"><div id="guide-video-modal-video-overlay"></div></div>'),
2385                $watchAgainNote = $('<span class="watch-again-note">' + $.lang[LANG]['tutorial-video.watch-again-note'] + '</span>'),
2386                $bottom = $('<div class="bottom"></div>');
2387
2388            $close.on('click',function() { $.guideVideoOFF(); });
2389            $close2.on('click',function() { $.guideVideoOFF(); });
2390
2391            $videoWrap.on('click', function() {
2392
2393                $(this).toggleClass('guideVideo-stopPlay');
2394
2395                if(!$(this).hasClass('guideVideo-stopPlay')) {
2396                    if ( LANG == 'en' )
2397                        var link = "https://www.youtube.com/embed/p6fyIMl2BcI";
2398
2399                    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>';
2400
2401                    $(this).html(html);
2402
2403                }
2404            });
2405
2406            $tutorialVideo.append( $videoWrap );
2407            $contentbox.append( $tutorialVideo );
2408
2409            $bottom.append($close2).append($watchAgainNote);
2410            $body.append($contentbox).append($bottom);
2411            $guideVideo.append($header).append($close).append($body);
2412            $content.append($guideVideo);
2413            $content.fadeIn();
2414
2415        }
2416
2417        var $thisContent = $('.guideVideoModal .contentbox');
2418        
2419    }
2420
2421    jQuery.guideVideoOFF = function() {
2422        $('.guideVideoModal').fadeOut(function() {
2423            $(this).remove();  
2424        });
2425    }
2426
2427
2428
2429
2430    $.fn.siteDelete = function(sid, code, options) {
2431        // isDelLangSite : 특정 다국어 삭제시 ( 사이트 삭제에서의 다국어 삭제는 false 임 )
2432        var isDelLangSite = (code) ? true : false;
2433        options = options || {};
2434
2435        var sdOrgSid = sid,
2436            sdSid = (isDelLangSite) ? sid + '__' + code : sid,
2437            sdMore = [''],
2438            sdResource = [],
2439            sdResourceIdx = -1,
2440            sdResourceTotal = 0,
2441            sdIdx = -1,
2442            p_w = 0, p_max = 100, p_unit = 1,
2443            p_step_max = 100, p_step_unit = 1, p_step_plus = 1,
2444            block_view = { 'gallery':1, 'forum':2, 'form':2 };
2445
2446        $.sd = {
2447            initVal: function() {
2448                p_step_max = 100;
2449                p_step_unit = 1;
2450                p_step_plus = 1;
2451
2452                sdIdx++;
2453
2454                if(!isDelLangSite) {
2455                    code = sdMore[sdIdx];
2456                    sdSid = (code) ? sid + '__' + code : sid;
2457                }
2458            },
2459            strProcess: function(step) {
2460                // console.log('step: ' + step + '');
2461                // console.log('p_w: '+ p_w + ', p_unit: ' + p_unit);
2462                var str = '', cnt = '';
2463
2464                switch(step) {
2465                    case 'init':
2466                        p_max = (isDelLangSite) ? 100 : 100/sdMore.length;
2467                        p_unit = p_max / 100;
2468
2469                        str = $.lang[LANG]['site.delete.process.init'];
2470                        break;
2471
2472                    case '1':
2473                        p_w += p_unit * 5;
2474
2475                        str = $.lang[LANG]['site.delete.process.step1'];
2476                        break;
2477
2478                    case 'end':
2479                        p_w = p_max * (sdIdx+1);
2480
2481                        var checkEnd = (sdMore.length > sdIdx+1) ? false : true;
2482
2483                        str = $.lang[LANG]['site.delete.process.step14'];
2484                        cnt = (checkEnd) ? '' : '<br>' + $.lang[LANG]['site.delete.process.more'];
2485
2486                        if(checkEnd) {
2487
2488                            if(isDelLangSite) {
2489                                var slog_lang = $('.language-contents .settings-language .selected-languages li[data-code="' + code + '"] .language-name').text();
2490                                setSiteLogs('settings.language','delete',{'lang':slog_lang,'code':code},'settings.language');
2491                            }
2492
2493                            setTimeout(function() {
2494                                $.progressOFF();
2495                            }, 500);
2496                        }
2497                        break;
2498
2499                    default:
2500                        if(step == '2') {
2501                            p_step_max = p_unit * 90;
2502                            p_step_unit = p_step_max / 13;
2503                        }
2504
2505                        if($.inArray(step,['3','4'])>-1) str = $.lang[LANG]['site.delete.process.step3'];
2506                        else if($.inArray(step,['5','6','7','8','8-more','9'])>-1) str = $.lang[LANG]['site.delete.process.step5'];
2507                        else str = $.lang[LANG]['site.delete.process.step'+step];
2508
2509                        if(step == '13-more') {
2510                            if(sdResource.length == 0) return false;
2511                            str += '( ' + (sdResourceIdx+1) + ' / ' + sdResource.length + ' )';
2512                        }
2513
2514                        if(p_step_plus > 0) p_w += p_step_unit;
2515                        break;
2516                }
2517
2518
2519                if(step == 'init' && sdIdx == 0) {
2520                    $.progressON(str,'','',true);
2521                } else {
2522                    $('.progressModal .progress-header h1').html(str);
2523                    $('.progressModal .progress-bar').css('width',p_w+'%');
2524                }
2525
2526                // console.log('p_w: '+ p_w + ', p_unit: ' + p_unit);
2527            },
2528            step0: function() {
2529                if(sdIdx == 0) $('#loading').addClass('hide');
2530
2531                var sdStep1 = $.sd.step1();
2532                sdStep1.done(function() {
2533                    $.sd.stepMultiCall('2');
2534                }).fail(function(sdStep1_msg){
2535                    console.log(sdStep1_msg);
2536
2537                    $.sd.stepEnd();
2538                    if(sdStep1_msg) $(this).showModalFlat('ERROR', sdStep1_msg, false, false,'', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0');
2539                });
2540            },
2541            step1: function() { // [del] ln_select
2542                var step1_deferred = $.Deferred();
2543
2544                $.post('/template/siteDelete', { step:'1', sid:sdOrgSid, code:code, isDelLangSite:isDelLangSite }, function(r1) {
2545                    if(typeof r1.error != 'undefiend' && r1.error) {
2546                        console.log('step1 reject');
2547                        step1_deferred.reject(r1.error);
2548                    }
2549                    $.sd.strProcess('1');
2550
2551                    setTimeout(function() {
2552                        step1_deferred.resolve();
2553                    }, 200);
2554                }, 'json');
2555                
2556                return step1_deferred.promise();
2557            },
2558            stepMultiCall: function(call_step) {
2559                if(call_step == '2') $.sd.strProcess('2');
2560
2561                if(call_step == '13-more') {
2562                    var sdStep3 = $.sd.step3();
2563                    sdStep3.done(function(next_step) {
2564                        if(next_step) $.sd.stepMultiCall(next_step);
2565                        else $.sd.stepEnd();
2566                    }).fail(function(sdStep3_msg) {
2567                        console.log(sdStep3_msg);
2568
2569                        $.sd.stepMultiCall('14');
2570                        if(sdStep3_msg) $(this).showModalFlat('ERROR', sdStep3_msg, false, false,'', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0');
2571                    });
2572                } else {
2573                    var sdStepMulti = $.sd.stepMulti(call_step);
2574                    sdStepMulti.done(function(next_step) {
2575                        if(next_step) $.sd.stepMultiCall(next_step);
2576                        else $.sd.stepEnd();
2577                    }).fail(function(sdStepMulti_msg){
2578                        console.log(sdStepMulti_msg);
2579
2580                        var jump_step = (call_step.indexOf('-more') > -1) ? Number(call_step.replace('-more', ''))+1 : Number(call_step)+1;
2581                        if(jump_step >= 15) $.sd.stepEnd();
2582                        else $.sd.stepMultiCall(jump_step.toString());
2583                        
2584                        console.log(call_step);
2585                        console.log('->');
2586                        console.log(jump_step.toString());
2587
2588                        if(sdStepMulti_msg) $(this).showModalFlat('ERROR', sdStepMulti_msg, false, false,'', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0');
2589                    });
2590                }
2591            },
2592            stepMulti: function(sd_step) {
2593                var stepMulti_deferred = $.Deferred();
2594
2595                $.post('/template/siteDelete', { step:sd_step, sid:sdOrgSid, code:code }, function(r) {
2596                    if(typeof r.error != 'undefiend' && r.error) {
2597                        console.log('stepMulti reject');
2598                        stepMulti_deferred.reject(r.error);
2599                    }
2600                    if(sd_step == '13') {
2601                        sdResource = (typeof r.r_list != 'undefiend') ? r.r_list : [];
2602                        sdResourceTotal = (typeof r.r_total != 'undefiend') ? r.r_total : 0;
2603                    }
2604
2605                    p_step_plus = (r.next_step=='' || r.next_step.indexOf('-more') > -1) ? 0 : 1;
2606                    if(r.next_step) $.sd.strProcess(r.next_step);
2607
2608                    setTimeout(function() {
2609                        stepMulti_deferred.resolve(r.next_step);
2610                    }, 100);
2611                }, 'json');
2612
2613                return stepMulti_deferred.promise();
2614            },
2615            step3: function() {
2616                var step3_deferred = $.Deferred();
2617
2618                sdResourceIdx++;
2619                var r_seq = sdResource[sdResourceIdx];
2620                if(typeof r_seq != 'undefiend' && r_seq) {
2621                    $.post('/template/siteDelete', { step:'13-more', sid:sdOrgSid, code:code, r_seq:r_seq }, function(r3) {
2622                        if(typeof r3.error != 'undefiend' && r3.error) {
2623                            console.log('step3 reject');
2624                            step3_deferred.reject(r3.error);
2625                        }
2626                        p_step_plus = 0;
2627                        if(r3.next_step) $.sd.strProcess(r3.next_step);
2628
2629                        setTimeout(function() {
2630                            step3_deferred.resolve(r3.next_step);
2631                        }, 50);
2632                    }, 'json');
2633                } else {
2634                    step3_deferred.resolve('14');
2635                }
2636
2637                return step3_deferred.promise();
2638            },
2639            stepEnd: function() {
2640                $.sd.strProcess('end');
2641
2642                var checkEnd = (sdMore.length > sdIdx+1) ? false : true;
2643                if(checkEnd) {
2644                    $('#loading').removeClass('hide');
2645
2646                    var completed = false,
2647                        completeDelete = function() {
2648                            if (completed) return;
2649                            completed = true;
2650                            $('.modal.modal-default.fade.in').css('zIndex','');
2651                            if (typeof options.onComplete == 'function') options.onComplete();
2652                            if (options.noRedirect) return;
2653
2654                            location.href='/';
2655                        };
2656
2657                    var deleted_modal = $(this).showModalFlat($.lang[LANG]['site.delete.process.end.title'], $.lang[LANG]['site.delete.process.end.description'], true, false, function() {
2658                        completeDelete();
2659                    }, 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0','','','',function() {
2660                        completeDelete();
2661                    });
2662                } else {
2663                    $.sd.initVal();
2664                    setTimeout(function() {
2665                        $.sd.step0();
2666                    }, 300);
2667                }
2668            }
2669        }
2670
2671
2672
2673        if(isDelLangSite) {
2674            $.sd.initVal();
2675            $.sd.strProcess('init');
2676            setTimeout(function() {
2677                $.sd.step0();
2678            }, 300);
2679        } else {
2680            $.post('/template/siteDelete', { step:'check', sid:sdOrgSid, code:code }, function(r1) {
2681                if(typeof r1.error != 'undefiend' && r1.error) {
2682                    alert(r1.error);
2683                    location.reload();
2684                    return false;
2685                }
2686                sdMore = r1.more_code;
2687
2688                $.sd.initVal();
2689                $.sd.strProcess('init');
2690
2691                setTimeout(function() {
2692                    $.sd.step0();
2693                }, 300);
2694            }, 'json');
2695        }
2696    }
2697
2698
2699    $.fn.siteClone = function(sid, dest_sid, isAddLangSite) {
2700        var scIdx = -1,
2701            scSid = [sid],
2702            scDest = [dest_sid],
2703            scCheck = { 'popup':false, 'music':false, 'gallery':false, 'forum':false },
2704            scOrgData = [],
2705            scDestData = [],
2706            scTempData = [];
2707
2708        var p_w = 0, p_max = 100, p_unit = 1,
2709            p_step_max = 100, p_step_unit = 1, p_step_plus = 1,
2710            block_view = { 'gallery':1, 'forum':2, 'form':2, 'contact':2 };
2711
2712        $.sc = {
2713            initVal: function() {
2714                p_step_max = 100;
2715                p_step_unit = 1;
2716                p_step_plus = 1;
2717              
2718                scIdx++;
2719                if(scIdx == 0) {
2720                    if(isAddLangSite) scCheck = { 'popup':true, 'music':true, 'gallery':true, 'forum':true };
2721                    else scCheck = { 'popup':false, 'music':false, 'gallery':false, 'forum':false };
2722                } else if(scIdx > 0) {
2723                    scDest.push(scSid[scIdx].replace(scSid[0],scDest[0])
2723);
2724                }
2725
2726                scOrgData.push({ 'total':0, 'normal_total':0, 'gallery' : { 'total':0 }, 'forum' : { 'total':0 }, 'form' : { 'total':0 }, 'contact' : { 'total':0 } });
2727                scDestData.push({ 'total':0, 'normal_total':0, 'gallery' : { 'total':0 }, 'forum' : { 'total':0 }, 'form' : { 'total':0 }, 'contact' : { 'total':0 } });
2728                scTempData.push({ 'gallery':false, 'forum':false, 'form':false, 'contact':false });
2729            },
2730            strCheck: function() {
2731                var checkbox = clSVG('checkbox',16,16,false,'');
2732
2733                return '\
2734                <div class="check-wrap">\
2735                    <div class="box">\
2736                        <div class="newcheckbox hand checkbox">\
2737                            <label>\
2738                                <input type="checkbox" class="check-popup" name="check-popup">\
2739                                ' + checkbox + '\
2740                            </label>\
2741                            <span>' + $.lang[LANG]['site.clone.check.popup'] + '</span>\
2742                        </div>\
2743                        <div class="newcheckbox hand checkbox">\
2744                            <label>\
2745                                <input type="checkbox" class="check-music" name="check-music">\
2746                                ' + checkbox + '\
2747                            </label>\
2748                            <span>' + $.lang[LANG]['site.clone.check.music'] + '</span>\
2749                        </div>\
2750                        <div class="newcheckbox hand checkbox">\
2751                            <label>\
2752                                <input type="checkbox" class="check-gallery" name="check-gallery">\
2753                                ' + checkbox + '\
2754                            </label>\
2755                            <span>' + $.lang[LANG]['site.clone.check.gallery'] + '</span>\
2756                        </div>\
2757                        <div class="newcheckbox hand checkbox">\
2758                            <label>\
2759                                <input type="checkbox" class="check-forum" name="check-forum">\
2760                                ' + checkbox + '\
2761                            </label>\
2762                            <span>' + $.lang[LANG]['site.clone.check.forum'] + '</span>\
2763                        </div>\
2764                    </div>\
2765                    <p><span class="error">' + $.lang[LANG]['site.clone.check.info.1'] + '\
2766                    <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'] + '">\
2767                        <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"/>\
2768                    </svg>' + $.lang[LANG]['site.clone.check.info.2'] + '</span></p>\
2769                </div>\
2770                ';
2771            },
2772            strProcess: function(step) {
2773                // console.log('step: ' + step + '');
2774                // console.log('p_w: '+ p_w + ', p_unit: ' + p_unit);
2775
2776                var str = '',
2777                    cnt = '';
2778
2779                switch(step) {
2780                    case 'init': // 0%
2781                        str = $.lang[LANG]['site.clone.process.init'];
2782                        break;
2783
2784                    case '1': // 5%
2785                        if(scIdx == 0) {
2786                            p_max = 100 / scSid.length;
2787                            p_unit = p_max / 100;
2788                        }
2789
2790                        p_w += p_unit * 5;
2791
2792                        str = $.lang[LANG]['site.clone.process.step1'];
2793                        if(!isAddLangSite) {
2794                            if(!scCheck['popup'] && !scCheck['music']) str = $.lang[LANG]['site.clone.process.step1.1'];
2795                            else if (scCheck['popup'] && !scCheck['music']) str = $.lang[LANG]['site.clone.process.step1.2'];
2796                            else if (!scCheck['popup'] && scCheck['music']) str = $.lang[LANG]['site.clone.process.step1.3'];
2797                        }
2798                        break;
2799
2800                    case '2': // 0%
2801                        str = $.lang[LANG]['site.clone.process.step2'];
2802                        break;
2803
2804                    case '2-ok':                        
2805                        str = $.lang[LANG]['site.clone.process.step2'];
2806                        cnt = '(0/' + scOrgData[scIdx]['total'] + ')';
2807
2808                        // step3,4 init
2809                        p_step_max = p_unit * 60;
2810                        p_step_unit = p_step_max / scOrgData[scIdx]['total'];
2811                        break;
2812
2813                    case '3': // 30%
2814                        str = $.lang[LANG]['site.clone.process.step3'];
2815                        cnt = '(' + scDestData[scIdx]['total'] + '/' + scOrgData[scIdx]['total'] + ')';
2816                        break;
2817
2818                    case '3-ok':
2819                        p_w += p_step_unit * p_step_plus;
2820
2821                        str = $.lang[LANG]['site.clone.process.step3'];
2822                        cnt = '(' + scDestData[scIdx]['total'] + '/' + scOrgData[scIdx]['total'] + ')';
2823                        break;
2824
2825                    case '4': // 5%
2826                        p_w += p_unit * 5;
2827
2828                        str = $.lang[LANG]['site.clone.process.step4'];
2829                        cnt = '(' + scDestData[scIdx]['total'] + '/' + scOrgData[scIdx]['total'] + ')';
2830                        break;
2831
2832                    case '5': // 30%
2833                        p_w += p_step_unit * p_step_plus;
2834
2835                        str = $.lang[LANG]['site.clone.process.step5'];
2836                        cnt = '(' + scDestData[scIdx]['total'] + '/' + scOrgData[scIdx]['total'] + ')';
2837                        break;
2838
2839                    case '6': // 5%
2840                        p_w += p_unit * 5;
2841
2842                        str = $.lang[LANG]['site.clone.process.step6'];
2843                        cnt = '(' + scDestData[scIdx]['resource']['total'] + '/' + scOrgData[scIdx]['resource']['total'] + ')';
2844
2845                        // step7 init
2846                        p_step_max = p_unit * 20;
2847                        p_step_unit = p_step_max / scOrgData[scIdx]['resource']['total'];
2848                        break;
2849
2850                    case '7': // 20%
2851                        p_w += p_step_unit;
2852
2853                        str = $.lang[LANG]['site.clone.process.step7'];
2854                        cnt = '(' + scDestData[scIdx]['resource']['total'] + '/' + scOrgData[scIdx]['resource']['total'] + ')';
2855                        break;
2856
2857                    case '8': // 5%
2858                        p_w = p_max * (scIdx+1);
2859
2860                        var checkEnd = (scSid.length > 1 && scSid.length > scIdx+1) ? false : true;
2861
2862                        str = $.lang[LANG]['site.clone.process.step8'];
2863                        cnt = (checkEnd) ? '' : '<br>' + $.lang[LANG]['site.clone.process.step8.more'];
2864
2865                        if(checkEnd) {
2866                            setTimeout(function() {
2867                                $.progressOFF();
2868                            }, 500);
2869                        }
2870                        break;
2871
2872                    default:
2873                        break;
2874                }
2875
2876
2877                if(step == 'init' && scIdx == 0) {
2878                    $.progressON(str,'','',true);
2879                } else {
2880                    $('.progressModal .progress-header h1').html(str + cnt);
2881                    $('.progressModal .progress-bar').css('width',p_w+'%');
2882                }
2883
2884                // console.log('p_w: '+ p_w + ', p_unit: ' + p_unit);
2885            },
2886            step0: function() {
2887
2888                var scStep1 = $.sc.step1();
2889                scStep1.done(function() {
2890                    var scStep2 = $.sc.step2();
2891                    scStep2.done(function() {
2892                        $.sc.step3Call(1);
2893                    }).fail(function(scStep2_msg) {
2894                        console.log('scStep2 fail');
2895                        console.log(scStep2_msg);
2896
2897                        $.sc.step8();
2898                        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');
2899                    });
2900                }).fail(function(scStep1_msg){
2901                    console.log(scStep1_msg);
2902
2903                    $.sc.step8();
2904                    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');
2905                });
2906            },
2907            step1: function() { // [clone] pf_site | [get] org pf_site 
2908                var step1_deferred = $.Deferred();
2909
2910                $.post('/template/siteClone', { step:'1', sid:scSid[scIdx], dest_sid:scDest[scIdx], check:scCheck, isAddLangSite:isAddLangSite }, function(r1) {
2911                    if(typeof r1.error != 'undefiend' && r1.error) {
2912                        console.log('step1 error: ' + r1.error);
2913
2914                        var error_msg = (r1.error == 'already_dest') ? '복제가 정상적으로 안되었으니 삭제 후 다시 시도해주세요.' : 'Site Clone Step1 Error';
2915                        step1_deferred.reject(error_msg);
2916                    }
2917
2918                    scOrgData[scIdx]['pfsite'] = r1.org_site;
2919                    if(scIdx == 0 && r1.site_langs !== null) scSid = r1.site_langs;
2920                    $.sc.strProcess('1');
2921
2922                    setTimeout(function() {
2923                        step1_deferred.resolve();
2924                    }, 300);
2925                }, 'json');
2926                
2927                return step1_deferred.promise();
2928            },
2929            step2: function() { // [get] block total
2930                var step2_deferred = $.Deferred();
2931                $.sc.strProcess('2');
2932
2933                $.post('/template/siteClone', { step:'2', sid:scSid[scIdx], check:scCheck }, function(r2) {
2934                    if(typeof r2.error != 'undefiend' && r2.error) {
2935                        console.log('step2 reject');
2936                        step2_deferred.reject(r2.error);
2937                    }
2938
2939                    scOrgData[scIdx]['total'] = r2.data.total;
2940                    scOrgData[scIdx]['normal_total'] = r2.data.normal_total;
2941                    $.sc.strProcess('2-ok');
2942
2943                    setTimeout(function() {
2944                        step2_deferred.resolve();
2945                    }, 300);
2946                }, 'json');
2947                
2948                return step2_deferred.promise();
2949            },
2950            step3Call: function(page) {
2951
2952                var view = 100,
2953                    checkNextStep = (Math.ceil(scOrgData[scIdx]['normal_total']/view) < page) ? true : false;
2954
2955                if(checkNextStep) {
2956                    var scStep4 = $.sc.step4();
2957                    scStep4.done(function(data4) {
2958                        $('.progress-content').append('\
2959                            <div class="clone-section" data-sid="' + scSid[scIdx] + '" data-sid="' + scDest[scIdx] + '">\
2960                                <ul class="clone-block-list"></ul>\
2961                                <ul class="clone-resource-list"></ul>\
2962                            </div>\
2963                        ');
2964                        $.each(data4, function(key,total) {
2965                            // if(key == 'gallery_items') return true;
2966                            if(key == 'total') return true;
2967                            if(total > 0) {
2968                                var view = block_view[key],
2969                                    total_page = (total > view) ? Math.ceil(total/view) : 1,
2970                                    view_start = 1,
2971                                    view_end = (total > view) ? view : total;
2972
2973                                for(var idx=1; idx<=total_page; idx++) {
2974                                    if(idx > 1) {
2975                                        view_start = view_end + 1;
2976                                        view_end = (total > (view*idx)) ? view*idx : total;
2977                                    }
2978
2979                                    var btn_target = (view === 1 || view_end == 1) ? '' : '(' + view_start + '~' + view_end + ')',
2980                                    btn_str = key + ' ' + idx + btn_target,
2981                                    btn_html = '<button type="button" class="btn btn-primary site-clone-step5" data-start="'+view_start+'" data-end="'+view_end+'">'+btn_str+'</button>';
2982                                    $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-block-list').append('<li class="'+ key +'">' + btn_html + '</li>');
2983                                }
2984                            }
2985                        });
2986
2987                        $.sc.step5Call(0);
2988
2989                    }).fail(function(scStep4_msg){
2990                        console.log(scStep4_msg);
2991
2992                        $.sc.step8();
2993                        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');
2994                    });
2995
2996                    return false;
2997                }
2998
2999                var scStep3 = $.sc.step3(page);
3000                scStep3.done(function() {
3001                    $.sc.step3Call(page+1);
3002                }).fail(function(scStep3_msg){
3003                    console.log(scStep3_msg);
3004
3005                    $.sc.step8();
3006                    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');
3007                });
3008
3009            },
3010            step3: function(page) { // [clone] pf_page > normal block
3011                var step3_deferred = $.Deferred();
3012
3013                $.sc.strProcess('3');
3014                $.post('/template/siteClone', { step:'3', sid:scSid[scIdx], dest_sid:scDest[scIdx], check:scCheck, page:page, isAddLangSite:isAddLangSite }, function(r3) {
3015                    if(typeof r3.error != 'undefiend' && r3.error) {
3016                        console.log('step3 reject');
3017                        step3_deferred.reject(r3.error);
3018                    }
3019
3020                    p_step_plus = r3.data.insert_total;
3021                    scDestData[scIdx]['total'] += r3.data.insert_total;
3022                    $.sc.strProcess('3-ok');
3023
3024                    setTimeout(function() {
3025                        step3_deferred.resolve();
3026                    }, 200);
3027                }, 'json');
3028                
3029                return step3_deferred.promise();
3030            },
3031            step4: function() { // [get] (gallery / form / forum) block total
3032                var step4_deferred = $.Deferred();
3033
3034                $.post('/template/siteClone', { step:'4', sid:scSid[scIdx], check:scCheck }, function(r4) {
3035                    if(typeof r4.error != 'undefiend' && r4.error) {
3036                        console.log('step4 reject');
3037                        step4_deferred.reject(r4.error);
3038                    }
3039
3040                    scOrgData[scIdx]['gallery']['total'] = r4.data.gallery;
3041                    scOrgData[scIdx]['forum']['total'] = r4.data.forum;
3042                    scOrgData[scIdx]['form']['total'] = r4.data.form;
3043                    scOrgData[scIdx]['contact']['total'] = r4.data.contact;
3044                    $.sc.strProcess('4');
3045
3046                    setTimeout(function() {
3047                        step4_deferred.resolve(r4.data);
3048                    }, 300);
3049                }, 'json');
3050                
3051                return step4_deferred.promise();
3052            },
3053            step5Call: function(cnt) {
3054                var cloneBlock = $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-block-list li').eq(cnt);
3055                if(cloneBlock.length == 0) {
3056                    $.sc.step6();
3057                    return false;
3058                }
3059
3060                var cloneBlockBtn = cloneBlock.find('button'),
3061                    key = cloneBlock.attr('class'),
3062                    start = cloneBlockBtn.attr('data-start'),
3063                    end = cloneBlockBtn.attr('data-end'),
3064                    more = (typeof cloneBlockBtn.attr('data-more') != 'undefined' && cloneBlockBtn.attr('data-more')) ? cloneBlockBtn.attr('data-more') : '';
3065
3066                var scStep5 = $.sc.step5(key,cnt,start,end,more);
3067                scStep5.done(function(checkMore) {
3068                    if(checkMore) $.sc.step5Call(cnt);
3069                    else $.sc.step5Call(cnt+1);
3070                }).fail(function() {
3071                    console.log('scStep5 fail');
3072                });
3073            },
3074            step5: function(key,cnt,start,end,more) { // [clone] pf_page > (gallery / form / forum) block
3075                var step5_deferred = $.Deferred();
3076
3077                var cloneBlock = $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-block-list li').eq(cnt),
3078                    cloneBlockBtn = cloneBlock.find('button'),
3079                    block_insert_data = scTempData[scIdx][key];
3080
3081                $.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) {
3082
3083                    if(typeof r5.error != 'undefined' && r5.error) {
3084                        console.log('step5 reject');
3085                        console.log('Gallery / form / forum Clone error::' + scSid[scIdx] + ', ' + r5.error);
3086                        $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-block-list li').eq(cnt).append('<span class="error">
3086'+r5.error+'</span>');
3087                        step5_deferred.reject();
3088
3089                    } else $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-block-list .error').remove();
3090
3091                    scDestData[scIdx]['total'] = scDestData[scIdx]['total'] + r5.data.total;
3092                    scTempData[scIdx][key] = Object.assign(block_insert_data, r5.data.insert_data);
3093
3094                    var check_more = false;
3095                    if(typeof r5.data.more != 'undefiend' && r5.data.more) {
3096                        check_more = true;
3097                        
3098                        var more_str = r5.data.more,
3099                            more_arr = more_str.split(','),
3100                            more_btn_str = more_arr[2]+'/'+more_arr[3];
3101                        cloneBlockBtn.attr('data-more',r5.data.more);
3102                        if(cloneBlockBtn.find('.next').length > 0) cloneBlockBtn.find('.next').text(more_btn_str);
3103                        else cloneBlockBtn.append('<span class="next">('+more_btn_str+')</span>');
3104                    } else {
3105                        p_step_plus = r5.data.total;
3106                        $.sc.strProcess('5');
3107                        cloneBlockBtn.attr('disabled',true);
3108                    }
3109
3110                    setTimeout(function() {
3111                        step5_deferred.resolve(check_more);
3112                    }, 200);
3113                }, 'json');
3114
3115
3116                return step5_deferred.promise();
3117            },
3118            step6: function() { // [get] pf_resource seq & total
3119                console.log(scSid[scIdx]);
3120
3121                $.post('/template/siteClone', { step:'6', sid:scSid[scIdx], dest_sid:scDest[scIdx] }, function(r6) {
3122
3123                    var cloneSection = $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-resource-list');
3124                    if(typeof r6.error != 'undefined' && r6.error) {
3125                        console.log('step6 reject');
3126                        console.log('Resorce Clone error::' + scSid[scIdx] + ', ' + r6.error);
3127                        cloneSection.before('<span class="error">'+r6.error+'</span>');
3128                        return false;
3129                    } else $('.error').remove();
3130
3131                    var r_view = 30,
3132                        r_total = r6.count,
3133                        r_add = 0;
3134                    
3135                    scOrgData[scIdx]['resource'] = {
3136                        'total' : r_total,
3137                        'list' : r6.list
3138                    };
3139                    scDestData[scIdx]['resource'] = {
3140                        'total' : 0,
3141                        'list' : new Array()
3142                    };
3143                    $.sc.strProcess('6');
3144
3145                    if(r_total == 0) {
3146                        $.sc.step8();
3147                        return false;
3148                    }
3149
3150                    $.each(r6.list, function(rs_i,rs_v) {
3151                        r_add++;
3152                        var mod = r_add%r_view;
3153                        if(mod === 1) cloneSection.append('<li></li>');
3154                        cloneSection.find('li:last-child').append('<span>' + rs_v.seq + '</span>');
3155
3156                        if(r_add == r_total) {
3157                            $.sc.step7Call(0,0);
3158                        }
3159                    });
3160                }, 'json');
3161            },
3162            step7Call: function(rs_eq1,rs_eq2) {
3163                var cloneResource = $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-resource-list');
3164                    rs_li_total = cloneResource.find('li').length;
3165                if(rs_eq1 >= rs_li_total) {
3166                    $.sc.step8();
3167                    return false;
3168                }
3169
3170                var cloneResourceli = cloneResource.find('li').eq(rs_eq1),
3171                    rs_span_total = cloneResourceli.find('span').length;
3172                if(rs_eq2 >= rs_span_total) {
3173                    $.sc.step7Call(rs_eq1+1,0);
3174                    return false;
3175                }
3176
3177                var cloneResourceSpan = cloneResourceli.find('span').eq(rs_eq2),
3178                    rs_seq = cloneResourceSpan.text();
3179                if(rs_seq == '') {
3180                    $.sc.step8();
3181                    return false;
3182                }
3183
3184                var scStep7 = $.sc.step7(rs_seq);
3185                scStep7.done(function() {
3186                    if(rs_eq2+1 < rs_span_total) $.sc.step7Call(rs_eq1,rs_eq2+1);
3187                    else $.sc.step7Call(rs_eq1+1,0);
3188                }).fail(function() {
3189                    console.log('scStep7 fail');
3190                });
3191            },
3192            step7: function(rs_seq) { // [clone] pf_resource
3193                var step7_deferred = $.Deferred();
3194
3195                $.post('/template/siteClone', { step:'7', sid:scSid[scIdx], dest_sid:scDest[scIdx], r_seq:rs_seq }, function(r7) {
3196
3197                    if(typeof r7.error != 'undefined' && r7.error) {
3198                        console.log('step7 reject');
3199                        console.log('Resorce Clone error::' + rs_seq + ', ' + r7.error);
3200                        $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-resource-list li span[data-seq="' + rs_seq + '"]').addClass('error');
3201                        step7_deferred.reject();
3202
3203                    } else $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-resource-list li .error').remove();
3204
3205                    scDestData[scIdx]['resource']['total'] = scDestData[scIdx]['resource']['total'] + 1;
3206                    scDestData[scIdx]['resource']['list'].push(rs_seq);
3207                    $.sc.strProcess('7');
3208
3209                    setTimeout(function() {
3210                        step7_deferred.resolve();
3211                    }, 100);
3212                }, 'json');
3213
3214                return step7_deferred.promise();
3215            },
3216            step8: function() { // check other site(language site)
3217                $.sc.strProcess('8');
3218
3219                if(isAddLangSite || scIdx+1 == scSid.length) {
3220                    location.reload();
3221                } else {
3222                    $.sc.initVal();
3223                    setTimeout(function() {
3224                        $.sc.step0();
3225                    }, 500);
3226                }
3227            }
3228        }
3229
3230
3231        $.sc.initVal();
3232        if(isAddLangSite) {
3233            $.sc.strProcess('init');
3234            setTimeout(function() {
3235                $.sc.step0();
3236            }, 600);
3237        } else {
3238            var scCheckModal = $(this).showModalFlat($.lang[LANG]['site.clone.check.title'], $.sc.strCheck(), true, true, function() {
3239                $.sc.strProcess('init');
3240
3241                scCheck.popup = $('.check-popup').prop('checked');
3242                scCheck.music = $('.check-music').prop('checked');
3243                scCheck.gallery = $('.check-gallery').prop('checked');
3244                scCheck.forum = $('.check-forum').prop('checked');
3245                
3246                setTimeout(function() {
3247                    $.sc.step0();
3248                    scCheckModal.modal('hide');
3249                }, 600);
3250            },'cancel','','cl-siteclone cl-cmmodal cl-s-btn w560 cl-p70 cl-p0','','',function() { $('[data-toggle="popover"]').popover(); });
3251        }
3252    }
3253
3254    $.fn.sitePublishVer01 = function(sid,onoff,endCallback) {
3255
3256        var strTitle = (onoff==1) ? $.lang[LANG]['loading.publishing'] : $.lang[LANG]['loading.publishing.off'];
3257        $.progressON(strTitle,'',0,true);
3258        
3259        var pbSiteCall = function(slist,sidx) {
3260            if(typeof slist == 'undefined' || typeof slist[sidx] == 'undefined') {
3261                pbEndCall(false);
3262                return false;
3263            }
3264
3265            var s_obj = slist[sidx],
3266                s_orgsid = s_obj['sid'],
3267                s_code = (typeof s_obj['code'] != 'undefined' && s_obj['code']) ? s_obj['code'] : '',
3268                s_sid = (s_code) ? s_orgsid+'__'+s_code : s_orgsid;
3269
3270            $.progressON('', s_orgsid + ((s_code) ? $.lang[LANG]['editor.publish.step2.1'] + ' (' + s_code + ')' : '') + $.lang[LANG]['editor.publish.step2.2'],0,true);
3271            var pbSite_r = pbSite(s_sid,onoff);
3272            pbSite_r.done(function(r2) {
3273                $.progressON('', s_orgsid + ((s_code) ? $.lang[LANG]['editor.publish.step3.1'] + ' (' + s_code + ')' : '') + $.lang[LANG]['editor.publish.step3.2'],0,true);
3274                var w = getProgressWidth() + (20/slist.length) * (sidx+1);
3275                $('.progress-bar').css('width',w+'%');
3276
3277                pbGalleryCall(slist,sidx,s_orgsid,s_code,r2.count,0);
3278            }).fail(function(r2_error) {
3279                console.log(r2_error);
3280                pbEndCall(false);
3281            });
3282        }
3283
3284        var pbGalleryCall = function(sitelist,siteidx,sidorg,sidcode,gcount,gpidx) {
3285            var sitesid = (sidcode) ? sidorg+'__'+sidcode : sidorg;
3286
3287            var pbGallery_r = pbGallery(sitesid,onoff,gcount,gpidx,sitelist.length,siteidx);
3288            pbGallery_r.done(function(r3) {
3289                $.progressON('',sidorg + ((sidcode) ? $.lang[LANG]['editor.publish.step4.1'] + ' (' + sidcode + ')' : '') + $.lang[LANG]['editor.publish.step4.2'],0,true);
3290                $('.progress-bar').css('width',r3.w+'%');
3291
3292                if(r3.done == true) pbPagesCall(sitelist,siteidx,sidorg,sidcode,r3.count,0);
3293                else pbGalleryCall(sitelist,siteidx,sidorg,sidcode,gcount,gpidx+1);
3294
3295            }).fail(function(r3_error) {
3296                console.log(r3_error);
3297                pbEndCall(false);
3298            });
3299        }
3300
3301        var pbPagesCall = function(sitelist,siteidx,sidorg,sidcode,bcount,bpidx) {
3302            var sitesid = (sidcode) ? sidorg+'__'+sidcode : sidorg;
3303
3304            var pbPages_r = pbPages(sitesid,onoff,bcount,bpidx,sitelist.length,siteidx);
3305            pbPages_r.done(function(r4) {
3306                $('.progress-bar').css('width',r4.w+'%');
3307
3308                if(r4.done == true) {
3309                    if(sitelist.length == (siteidx+1)) pbEndCall(true);
3310                    else pbSiteCall(sitelist,siteidx+1);
3311                } else {
3312                    pbPagesCall(sitelist,siteidx,sidorg,sidcode,bcount,bpidx+1);
3313                }
3314
3315            }).fail(function(r4_error) {
3316                console.log(r4_error);
3317                pbEndCall(false);
3318            });
3319        }
3320
3321        var pbEndCall = function(isCompleted) {
3322            $('.progress-bar').css('width','100%');
3323        
3324            if(!isCompleted) {
3325                $.progressOFF();
3326                return false;
3327            }
3328
3329            if(typeof endCallback == 'function') {
3330                endCallback(sid,onoff);
3331            }
3332        }
3333
3334        var sites_r = sites(sid);
3335        sites_r.done(function(r1) {
3336            $.progressON('',$.lang[LANG]['editor.publish.step1'],0,true);
3337            pbSiteCall(r1.lists,0);
3338        }).fail(function(r1_error) {
3339            console.log(r1_error);
3340            pbEndCall(false);
3341        });
3342    }
3343
3344    $.fn.sitePublishByConfig = function(sid) {
3345        var $publishTarget = $(this);
3346        var isConfigPbs = (typeof CONFIG_PBS != 'undefined' && CONFIG_PBS) ? true : false;
3347        var publishDomain = (typeof PUBDOMAIN != 'undefined' && PUBDOMAIN) ? PUBDOMAIN : ((typeof DOMAIN != 'undefined' && DOMAIN) ? DOMAIN : $('#pubhost a').attr('href'));
3348
3349        if (isConfigPbs) {
3350            $publishTarget.sitePublishVer02(sid);
3351        } else {
3352            $publishTarget.sitePublishVer01(sid, 1, function() {
3353                setTimeout(function() {
3354                    if (typeof SLANG != 'undefined' && typeof SLANG.select_code != 'undefined' && SLANG.select_code) {
3355                        changeLanguage(SLANG.select_code, 'sync_publish');
3356                    }
3357
3358                    $.progressOFF();
3359                    $.processON();
3360                    $('.processModal p').text('');
3361                    $('.processModal p').css({
3362                        'width': '385px',
3363                        'height': '215px',
3364                        'top': '0',
3365                        'margin': 'auto',
3366                        'background': 'none',
3367                    });
3368
3369                    if ($('.processModal').length == 1) {
3370                        if (typeof CONFIG_PBS != 'undefined') CONFIG_PBS = true;
3371
3372                        $.processOFF();
3373                        var modal = $publishTarget.showModalFlat($.lang[LANG]['editor.publish.priview.title'], $.lang[LANG]['editor.publish.priview'], true, false, function() {
3374                            if (publishDomain) window.open(publishDomain, '_blank');
3375                            modal.modal('hide');
3376                        }, 'ok', '', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70 cl-publish-complete', '', '', function() {
3377                            $('.cl-publish-complete .ok-button-dialog, .cl-publish-complete .close').on('click', function() {
3378                                $.processOFF();
3379                            });
3380                        });
3381                    }
3382                }, 1000);
3383            });
3384        }
3385    }
3386
3387    $.fn.sitePublishVer02 = function(sid) {
3388
3389        $.progressON($.lang[LANG]['editor.publish.step.start'],'',0,true);
3390
3391        $.sp = {
3392            step: 0,
3393
3394            site_list: {},
3395            site_total: 0,
3396            site_idx: 0,
3397            site_per: 100,
3398
3399            sid: sid,
3400            sid_code: '',
3401            org_sid: sid,
3402
3403            step_k: {'d':3, 'i':2, 'u':1},
3404            step_total: [0,0,0,0],
3405            step_success: [0,0,0,0],
3406
3407            change_total: 0,
3408            change_success: 0,
3409            change_list: {},
3410
3411            per: 0,
3412            error_msg: $.lang[LANG]['editor.publish.step.error'],
3413            end: function(isError) {
3414                if(typeof isError == 'undefined') isError = false;
3415
3416                if(isError) {
3417                    $.progressOFF();
3418                    $(this).showModalFlat('ERROR',$.sp.error_msg, true, false, '', 'ok', '', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
3419                } else {
3420
3421                    var isNext = (typeof $.sp.site_list[$.sp.site_idx+1] != 'undefined' && $.sp.site_idx+1 <= $.sp.site_total) ? true : false;
3422                    if(isNext) {
3423                        setTimeout(function() {
3424                            $.progressON('',$.lang[LANG]['editor.publish.step.restart']);
3425                            $('.progress-bar').css('width','0%');
3426                            $.sp.site_idx++;
3427                            setTimeout(function() {
3428                                $.sp.step1();
3429                            },1500);
3430                        },1500);
3431                    } else {
3432
3433                        $('.progress-bar').css('width','70%');
3434                        setTimeout(function() {
3435                            $('.progress-bar').css('width','100%');
3436
3437                            if(typeof SLANG != 'undefined' && typeof SLANG.select_code != 'undefined' && SLANG.select_code) {
3438                                changeLanguage(SLANG.select_code,'sync_publish');
3439                            }
3440
3441                            $.progressOFF();
3442                            $.processON();
3443
3444                            var time = $.now();
3445                            $('.processModal p').text('');
3446                            $('.processModal p').css({
3447                                'width' : '385px',
3448                                'height' : '215px',
3449                                'top' : '0',
3450                                'margin' : 'auto',
3451                                'background' : 'none',
3452                            });
3453
3454                            if($('.processModal').length ==1) {
3455                                $.processOFF();
3456                                var modal = $(this).showModalFlat($.lang[LANG]['editor.publish.priview.title'],$.lang[LANG]['editor.publish.priview'],  true, false ,function(){
3457                                        window.open(DOMAIN, '_blank');
3458                                        modal.modal('hide');
3459                                    },'ok', '', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70 cl-publish-complete','','',function(){
3460                                        $('.cl-publish-complete .ok-button-dialog, .cl-publish-complete .close').on('click',function(){
3461                                        $.processOFF();
3462                                    });
3463                                }); 
3464                            }
3465                        }, 500);
3466
3467                    }
3468
3469                }
3470
3471            },
3472            step0: function(sid) {
3473                $.sp.step = 0;
3474
3475                var sp0_deferred = $.Deferred();
3476                if(typeof sid == 'undefined') sp0_deferred.reject('sid Undefined :(');
3477                else {
3478                    $.ajax({
3479                        url : '/template/publishSites',
3480                        data : { sid : sid },
3481                        type : 'POST',
3482                        dataType : 'json',
3483                        async : true,
3484                        cashe : false,
3485                        success : function(data) {
3486                            if(typeof data.error != 'undefined' && data.error) {
3487                                sp0_deferred.reject(data.error);
3488                                return false;
3489                            }
3490
3491                            $.sp.site_list = data.lists;
3492                            $.sp.site_total = data.lists.length;
3493                            $.sp.site_idx = 0;
3494                            $.sp.site_per = Math.ceil(100 / $.sp.site_total);
3495
3496                            $.progressON('',$.lang[LANG]['editor.publish.step.0'],0,true);
3497                            $('.progress-bar').css('width','5%');
3498
3499                            sp0_deferred.resolve();
3500                        }
3501                    });
3502                }
3503                return sp0_deferred.promise();
3504            },
3505            step1: function() {
3506                $.sp.step = 1;
3507
3508                $.sp.org_sid = $.sp.site_list[$.sp.site_idx]['sid'];
3509                $.sp.sid_code = $.sp.site_list[$.sp.site_idx]['code'];
3510                $.sp.sid = ($.sp.sid_code) ? $.sp.org_sid+'__'+$.sp.sid_code : $.sp.org_sid;
3511
3512                if($.sp.site_idx > 0) {
3513                    $.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);
3514                    $('.progress-bar').css('width','5%');
3515                }
3516                var sp1_1 = $.sp.step1_1();
3517                sp1_1.done(function(r1_1) {
3518                    if(r1_1 > 0) $.sp.step2('d',0);
3519                    else $.sp.end();
3520                }).fail(function(r1_1_error) {
3521                    console.log('r1_1_error: '+r1_1_error);
3522                    $.sp.end(true);
3523                });
3524            },
3525            step1_1: function() {
3526                // sites[idx] - pf_site → pb_site (UPDATE or INSERT)
3527                // sites[idx] - pf_site.activate, pb_site.activate = 1 or 9 (UPDATE)
3528                // return pf_publish total list
3529                var sp1_1_deferred = $.Deferred();
3530                $.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);
3531
3532                $.ajax({
3533                    url : '/template/sitepublish1',
3534                    data : { sid : $.sp.sid, onoff : 1 },
3535                    type : 'POST',
3536                    dataType : 'json',
3537                    async : true,
3538                    cashe : false,
3539                    success : function(data1) {
3540                        $('.progress-bar').css('width','20%');
3541
3542                        $.sp.step_total = [0,0,0,0];
3543                        $.sp.step_success = [0,0,0,0];
3544
3545                        $.sp.change_total = data1.total;
3546                        $.sp.change_success = 0;
3547                        $.sp.change_list = {};
3548                        $.sp.per = Math.ceil(70 / data1.total);
3549
3550                        sp1_1_deferred.resolve(data1.total);
3551                    }
3552                });
3553
3554                return sp1_1_deferred.promise();
3555            },
3556            step2: function(step,start) {
3557                // d->i->u
3558
3559                var sp2_1 = $.sp.step2_1(step,start);
3560                sp2_1.done(function(r2_1) {
3561                    if(r2_1 > 0) $.sp.step2(step,r2_1);
3562                    else {
3563                        if(step == 'd') $.sp.step2('i',0);
3564                        else if(step == 'i') $.sp.step2('u',0);
3565                        else if(step == 'u') $.sp.step3();
3566                        else $.sp.end();
3567                    }
3568                }).fail(function(r2_1_error) {
3569                    console.log('r2_1_error: '+r2_1_error);
3570                    $.sp.end(true);
3571                });
3572            },
3573            step2_1: function(this_step,this_start) {
3574                // sites[idx] - pf_publish.pbs_val == pb_page.seq (DELETE | INSERT | UPDATE)
3575                // sites[idx] - pf_publish.pbs_val == pb_gallery.seq (DELETE | INSERT | UPDATE)
3576                // return pb_page.seq, pb_gallery.seq list + (200개씩 처리) more?
3577                        // $list = array('b'=>array(), 'g'=>array(), 'next_start'=>$start+$limit);
3578                        // json_result(array('result' => 'done pf_publish delete', 'list' => $list, 'total' => $total));
3579                var sp2_1_deferred = $.Deferred();
3580                $.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);
3581
3582                $.ajax({
3583                    url : '/template/sitepublish2/'+this_step,
3584                    data : { sid : $.sp.sid, start: this_start },
3585                    type : 'POST',
3586                    dataType : 'json',
3587                    async : true,
3588                    cashe : false,
3589                    success : function(data2) {
3590                        var this_step_k = $.sp.step_k[this_step];
3591                        if(this_start > 0) {
3592                            $.sp.change_list[this_step].b = $.sp.change_list[this_step].b.concat(data2.list.b);
3593                            $.sp.change_list[this_step].g = $.sp.change_list[this_step].g.concat(data2.list.g);
3594                        } else {
3595                            $.sp.step_total[this_step_k] = data2.total;
3596                            $.sp.change_list[this_step] = data2.list;
3597                        }
3598
3599                        var this_success = data2.list.b.length + data2.list.g.length;
3600                        $.sp.step_success[this_step_k] = $.sp.step_success[this_step_k] + this_success;
3601                        $.sp.change_success = $.sp.change_success + this_success;
3602
3603                        var next_start = ($.sp.step_success[this_step_k] < data2.total) ? data2.list.next_start : 0,
3604                            bar_w = 20 + ($.sp.per * $.sp.change_success);
3605                        $('.progress-bar').css('width',bar_w+'%');
3606
3607                        sp2_1_deferred.resolve(next_start);
3608                    }
3609                });
3610                return sp2_1_deferred.promise();
3611            },
3612            step3: function() {
3613                $('.progress-bar').css('width','95%');
3614
3615                var sp3_1 = $.sp.step3_1();
3616                sp3_1.done(function() {
3617                    $.sp.end();
3618                }).fail(function(r3_1_error) {
3619                    console.log('r3_1_error: '+r3_1_error);
3620                    $.sp.end(true);
3621                });
3622            },
3623            step3_1: function() {
3624                // sites[idx] - pf_publish.sid == SID (DELETE)
3625                var sp3_1_deferred = $.Deferred();
3626                $.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);
3627
3628                $.ajax({
3629                    url : '/template/sitepublish3/',
3630                    data : { sid : $.sp.sid },
3631                    type : 'POST',
3632                    dataType : 'json',
3633                    async : true,
3634                    cashe : false,
3635                    success : function(data3) {
3636                        $('.progress-bar').css('width','100%');
3637                        sp3_1_deferred.resolve();
3638                    }
3639                });
3640                return sp3_1_deferred.promise();
3641
3642            }
3643        }
3644
3645        var sp0 = $.sp.step0(sid);
3646        sp0.done(function() {
3647            $.sp.step1();
3648        }).fail(function(r0_error) {
3649            console.log('r0_error: '+r0_error);
3650            $.sp.end();
3651        });
3652    }
3653
3654    $.fn.publishGallery = function(sid) {
3655        $.progressON($.lang[LANG]['editor.publish.step.start'],'',0,true);
3656        $.sp =  {
3657            domain: (typeof MODE != 'undefined' && MODE == 'config')? DOMAIN : $('#pubhost a').attr('href'),
3658            step1: function() {
3659                var deferred = $.Deferred();
3660
3661                $.ajax({
3662                    url : '/template/publishGallery/step1',
3663                    data : { sid : sid },
3664                    type : 'POST',
3665                    dataType : 'json',
3666                    async : true,
3667                    cashe : false,
3668                    success : function(data1) {
3669                        console.log('data', data1);
3670                        $('.progress-bar').css('width','25%');
3671                        deferred.resolve(data1);
3672                    }
3673                });
3674
3675                return deferred.promise();
3676            },
3677            step2: function() {
3678                var deferred = $.Deferred();
3679
3680                $.ajax({
3681                    url : '/template/publishGallery/step2',
3682                    data : { sid : sid },
3683                    type : 'POST',
3684                    dataType : 'json',
3685                    async : true,
3686                    cashe : false,
3687                    success : function(data2) {
3688                        console.log('data', data2);
3689                        $('.progress-bar').css('width','50%');
3690
3691                        deferred.resolve(data2);
3692                    }
3693                });
3694
3695                return deferred.promise();
3696            },
3697            clear: function() {
3698                var deferred = $.Deferred();
3699
3700                $.ajax({
3701                    url : '/template/publishGallery/clear',
3702                    data : { sid : sid },
3703                    type : 'POST',
3704                    dataType : 'json',
3705                    async : true,
3706                    cashe : false,
3707                    success : function(data3) {
3708                        console.log('data', data3);
3709                        $('.progress-bar').css('width','75%');
3710                        deferred.resolve(data3);
3711                    }
3712                });
3713
3714                return deferred.promise();
3715            },
3716            end: function(isError) {
3717                if(typeof isError == 'undefined') isError = false;
3718                if(isError) {
3719                    $.progressOFF();
3720                    $(this).showModalFlat('ERROR','error', true, false, '', 'ok', '', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
3721                } else {
3722                    $('.progress-bar').css('width','100%');
3723                    setTimeout(function() {
3724                        $.progressOFF();
3725                        $.processON();
3726                        if($('.processModal').length ==1) {
3727                            $.processOFF();
3728                            var modal = $(this).showModalFlat($.lang[LANG]['editor.publish.priview.title'],$.lang[LANG]['editor.publish.priview'],  true, false ,function(){
3729                                    window.open($.sp.domain, '_blank');
3730                                    modal.modal('hide');
3731                                },'ok', '', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70 cl-publish-complete','','',function(){
3732                                    $('.cl-publish-complete .ok-button-dialog, .cl-publish-complete .close').on('click',function(){
3733                                    $.processOFF();
3734                                });
3735                            }); 
3736                        }
3737                    }, 500);
3738                }
3739            }
3740        }
3741
3742        $.sp.step1().then(function (res1) {
3743            return $.sp.step2(res1);
3744        })
3745        .then(function (res2) {
3746            return $.sp.clear(res2);
3747        })
3748        .done(function () {
3749            return $.sp.end();
3750        })
3751        .fail(function (err) {
3752            return $.sp.end(err);
3753        });
3754    }
3755
3756    $.musicON = function(play) {
3757        play = (typeof play == 'undefined') ? true : play;
3758        var tpl = '\
3759            <div id="cl-music-player" class="cl-mplayer"></div>\
3760            <div id="cl-music-container" class="jp-audio" role="application" aria-label="media player">\
3761                <div class="jp-type-playlist">\
3762                    <div class="jp-gui jp-interface">\
3763                        <div class="jp-controls-holder">\
3764                            <div class="jp-controls">\
3765                                <div class="music-player-controls">\
3766                                    <span class="jp-backward" role="button" tabindex="0"><i class="fa fa-backward" aria-hidden="true"></i></span>\
3767                                    <span class="jp-play" role="button" tabindex="0"><i class="fa fa-pause" aria-hidden="true"></i></span>\
3768                                    <span class="jp-forward" role="button" tabindex="0"><i class="fa fa-forward" aria-hidden="true"></i></span>\
3769                                </div>\
3770                                <div class="music-player-progress">\
3771                                    <div class="jp-progress">\
3772                                        <div class="jp-seek-bar">\
3773                                            <div class="jp-play-bar"></div>\
3774                                        </div>\
3775                                    </div>\
3776                                </div>\
3777                                <div class="jp-lists">\
3778                                    <span class="music-lists" role="button" tabindex="0">LIST</span>\
3779                                </div>\
3780                                <div class="music-playlist-wrap">\
3781                                    <div class="jp-playlist"><ul class="music-playlist"><li></li></li></div>\
3782                                </div>\
3783                            </div>\
3784                        </div>\
3785                    </div>\
3786                    <div class="jp-no-solution">\
3787                        <span>Update Required</span>\
3788                        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>.\
3789                    </div>\
3790                </div>\
3791            </div>\
3792            ',
3793            equalizer_img = ($('body').width() < 769) ? 'https://storage.googleapis.com/i.addblock.net/equal_stop.gif' : 'https://storage.googleapis.com/i.addblock.net/equal.gif',
3794            checkFree = (!property.VALIDPLAN || property.VALIDTYPE == 'PK') ? true : false,
3795            move_position = (checkFree) ? 'class="moved"' : '',
3796            vpModeOnoff = (property.SETTINGS.vpMode_onoff === true) ? true : false,
3797            vpOption = (property.SETTINGS.viewportMode) ? property.SETTINGS.viewportMode : '',
3798            WebType = $.mpcWeb.mpcCheckWebType(),
3799            checkFnav = ($('.fnav').length > 0 && vpOption=='mobile_web') ? true : false,
3800            $music_icon = $('<div id="cl-music-player-icon" '+move_position+'><img src="' + equalizer_img + '" class="hand"></div>');
3801
3802        $('#goto-top').after($music_icon);
3803        $('#cl-music-player-icon').after(tpl);
3804        if($('.fnav').length > 0) {
3805            if(window.innerWidth <= 480) {
3806                $('#goto-top').addClass('movedOne');
3807                $music_icon.addClass('movedOne');
3808            }
3809        } else if($(`.quickmenu.non_config`).length > 0) {
3810            quickMenuMusicPosition(property);
3811        }
3812
3813        if(vpModeOnoff && WebType == 'MOBILE') $.mpcWeb.mpcMusicandGoTop(checkFnav,vpOption);
3814
3815        ($('body').width() < 769) ? $('.jp-play i').removeClass('fa-pause').addClass('fa-play').parent().addClass('pause') : '';
3816        var music = (typeof property == 'undefined') ? [] : property.MUSIC;
3817
3818        if(music.length==0) {
3819            $music_icon.addClass('hide');
3820            $music_icon.removeClass('movedOne');
3821            $('#goto-top').removeClass('movedOne');
3822        }
3823        var myPlaylist = new jPlayerPlaylist({
3824            jPlayer: '#cl-music-player',
3825                cssSelectorAncestor: '#cl-music-container'
3826            }, music, {
3827            playlistOptions: {
3828                loop: true,
3829                autoPlay: play,
3830                loopOnPrevious: true,
3831                enableRemoveControls: false
3832            },
3833            ready: function() {
3834                if (!window._musicUserInteracted) {
3835                    $(this).jPlayer('option', 'muted', true);
3836                    $(document).one('click scroll touchstart keydown', function() {
3837                        $('#cl-music-player').jPlayer('option', 'muted', false);
3838                    });
3839                }
3840            },
3841            ended: function() { 
3842                // var $item = $('.music-playlist li'),
3843                //     idx = $item.parent().find('.active').index(),
3844                //     active = (idx+1 > $item.length) ? 0 : idx+1;
3845
3846                // $item.removeClass('active');
3847                // $item.eq(active).addClass('active');
3848            },            
3849            swfPath: '/js',
3850            solution: 'html, flash',
3851            supplied: 'mp3',
3852            preload: 'metadata',
3853            volume: 1,
3854            loop: true,
3855            muted: false,
3856            backgroundColor: '#000000',
3857
3858            smoothPlayBar: true,
3859            keyEnabled: false,
3860            audioFullScreen: false // Allows the audio poster to go full screen via keyboard
3861        });
3862
3863        $music_icon.click(function() {
3864            $(this).toggleClass('show');
3865            if($(this).hasClass('show')) {
3866                $('#cl-music-container').css('display','block');
3867            } else {
3868                $('#cl-music-container').css('display','none');
3869            }
3870        });
3871
3872        var $play = $('.jp-play'),
3873            $next = $('.jp-forward'),
3874            $prev = $('.jp-backward'),
3875            $list = $('.music-lists'),
3876            $playlist_wrap = $('.music-playlist-wrap'),
3877            $playlist = $('.music-playlist'),
3878            $item = $('.music-playlist li');
3879
3880        $playlist.empty();
3881        if(myPlaylist.playlist.length) {
3882            var index = myPlaylist.current;
3883            $.each(myPlaylist.playlist, function(i,v) {
3884                var active = (i == index) ? 'jp-playlist-current' : '',
3885                    item = '<li class="' + active + '" data-music-index="' + i + '"><span class="hand">' + v.title + '</span></li>';
3886                $playlist.append(item);
3887            });
3888        }
3889
3890        $list.click(function() {
3891            $playlist_wrap.toggle();
3892            if($playlist_wrap.css('display') == 'block') {
3893                $list.text('CLOSE');
3894            } else {
3895                $list.text('LIST');
3896            }
3897        });
3898
3899        $('body').on( 'click', '.music-playlist li a', function(e) {
3900            var $pause_icon = '<i class="fa fa-pause"></i>';
3901                $equalizer = $("#cl-music-player-icon"),
3902                src = 'https://storage.googleapis.com/i.addblock.net/equalizer.gif',
3903            $equalizer.find('img').attr('src',src);
3904            $('.jp-play').removeClass('pause');
3905            $('.jp-play').html($pause_icon);
3906        });
3907
3908        $('.music-playlist li span').click(function() {
3909            var idx = $(this).parent().attr('data-music-index');
3910            if(typeof idx == 'undefined') return;
3911            myPlaylist.play(idx);
3912            myPlaylist.current = idx;
3913            $('.music-playlist li').removeClass('jp-playlist-current');
3914            $('.music-playlist li').eq(idx).addClass('jp-playlist-current');
3915            // $.musicPlay();
3916        });
3917
3918        $play.click(function() {
3919            if($(this).hasClass('pause')) {
3920                $.musicPlay();
3921            } else {
3922                $.musicPause();
3923            }
3924        });
3925        $next.click(function() {
3926            $.musicNext(myPlaylist);
3927
3928        });
3929        $prev.click(function() {
3930            $.musicPrev(myPlaylist);
3931        })
3932
3933        document.onkeydown = function(evt) {
3934            evt = evt || window.event;
3935            if (evt.keyCode == 27) {
3936                $.musicPause();
3937            }
3938        };
3939        // myPlaylist.play();
3940        // $('#cl-music-player').jPlayer('play');
3941    }
3942    $.musicPause = function() {
3943        var $play_icon = '<i class="fa fa-play"></i>',
3944            $equalizer = $('#cl-music-player-icon'),
3945            src = 'https://storage.googleapis.com/i.addblock.net/equal_stop.gif';
3946        $equalizer.find('img').attr('src',src);
3947        $('.jp-play').addClass('pause');
3948        $('.jp-play').html($play_icon);
3949        $('#cl-music-player').jPlayer('pause');
3950    }
3951    $.musicPlay = function() {
3952        var $pause_icon = "<i class='fa fa-pause'></i>";
3953            $equalizer = $('#cl-music-player-icon'),
3954            src = 'https://storage.googleapis.com/i.addblock.net/equalizer.gif',
3955        $equalizer.find('img').attr('src',src);
3956        $('.jp-play').removeClass('pause');
3957        $('.jp-play').html($pause_icon);
3958        $('#cl-music-player').jPlayer('play');
3959    }
3960    $.musicStop = function() {
3961        $('#cl-music-player').jPlayer('stop');
3962    }
3963    $.musicRepeat = function() {
3964    }
3965    $.musicOFF = function() {
3966    }
3967    $.musicNext = function(player) {
3968        player.next();
3969        var index = player.current;
3970        $.musicPlay();
3971    }
3972    $.musicPrev = function(player) {
3973        player.previous();
3974        var index = player.current;
3975        $.musicPlay();
3976    }
3977
3978
3979    $.fnav = {
3980        getFnav: function() {
3981            var data = (PAGE_MODE == 'c') ? SETTINGS.fnav : property.SETTINGS.fnav;
3982            if(typeof data == 'undefined' || $.isEmptyObject(data)) data = new Array();
3983            
3984            return data;
3985        },
3986        getFnavColor: function(target) {
3987            var color = '';
3988            if(target == 'font') {
3989                color = (PAGE_MODE == 'c') ? SETTINGS.fnavFcolor : property.SETTINGS.fnavFcolor;
3990            } else if(target == 'bg') {
3991                color = (PAGE_MODE == 'c') ? SETTINGS.fnavBg : property.SETTINGS.fnavBg;
3992                var hexRegex = /^([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
3993                if(hexRegex.test(color)) color = '#'+color;
3994            }
3995
3996            if(typeof color == 'undefined' || !color) return (target == 'font') ? '#ffffff' : '#000000';
3997            else return color;
3998        },
3999        checkFnavON: function(data) {
4000            var result = false,
4001                fnav_data = (typeof data != 'undefined') ? data : $.fnav.getFnav();
4002
4003            $.each(fnav_data, function(i,obj) {
4004                if(obj['display'] == 'on') result = true;
4005            });
4006
4007            return result;
4008        },
4009        draw: function(data) {
4010            var fnav_data = (typeof data != 'undefined') ? data : $.fnav.getFnav(),
4011                hasON = $.fnav.checkFnavON(fnav_data);
4012
4013            if (window.location.href.indexOf('_checkout') != -1) hasON = false;
4014
4015            if(!hasON) {
4016                $('.fnav.fnav-mobile-fnav').remove();
4017            } else {
4018                var fnav_html = $.fnav.listHTML(fnav_data,hasON);
4019                if(fnav_html.length > 0) {
4020                    if($('.dsgn-body').find('.fnav.fnav-mobile-fnav').length > 0) $('.dsgn-body .fnav.fnav-mobile-fnav').replaceWith(fnav_html);
4021                    else $('.dsgn-body').find('.el-footer').before(fnav_html);
4022                } else {
4023                    $('.dsgn-body').find('.fnav.fnav-mobile-fnav').remove();
4024                }
4025            }
4026        },
4027        listHTML: function(fnav_data,hasON) {
4028            if(typeof fnav_data == 'undefined') fnav_data = $.fnav.getFnav();
4029            if(typeof hasON == 'undefined') hasON = $.fnav.checkFnavON(fnav_data);
4030
4031            var fnav_fcolor = $.fnav.getFnavColor('font'),
4032                fnav_bg = $.fnav.getFnavColor('bg'),
4033                str = '';
4034                
4035            if(hasON) {
4036                $.each(fnav_data, function(i,v) {
4037                    str += $.fnav.itemHTML(v.idx, v.name, v.type, v.value, v.target, v.icon, v.display); 
4038                });
4039            }
4040
4041            return '\
4042                            <div class="fnav fnav-mobile-fnav" style="--fnav-bgcolor: '+fnav_bg+'; --fnav-color: '+fnav_fcolor+'; ">\
4043                            ' + str + '\
4044                            </div>\
4045            ';
4046        },
4047        itemHTML: function(idx,name,type,value,target,icon,display) {
4048            var href = '#', 
4049                attr_target = (type == "tel") ? ' target=""' : ' target="' + target + '"',
4050                attr_link = '';
4051
4052            if(icon == 'empty') icon = '';
4053
4054            if(value) {
4055                if(type == "tel") {
4056                    href = (value.match(/^tel:/)) ? value : 'tel:' + value;
4057                } else { //link
4058                    if(checkBase64Encode(decodeURIComponent(value))) value = Base64.decode(decodeURIComponent(value));
4059                    else value = (checkBase64Encode(value)) ? Base64.decode(value) : value;
4060                    
4061                    var menulist = (PAGE_MODE == 'c') ? MENULIST : property.MENULIST,
4062                        one = (PAGE_MODE == 'c') ? ONE : property.ONE,
4063                        view = (PAGE_MODE == 'c') ? VIEW : property.VIEW;
4064
4065                    href = makeLinkUrl(value,one,view);
4066                    if(menulist.indexOf(value.replace(/ /g,'-'))>-1) {
4067                        attr_link = 'data-user-link="' + href + '"';
4068                    } else if(value.match(/^\@/g)) {
4069                        attr_link = 'attr-bookmark="' + value.replace(/^\@/g,'') + '"';
4070                    } else {
4071                        var link = encodeURIComponent(Base64.encode(value));
4072                        attr_link = 'attr-link="' + link + '"';
4073                    }
4074                }
4075
4076            }
4077
4078            if(display != 'on') return '';
4079            else return '\
4080                                <div class="fnav-item" data-idx="' + idx + '" data-type="' + type + '">\
4081                                    <a href="' + href + '" ' + attr_target + ' ' + attr_link + '>\
4082                                        <i class="' + icon + '" aria-hidden="true"></i>\
4083                                        <span class="fnav-name">' + name + '</span>\
4084                                    </a>\
4085                                </div>\
4086            ';
4087        },
4088
4089    }
4090
4091    $.mpcWeb = {
4092        init: function(vpOption,contents,WebType,zoom,pagemove) {   
4093            var device_w = (vpOption=='mobile_pc') ? 1440 : 'device-width',
4094                scale = (vpOption=='mobile_pc') ? (window.screen.width / 1440) : 1.0,
4095                zoom = (zoom) ? '' : ', maximum-scale=1, user-scalable=no',
4096                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>',
4097                checkFnav = ($('.fnav').length > 0 && vpOption=="mobile_web") ? true : false;
4098
4099            //$.mpcWeb.mpcWebShowcase(vpOption,contents,pagemove);
4100
4101            $('.dsgn-body .mobilepc_ch .mpc_icon').remove();
4102            $('.dsgn-body .mobilepc_ch').prepend(mpc_icon);
4103            document.documentElement.setAttribute('data-mpc-vpmode',vpOption);
4104            
4105            var viewport = document.querySelector('meta[name="viewport"]');
4106            if(viewport) viewport.setAttribute('content','width='+device_w+', initial-scale='+scale+''+zoom+'');
4107            setTimeout(function() {
4108                if(typeof Event == 'function') window.dispatchEvent(new Event('resize'));
4109                else {
4110                    var resizeEvent = document.createEvent('Event');
4111                    resizeEvent.initEvent('resize',true,true);
4112                    window.dispatchEvent(resizeEvent);
4113                }
4114
4115                if(typeof $.clnav != 'undefined'
4116                    && typeof $.clnav.check == 'function'
4117                    && $.clnav.check()
4118                ) {
4119                    if(typeof $.clnav.refreshMobileStyle == 'function') $.clnav.refreshMobileStyle();
4120                    else if(typeof $.clnav.setMobileStyle == 'function') {
4121                        var $header = $('.cl-nav').first();
4122                        if($header.length) $.clnav.setMobileStyle($header);
4123                        if(typeof $.clnav.setRootcss == 'function') $.clnav.setRootcss();
4124                    }
4125                }
4126            }, 80);
4127
4128            /*if($('.dsgn-body').hasClass('sidebar')) {
4129                $('.dsgn-body').removeClass('sidebar').addClass('removed-sidebar');
4130            } else if ($('.dsgn-body').hasClass('removed-sidebar')) {
4131                $('.dsgn-body').removeClass('removed-sidebar').addClass('sidebar');                
4132            }*/
4133
4134            $.mpcWeb.mpcMusicandGoTop(checkFnav,vpOption);     
4135
4136            if(checkFnav && WebType == 'MOBILE') {
4137                $('.fnav.fnav-mobile-fnav').css('margin-bottom','53px');
4138                $('.element.el-footer').css('margin-bottom','100px');
4139            } else {
4140                $('.mobilepc_ch').css('margin-bottom','0px');
4141                $('.element.el-footer').css('margin-bottom','0px');
4142            }
4143        },
4144
4145
4146        mpcWebhtml: function(vpOption,contents,zoom,pagemove,sid) {
4147            //if (window.location.href.indexOf('_checkout') != -1) return false;
4148            sid = (sid) ? sid : (typeof property != 'undefined' ? property.SID : SID);
4149            pagemove = ((typeof pagemove == 'undefined') || !pagemove) ? '' : pagemove;
4150            
4151            $.mpcWeb.mpcCookie(vpOption,sid);
4152
4153            if($.cookie('vpmode')) {
4154                vpOption = $.cookie('vpmode');
4155            }
4156            
4157            var vpChangeText = (vpOption=="mobile_pc") ? $.lang[LANG]['editor.mobile.changePc.mobileWeb'] : $.lang[LANG]['editor.mobile.changePc.mobilePc'],    
4158                mpc_html = "\
4159                <div class='mobilepc_ch' data-desktop-option='"+vpOption+"'>\
4160                    <p class='hand'>\
4161                        <span class='mpc-name'>" + vpChangeText + "</span>\
4162                    </p>\
4163                </div>\
4164            ",
4165                WebType = $.mpcWeb.mpcCheckWebType();
4166
4167            if(WebType == 'MOBILE') {
4168                if(window.location.href.indexOf('_checkout') == -1) {
4169                    $('.dsgn-body').find('.mobilepc_ch').remove();
4170                    $('.dsgn-body').append(mpc_html);
4171                }                
4172                $.mpcWeb.init(vpOption,contents,WebType,zoom,pagemove);
4173                $.mpcWeb.mpcChangeVal(vpOption,contents,WebType,zoom,pagemove,sid);
4174            }
4175        },   
4176
4177        mpcWebShowcase : function(vpOption,contents,pagemove) {
4178            $.each(contents,function(i,v) {
4179                var v_el = (pagemove=='pagemove') ? v : v.element;
4180                if((vpOption == "mobile_pc") && (v_el.type == 'showcase')) $("."+v_el.elname).addClass('mobilePc_he
4180ight');
4181                else $("."+v_el.elname).removeClass('mobilePc_height');
4182            });
4183            
4184        },
4185
4186        mpcChangeVal : function(vpOption,contents,WebType,zoom,pagemove,sid) {
4187            //if (window.location.href.indexOf('_checkout') != -1) return false;
4188            sid = (sid) ? sid : (typeof property != 'undefined' ? property.SID : SID);
4189            $('.mobilepc_ch').off('click.mpcWeb').on('click.mpcWeb', function() {
4190                vpOption = (vpOption=="mobile_pc") ? 'mobile_web' : 'mobile_pc';
4191                var vpChangeText = (vpOption=="mobile_pc") ? $.lang[LANG]['editor.mobile.changePc.mobileWeb'] : $.lang[LANG]['editor.mobile.changePc.mobilePc'];
4192                
4193                $(this).find('.mpc-name').text(vpChangeText);
4194                $(this).attr('data-desktop-option',vpOption);
4195                document.documentElement.setAttribute('data-mpc-vpmode',vpOption);
4196
4197                $.mpcWeb.init(vpOption,contents,WebType,zoom,pagemove);
4198
4199                if(typeof property != 'undefined') {
4200                    if(property.ONE && !property.VIEW || property.PAGE == property.MENULINK[0] && !property.VIEW) setSitePopup();
4201
4202                    setTimeout(() => {
4203                        if(typeof property.SETTINGS.qm_onoff != 'undefined' && property.SETTINGS.qm_onoff==true) {
4204                            var device_type = (vpOption=='mobile_pc') ? 'pc' : 'mobile',
4205                                mpc_height = $('.mobilepc_ch').innerHeight();
4206                                            
4207                            $.quickmenu.setHTML($.quickmenu['quickmenu'], device_type);
4208                            mobileWebQuickmenuPosition(property,device_type);    
4209                            if($('#cl-music-player-icon').length > 0) quickMenuMusicPosition(property);
4210                        }    
4211                    }, 500);
4212                }
4213                if($('.element[data-type="forum"]').length > 0) {
4214                    var icon_notice = '<i class="tpl-forum-list-notice-icon cl-icon notice01" aria-hidden="true"></i>';
4215                    
4216                    $('.element[data-type="forum"] .tpl-forum-list-title .tpl-forum-list-notice-icon').remove();
4217
4218                    $('.element[data-type="forum"]').each(function(idx, v) {
4219                        var $forum = $(v);
4220                        var type = $(v).attr('data-type2');
4221
4222                        if($forum.find('.tpl-forum-list-title[data-option="N"]').length > 0) { //forum notice
4223                            if(vpOption == 'mobile_web' && type == 'thumb') {
4224                                $forum.find('.tpl-forum-list-num.n').each(function(idx, n){
4225                                    var num = $(n).attr('data-fm-num');
4226                                    $(n).html(num);
4227                                });
4228                            } else {
4229                                $forum.find('.tpl-forum-list-num.n').html(icon_notice);
4230                            }
4231
4232                            if($forum.find('.tpl-forum-list-num').hasClass('hidden')) { // field_disabled = num
4233                                 $forum.find('.tpl-forum-list-title[data-option="N"]').prepend(icon_notice);
4234                            } else {
4235                                if(vpOption == 'mobile_web') {
4236                                    $forum.find('.tpl-forum-list-title[data-option="N"]').prepend(icon_notice);
4237                                    if(type == 'normal' && $forum.find('.tpl-forum-list-num').css('display') != 'none') {
4238                                        $forum.find('.tpl-forum-list-title .tpl-forum-list-notice-icon').addClass('hide');
4239                                    }
4240                                } else {
4241                                    $forum.find('.tpl-forum-list-num.n').html(icon_notice);
4242                                }
4243                            }
4244                        }
4245                    });
4246                }
4247                $('.element[data-msny="true"]').each(function() {
4248                    reloadBlockMasonry('refresh',$(this));
4249                });
4250
4251                $.mpcWeb.mpcCookie(vpOption,sid);
4252
4253                if (window.location.href.indexOf('_checkout') != -1) {
4254                    $('.dsgn-body').find('.mobilepc_ch').remove();
4255                }
4256
4257                if($('body').hasClass('openBandBanner')) $.siteBanner.call('band',false,false,true,true)
4258                if($('body').hasClass('openPopupBanner')) $.siteBanner.call('popup',false,false,true,true)
4259
4260                setTimeout(function(){
4261                    $.fheader.position();
4262					setFixedMenuCss(false);
4263				},50);
4264
4265            });
4266        },
4267
4268        mpcCheckWebType : function(){
4269            var filter = "win16|win32|win64|mac|macintel",
4270                WebType = "";
4271
4272            if (navigator.platform) {
4273                if (filter.indexOf(navigator.platform.toLowerCase()) < 0) WebType = "MOBILE";
4274                else WebType = "PC";
4275            }
4276
4277            return WebType;
4278        },
4279
4280        mpcMusicandGoTop : function(checkFnav,vpOption) {
4281            var checkmpc = ($('.mobilepc_ch').length > 0) ? true : false;
4282
4283            if(checkmpc && vpOption == 'mobile_pc') {
4284                if($('#cl-music-player-icon').length > 0) $('#goto-top,#cl-music-player-icon').removeClass('moveMpc movepc movedOne').addClass('moved');
4285                else $('#goto-top,#cl-music-player-icon').removeClass('movedOne moveMpc movepc').addClass('moved');
4286            } else {
4287                if(checkFnav) {
4288                    if($('#cl-music-player-icon').length > 0) {
4289                        $('#goto-top').css('bottom','');  
4290                        $('#goto-top,#cl-music-player-icon').removeClass('movedOne movepc moved').addClass('moveMpc');
4291                    } else $('#goto-top').removeClass('movedOne movepc moved moveMpc').css('bottom','120px');  
4292                } else {
4293                    if($('#cl-music-player-icon').length > 0) $('#goto-top,#cl-music-player-icon').removeClass('moveMpc movepc moved').addClass('movedOne');
4294                    else $('#goto-top,#cl-music-player-icon').removeClass('movedOne movepc moveMpc moved');
4295                }          
4296            }
4297        },
4298        mpcCookie : function(vpOption,sid) {
4299            sid = (sid) ? sid : (typeof property != 'undefined' ? property.SID : SID);
4300            var date = new Date();
4301            date.setTime(date.getTime() + 6*60*60*1000); // 6h
4302
4303            $.cookie('vpmode-'+sid, vpOption, { expires: date, path : '/' });
4304        },
4305        mpcGetVpmode : function(vpmode,settings,sid) {
4306            sid = (sid) ? sid : (typeof property != 'undefined' ? property.SID : SID);
4307            if($.cookie('vpmode-'+sid)) vpmode = $.cookie('vpmode-'+sid);
4308            else vpmode = (typeof $('.mobilepc_ch').attr('data-desktop-option') != 'undefined') ? $('.mobilepc_ch').attr('data-desktop-option') : settings.viewportMode;
4309            
4310            return vpmode;
4311        }
4312    }
4313
4314    /* menu 추가 버튼 설정 **************************************************************/
4315    $.menuFixBtn = {
4316        topSet : function(num,checkmodal,validArray,slang){
4317            var str = '',
4318                searchOn = '',
4319                cartOn = '',
4320                umOn = '',
4321                ssid = (PAGE_MODE == 'c') ? SID : property.SID,
4322                is_templates = checkTemplateSite(ssid),
4323                s_service = (PAGE_MODE == 'c') ? SERVICE : property.SERVICE,
4324                checkGabia = (s_service.indexOf('gabia') > -1) ? true : false,
4325                checkBS = (validArray['validplan'] && (validArray['validtype'] == 'BS' || (checkGabia && (validArray['validtype'] == 'FR')))) ? true : false,
4326                checkBN = (validArray['validplan'] && validArray['validtype'] == 'BN') ? true : false,
4327                checkSM = (validArray['validplan'] && validArray['validtype'] == 'SM') ? true : false,
4328                checkFREE = (!validArray['validplan'] || validArray['validplan'] == 'FR' || validArray['validplan'] == 'PK') ? true : false,
4329                checkElView = ($('.elviewhtml').length>0) ? true : false,
4330                fixBtnSITEUM = (checkElView) ? '' : ((PAGE_MODE=='c') ? SITEUM : property.SITEUM),
4331                checkSITEUM = (!checkElView && ((checkBN && typeof fixBtnSITEUM!='undefined' && Number(fixBtnSITEUM) > 0) || checkSM)) ? true : (checkElView ? true : false),
4332                checkmodal = (typeof checkmodal != 'undefined' && checkmodal) ? true : false,
4333                fixon = (typeof $('.el-menu header.navbar').attr('data-fixon') != 'undefined' && $('.el-menu header.navbar').attr('data-fixon')) ? $('.el-menu header.navbar').attr('data-fixon') : '',
4334                dropdownClass = (PAGE_MODE=='c') ? '' : 'dropdown ',
4335                slang = (typeof langObj != 'undefined' && langObj) ? langObj : ((PAGE_MODE == 'c') ? SLANG : property.SLANG);
4336                // lang_str = LANG;
4337                
4338                if(!checkElView) {
4339                    if(checkBN && !checkSITEUM) return '';
4340                    searchOn = (!checkSM) ? 'style="display:none;"' : '';
4341                    umOn = (checkBS || checkFREE || (checkBN && !checkSITEUM)) ? 'style="display:none;"' : '';   
4342                    cartOn = (checkFREE) ? 'style="display:none;"' : ((checkSM) ? '' : 'style="display:none;"');
4343                    if(fixon && (checkBN || checkSM) && checkSITEUM) {
4344                        searchOn = ((checkSM) && fixon.indexOf('search')>-1) ? '' : 'style="display:none;"';
4345                        cartOn = ((checkSM) && fixon.indexOf('cart')>-1) ? '' : 'style="display:none;"';
4346                        umOn = ((checkBN || checkSM) && fixon.indexOf('um')>-1) ? '' : 'style="display:none;"';
4347                    }
4348                    if(fixon == 'all') {
4349                        searchOn = 'style="display:none;"';
4350                        cartOn = 'style="display:none;"';
4351                        umOn = 'style="display:none;"';
4352                    }
4353                }
4354               
4355                if(checkElView || checkmodal || is_templates) {
4356                    umOn = (checkBS || checkFREE) ? 'style="display:none;"' : '';  
4357                    searchOn = cartOn = (checkSM) ? '' : 'style="display:none;"';
4358                }
4359               
4360                /* 다국어 / 사이트 언어별 lang 체크 ***/
4361                // if((typeof slang != 'undefined' && typeof slang.select_code != 'undefined' && slang.select_code)
4362                //             || (!$.isEmptyObject(slang) && slang.select_code)) {
4363                //     //searchOn = (slang['select_code']=='ko' && checkSM) ? '' : 'style="display:none;"';
4364                //     lang_str = (slang['select_code'].toLowerCase()=='ko') ? 'ko' : lang_str;
4365                // } 
4366
4367            switch(num) {
4368                case "01" : 
4369                    str = '\
4370                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">SEARCH</a></li>\
4371                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4372                            <a href="javascript:;" class="cl-login">LOGIN</a>\
4373                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">MY PAGE</a>\
4374                        </li>\
4375                        <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>\
4376                        '; 
4377                    break;
4378                
4379                case "02" : 
4380                    str = '\
4381                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">Search</a></li>\
4382                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4383                            <a href="javascript:;" class="cl-login">Login</a>\
4384                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">My page</a>\
4385                        </li>\
4386                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4387                            <a href="#"><span class=\"cart-text\">Basket</span><div class=\"cart-active\">5</div></a>\
4388                        </li>\
4389                        ';
4390                    break;
4391
4392                case "03" : 
4393                    str = '\
4394                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">검색</a></li>\
4395                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4396                            <a href="javascript:;" class="cl-login">로그인</a>\
4397                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">마이페이지</a>\
4398                        </li>\
4399                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4400                            <a href="#"><span class=\"cart-text\">장바구니</span>\
4401                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4402                            </a>\
4403                        </li>\
4404                        ';
4405                    break;
4406                
4407                case "04" : 
4408                    str = '\
4409                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search4',28,28,true)+'</a></li>\
4410                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4411                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login4',28,28,true)+'</a>\
4412                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage4',28,28,true)+'</a>\
4413                        </li>\
4414                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4415                            <a href="#">'+clSVG('fixbtn_cart4',28,28,true)+'\
4416                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4417                            </a>\
4418                        </li>\
4419                        ';
4420                    break;
4421                
4422                case "05" : 
4423                    str = '\
4424                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search5',28,28,true)+'</a></li>\
4425                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4426                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login5',28,28,true)+'</a>\
4427                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage5',28,28,true)+'</a>\
4428                        </li>\
4429                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4430                            <a href="#">'+clSVG('fixbtn_cart5',28,28,true)+'\
4431                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4432                            </a>\
4433                        </li>\
4434                        ';
4435                    break;
4436                
4437                case "06" : 
4438                    str = '\
4439                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search6',28,28,true)+'</a></li>\
4440                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4441                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login6',28,28,true)+'</a>\
4442                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage6',28,28,true)+'</a>\
4443                        </li>\
4444                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4445                            <a href="#">'+clSVG('fixbtn_cart6',28,28,true)+'\
4446                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4447                            </a>\
4448                        </li>\
4449                        ';
4450                    break;
4451                
4452                case "07" : 
4453                    str = '\
4454                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search7',28,28,true)+'</a></li>\
4455                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4456                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login7',28,28,true)+'</a>\
4457                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage7',28,28,true)+'</a>\
4458                        </li>\
4459                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4460                            <a href="#">'+clSVG('fixbtn_cart7',28,28,true)+'\
4461                                <div class=\"cart-active\">5</div>\
4462                            </a>\
4463                        </li>\
4464                        ';
4465                    break;
4466
4467                case "08" : 
4468                    str = '\
4469                        <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>\
4470                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4471                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login8',28,28,true)+'<span class=\"btn_text\">LOGIN</span></a>\
4472                            <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>\
4473                        </li>\
4474                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4475                            <a href="#">'+clSVG('fixbtn_cart8',28,28,true)+'\
4476                                <span class=\"btn_text\">CART</span><div class=\"cart-active\">5</div>\
4477                            </a>\
4478                        </li>\
4479                        ';
4480                    break;
4481                
4482                case "09" : 
4483                    str = '\
4484                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">검색</a></li>\
4485                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4486                            <a href="javascript:;" class="cl-login">로그인</a>\
4487                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">마이페이지</a>\
4488                        </li>\
4489                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4490                            <a href="#">'+clSVG('fixbtn_cart9',28,28,true)+'\
4491                                <div class=\"cart-active\">5</div>\
4492                            </a>\
4493                        </li>\
4494                        ';
4495                    break;
4496                
4497                case "10" : 
4498                    str = '\
4499                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4500                            <a href="javascript:;" class="cl-login">LOGIN</a>\
4501                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">MY PAGE</a>\
4502                        </li>\
4503                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search10',28,28,true)+'</a></li>\
4504                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4505                            <a href="#">'+clSVG('fixbtn_cart9',28,28,true)+'\
4506                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4507                            </a>\
4508                        </li>\
4509                        ';
4510                    break;
4511
4512                default : 
4513                    break;
4514            }
4515            
4516            return str;
4517        },
4518        sidebarSet : function(num,checkmodal,validArray,slang) {
4519            var str = '',
4520                searchOn = '',
4521                cartOn = '',
4522                umOn = '',
4523                ssid = (PAGE_MODE == 'c') ? SID : property.SID,
4524                is_templates = checkTemplateSite(ssid),
4525                s_service = (PAGE_MODE == 'c') ? SERVICE : property.SERVICE,
4526                checkGabia = (s_service.indexOf('gabia') > -1) ? true : false,
4527                checkBS = (validArray['validplan'] && (validArray['validtype'] == 'BS' || (checkGabia && (validArray['validtype'] == 'FR')))) ? true : false,
4528                checkBN = (validArray['validplan'] && validArray['validtype'] == 'BN') ? true : false,
4529                checkSM = (validArray['validplan'] && validArray['validtype'] == 'SM') ? true : false,
4530                checkFREE = (!validArray['validplan'] || validArray['validplan'] == 'FR' || validArray['validplan'] == 'PK') ? true : false,
4531                checkElView = ($('.elviewhtml').length>0) ? true : false,
4532                fixBtnSITEUM = (checkElView) ? '' : ((PAGE_MODE=='c') ? SITEUM : property.SITEUM),
4533                checkSITEUM = (!checkElView && ((checkBN && typeof fixBtnSITEUM!='undefined' && Number(fixBtnSITEUM) > 0) || checkSM)) ? true : (checkElView ? true : false),
4534                checkmodal = (typeof checkmodal != 'undefined' && checkmodal) ? true : false,                
4535                fixon = (typeof $('.el-menu header.navbar').attr('data-fixon') != 'undefined' && $('.el-menu header.navbar').attr('data-fixon')) ? $('.el-menu header.navbar').attr('data-fixon') : '',
4536                dropdownClass = (PAGE_MODE=='c') ? '' : 'dropdown ',
4537                slang = (typeof langObj != 'undefined' && langObj) ? langObj : ((PAGE_MODE == 'c') ? SLANG : property.SLANG);
4538                // lang_str = LANG;
4539                
4540                if(!checkElView) {
4541                    searchOn = (!checkSM) ? 'style="display:none;"' : '';                    
4542                    umOn = (checkBS || checkFREE || (checkBN && !checkSITEUM)) ? 'style="display:none;"' : '';   
4543                    cartOn = (checkFREE) ? 'style="display:none;"' : ((checkSM) ? '' : 'style="display:none;"');
4544                    if(fixon && (checkBN || checkSM) && checkSITEUM) {
4545                        searchOn = ((checkSM) && fixon.indexOf('search')>-1) ? '' : 'style="display:none;"';
4546                        cartOn = ((checkSM) && fixon.indexOf('cart')>-1) ? '' : 'style="display:none;"';
4547                        umOn = ((checkBN || checkSM) && fixon.indexOf('um')>-1) ? '' : 'style="display:none;"';
4548                    }
4549                    if(fixon == 'all') {
4550                        searchOn = 'style="display:none;"';
4551                        cartOn = 'style="display:none;"';
4552                        umOn = 'style="display:none;"';
4553                    }
4554                }
4555               
4556                if(checkElView || checkmodal || is_templates) {
4557                    umOn = (checkBS || checkFREE) ? 'style="display:none;"' : '';  
4558                    searchOn = cartOn = (checkSM) ? '' : 'style="display:none;"';
4559                }
4560                   
4561                /* 다국어 / 사이트 언어별 lang 체크 ***/
4562                // if((typeof slang != 'undefined' && typeof slang.select_code != 'undefined' && slang.select_code)
4563                //             || (!$.isEmptyObject(slang) && slang.select_code)) {
4564                //     //searchOn = (slang['select_code']=='ko' && checkSM) ? '' : 'style="display:none;"';
4565                //     lang_str = (slang['select_code'].toLowerCase()!='ko') ? 'en' : 'ko';
4566                // } 
4567
4568            switch(num) {
4569                case "01" : 
4570                    str = '\
4571                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">SEARCH</a></li>\
4572                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4573                            <a href="javascript:;" class="cl-login">LOGIN</a>\
4574                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">MY PAGE</a>\
4575                        </li>\
4576                        <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>\
4577                        '; 
4578                    break;
4579                
4580                case "02" : 
4581                    str = '\
4582                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">Search</a></li>\
4583                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4584                            <a href="javascript:;" class="cl-login">Login</a>\
4585                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">My page</a>\
4586                        </li>\
4587                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4588                            <a href="#"><span class=\"cart-text\">Basket</span><div class=\"cart-active\">5</div></a>\
4589                        </li>\
4590                        ';
4591                    break;
4592
4593                case "03" : 
4594                    str = '\
4595                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">검색</a></li>\
4596                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4597                            <a href="javascript:;" class="cl-login">로그인</a>\
4598                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">마이페이지</a>\
4599                        </li>\
4600                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4601                            <a href="#"><span class=\"cart-text\">장바구니</span>\
4602                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4603                            </a>\
4604                        </li>\
4605                        ';
4606                    break;
4607                
4608                case "04" : 
4609                    str = '\
4610                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search4',28,28,true)+'</a></li>\
4611                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4612                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login4',28,28,true)+'</a>\
4613                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage4',28,28,true)+'</a>\
4614                        </li>\
4615                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4616                            <a href="#">'+clSVG('fixbtn_cart4',28,28,true)+'\
4617                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4618                            </a>\
4619                        </li>\
4620                        ';
4621                    break;
4622                
4623                case "05" : 
4624                    str = '\
4625                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search5',28,28,true)+'</a></li>\
4626                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4627                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login5',28,28,true)+'</a>\
4628                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage5',28,28,true)+'</a>\
4629                        </li>\
4630                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4631                            <a href="#">'+clSVG('fixbtn_cart5',28,28,true)+'\
4632                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4633                            </a>\
4634                        </li>\
4635                        ';
4636                    break;
4637                
4638                case "06" : 
4639                    str = '\
4640                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search6',28,28,true)+'</a></li>\
4641                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4642                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login6',28,28,true)+'</a>\
4643                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage6',28,28,true)+'</a>\
4644                        </li>\
4645                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4646                            <a href="#">'+clSVG('fixbtn_cart6',28,28,true)+'\
4647                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4648                            </a>\
4649                        </li>\
4650                        ';
4651                    break;
4652                
4653                case "07" : 
4654                    str = '\
4655                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search7',28,28,true)+'</a></li>\
4656                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4657                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login7',28,28,true)+'</a>\
4658                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage7',28,28,true)+'</a>\
4659                        </li>\
4660                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4661                            <a href="#">'+clSVG('fixbtn_cart7',28,28,true)+'\
4662                                <div class=\"cart-active\">5</div>\
4663                            </a>\
4664                        </li>\
4665                        ';
4666                    break;
4667
4668                case "08" : 
4669                    str = '\
4670                        <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>\
4671                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4672                            <a href="javascript:;javascript:;" class="cl-login">'+clSVG('fixbtn_um_login8',28,28,true)+'<span class=\"btn_text\">LOGIN</span></a>\
4673                            <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>\
4674                        </li>\
4675                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4676                            <a href="#">'+clSVG('fixbtn_cart8',28,28,true)+'\
4677                                <span class=\"btn_text\">CART</span><div class=\"cart-active\">5</div>\
4678                            </a>\
4679                        </li>\
4680                        ';
4681                    break;
4682                
4683                case "09" : 
4684                    str = '\
4685                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">검색</a></li>\
4686                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4687                            <a href="javascript:;" class="cl-login">로그인</a>\
4688                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">마이페이지</a>\
4689                        </li>\
4690                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4691                            <a href="#">'+clSVG('fixbtn_cart9',28,28,true)+'\
4692                                <div class=\"cart-active\">5</div>\
4693                            </a>\
4694                        </li>\
4695                        ';
4696                    break;
4697                
4698                case "10" : 
4699                    str = '\
4700                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4701                            <a href="javascript:;" class="cl-login">LOGIN</a>\
4702                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">My page</a>\
4703                        </li>\
4704                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search10',28,28,true)+'</a></li>\
4705                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4706                            <a href="#">'+clSVG('fixbtn_cart9',28,28,true)+'\
4707                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4708                            </a>\
4709                        </li>\
4710                        ';
4711                    break;
4712
4713                default : 
4714                    break;
4715            }
4716            
4717            return str;
4718        },
4719        fixFhTypeSet : function(pos) {
4720            var str = '';
4721
4722            switch(pos) {
4723                
4724                case "right" : 
4725
4726                    str += '\
4727                        <ul class="menuList">\
4728                            <li class="cl-menulist"><a href="#">Home</a></li>\
4729                            <li class="cl-menulist"><a href="#">Portfolio</a></li>\
4730                            <li class="cl-menulist"><a href="#">Contact</a></li>\
4731                        </ul>\
4732                        <ul class="menufixArea">\
4733                            <li class="siteSEARCH cl-fixbtn"><a href="#">'+clSVG('fixbtn_search4',28,28,true)+'</a></li>\
4734                            <li class="siteUM cl-fixbtn"><a href="#">'+clSVG('fixbtn_um4',28,28,true)+'</a></li>\
4735                            <li class="siteCART cl-fixbtn"><a href="#">'+clSVG('fixbtn_cart4',28,28,true)+'</a></li>\
4736                        </ul>\
4737                        ';
4738
4739                    break;
4740
4741                case "top" : 
4742
4743                    str += '\
4744                        <ul class="menufixArea">\
4745                            <li class="siteSEARCH cl-fixbtn"><a href="#">'+clSVG('fixbtn_search4',28,28,true)+'</a></li>\
4746                            <li class="siteUM cl-fixbtn"><a href="#">'+clSVG('fixbtn_um4',28,28,true)+'</a></li>\
4747                            <li class="siteCART cl-fixbtn"><a href="#">'+clSVG('fixbtn_cart4',28,28,true)+'</a></li>\
4748                        </ul>\
4749                        <ul class="menuList">\
4750                            <li class="cl-menulist"><a href="#">Home</a></li>\
4751                            <li class="cl-menulist"><a href="#">Portfolio</a></li>\
4752                            <li class="cl-menulist"><a href="#">Contact</a></li>\
4753                        </ul>\
4754                        ';
4755
4756                    break;
4757
4758                default : 
4759                    break;
4760            }
4761            
4762            return str;
4763        },
4764        fixLangSet : function(num,def,langObj,checkMobile,validArray){
4765            var checkElView = ($('.elviewhtml').length>0) ? true : false,
4766                s_service = (PAGE_MODE == 'c') ? SERVICE : property.SERVICE,
4767                checkGabia = (s_service.indexOf('gabia') > -1) ? true : false,
4768                checkVALIDPLAN = (PAGE_MODE=='c') ? VALIDPLAN : property.VALIDPLAN,
4769                checkVALIDTYPE = (PAGE_MODE=='c') ? VALIDTYPE : property.VALIDTYPE,
4770                checkBS = (checkVALIDPLAN && (checkVALIDTYPE == 'BS' || (checkGabia && (checkVALIDTYPE == 'FR')))) ? true : false,
4771                slang = (typeof langObj != 'undefined' && langObj) ? langObj : ((PAGE_MODE == 'c') ? SLANG : property.SLANG),
4772                def = (typeof def!='undefined') ? def : true,
4773                checkMobile = (typeof checkMobile!='undefined') ? checkMobile : false;
4774
4775			slang = (slang && typeof slang == 'object') ? slang : {};
4776			var slangLists = $.isArray(slang.lists) ? slang.lists : [];
4777			if(slangLists.length === 0) return false;
4778              
4779            if(typeof validArray != 'undefined') var checkFREE = (!validArray['validplan'] || validArray['validplan'] == 'FR' || validArray['validplan'] == 'PK') ? true : false;
4780            if(!checkElView && ((typeof slang == 'undefined' && typeof slang.select_code == 'undefined' && !slang.select_code)
4781                            || ($.isEmptyObject(slang) && checkBS) || slang.select_code=='') || (checkElView && checkFREE) 
4782                || (typeof slang=='undefined' || !slang.select)) {
4783                    return false;
4784                }
4785          
4786            var str = '',
4787                lang_txt = (typeof slang.select != 'undefined' && slang.select) ? slang.select.trim() : '',
4788                lang_code = (typeof slang.select_code != 'undefined' && slang.select_code) ? slang.select_code.toUpperCase() : '',
4789                checkDropTopClass = ($('.el-menu > header.navbar').hasClass('sidebar') || checkMobile) ? 'dropup' : 'dropdown',
4790                dropdownClass = (PAGE_MODE=='c') ? '' : 'dropdown',
4791                dropdownStr = '';
4792            
4793            if(checkMobile) {
4794                dropdownStr += '\
4795                <div class="dropdown-menu-wrap" id="m-dropdown-wrap-lang">\
4796                    <span class="dropdown-close"><img src="//storage.googleapis.com/i.addblock.net/fa-close-modal-white.png" alt="Close Change Multilingual Site"></span></span>\
4797                ';
4798            }
4799                dropdownStr += '\
4800                    <ul class="dropdown-menu">';
4801                    $.each(slang.lists, function(i,v){
4802                    var active = (v.name == slang.select) ? 'active' : '';
4803                    dropdownStr += '\
4804                        <li class="'+active+'"><a class="cl-langlist " href="javascript:;" data-code="'+v.code+'">'+v.name+'</a></li>';
4805                    });
4806                dropdownStr += '\
4807                    </ul>';
4808            if(checkMobile) {
4809                dropdownStr += '\
4810                </div>\
4811                ';
4812            }                  
4813          
4814            var attrMobile = (checkMobile) ? 'data-toggle="dropdown" data-target="#m-dropdown-wrap-lang"' : '';
4815         
4816            switch(num) {
4817                case "01" : 
4818                    str = (!def) ? '\
4819                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4820                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4821                                <span class="slang-active">'+lang_code+'</span>\
4822                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4823                            </a>' + dropdownStr + '\
4824                        </div>' : '\
4825                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4826                            <a href="#" class="cl-lang dropdown-toggle">\
4827                                <span class="slang-active">'+lang_code+'</span>\
4828                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4829                            </a>' + dropdownStr + '\
4830                        </li>\
4831                        '; 
4832                    break;
4833                
4834                case "02" : 
4835                    str = (!def) ? '\
4836                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4837                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4838                                <span class="slang-active">'+lang_txt+'</span>\
4839                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4840                            </a>' + dropdownStr + '\
4841                        </div>' : '\
4842                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4843                            <a href="#" class="cl-lang dropdown-toggle">\
4844                                <span class="slang-active">'+lang_txt+'</span>\
4845                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4846                            </a>' + dropdownStr + '\
4847                        </li>\
4848                        '; 
4849                    break;
4850                
4851                case "03" : 
4852                    str = (!def) ? '\
4853                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4854                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4855                                <span class="slang-active">'+lang_code+'</span>\
4856                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4857                            </a>' + dropdownStr + '\
4858                        </div>' : '\
4859                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4860                            <a href="#" class="cl-lang dropdown-toggle">\
4861                                <span class="slang-active">'+lang_code+'</span>\
4862                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4863                            </a>' + dropdownStr + '\
4864                        </li>\
4865                        '; 
4866                    break;
4867                
4868                case "04" : 
4869                    str = (!def) ? '\
4870                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4871                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4872                                <span class="slang-active">'+lang_code+'</span>\
4873                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4874                            </a>' + dropdownStr + '\
4875                        </div>\
4876                        ' : '\
4877                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4878                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4879                                <span class="slang-active">'+lang_code+'</span>\
4880                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4881                            </a>' + dropdownStr + '\
4882                        </li>\
4883                        '; 
4884                    break;
4885                
4886                case "05" : 
4887                    str = (!def) ? '\
4888                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4889                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4890                                <span class="slang-active" style="display:none;">'+lang_code+'</span>\
4891                                ' + clSVG('fixbtn_lang5',18,18,true) + '\
4892                            </a>' + dropdownStr + '\
4893                        </div>\
4894                        ' : '\
4895                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4896                            <a href="#" class="cl-lang dropdown-toggle">\
4897                                <span class="slang-active" style="display:none;">'+lang_code+'</span>\
4898                                ' + clSVG('fixbtn_lang5',18,18,true) + '\
4899                            </a>' + dropdownStr + '\
4900                        </li>\
4901                        '; 
4902                    break;
4903
4904                case "06" : 
4905                    str = (!def) ? '\
4906                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4907                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4908                                ' + clSVG('fixbtn_lang5',18,18,true) + '\
4909                                <span class="slang-active">'+lang_code+'</span>\
4910                            </a>' + dropdownStr + '\
4911                        </div>\
4912                        ' : '\
4913                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4914                            <a href="#" class="cl-lang dropdown-toggle">\
4915                                ' + clSVG('fixbtn_lang5',18,18,true) + '\
4916                                <span class="slang-active">'+lang_code+'</span>\
4917                            </a>' + dropdownStr + '\
4918                        </li>\
4919                        '; 
4920                    break;
4921                
4922                case "07" : 
4923                    str = (!def) ? '\
4924                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4925                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4926                                <img src="//storage.googleapis.com/i.addblock.net/flag/flag_'+lang_code.toLowerCase()+'_cir.png" class="cl-lang-img img-responsive"/>\
4927                                <span class="slang-active">'+lang_txt+'</span>\
4928                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4929                            </a>' + dropdownStr + '\
4930                        </div>\
4931                        ' : '\
4932                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4933                            <a href="#" class="cl-lang dropdown-toggle">\
4934                                <img src="//storage.googleapis.com/i.addblock.net/flag/flag_'+lang_code.toLowerCase()+'_cir.png" class="cl-lang-img img-responsive"/>\
4935                                <span class="slang-active">'+lang_txt+'</span>\
4936                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4937                            </a>' + dropdownStr + '\
4938                        </li>\
4939                        '; 
4940                    break;
4941                
4942                case "08" : 
4943                    str = (!def) ? '\
4944                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4945                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4946                                <img src="//storage.googleapis.com/i.addblock.net/flag/flag_'+lang_code.toLowerCase()+'_rec.png" class="cl-lang-img img-responsive"/>\
4947                                <span class="slang-active">'+lang_txt+'</span>\
4948                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4949                            </a>' + dropdownStr + '\
4950                        </div>\
4951                        ' : '\
4952                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4953                            <a href="#" class="cl-lang dropdown-toggle">\
4954                                <img src="//storage.googleapis.com/i.addblock.net/flag/flag_'+lang_code.toLowerCase()+'_rec.png" class="cl-lang-img img-responsive"/>\
4955                                <span class="slang-active">'+lang_txt+'</span>\
4956                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4957                            </a>' + dropdownStr + '\
4958                        </li>\
4959                        '; 
4960                    break;
4961
4962                case "09" : 
4963                    str = (!def) ? '\
4964                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4965                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4966                                <img src="//storage.googleapis.com/i.addblock.net/flag/flag_'+lang_code.toLowerCase()+'_cir.png" class="cl-lang-img img-responsive"/>\
4967                            </a>' + dropdownStr + '\
4968                        </div>\
4969                        ' : '\
4970                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4971                            <a href="#" class="cl-lang dropdown-toggle">\
4972                                <img src="//storage.googleapis.com/i.addblock.net/flag/flag_'+lang_code.toLowerCase()+'_cir.png" class="cl-lang-img img-responsive"/>\
4973                            </a>' + dropdownStr + '\
4974                        </li>\
4975                        '; 
4976                    break;
4977
4978                case "10" : 
4979                    str = (!def) ? '\
4980                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4981                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4982                                <span class="slang-active">'+lang_code+'</span>\
4983                            </a>' + dropdownStr + '\
4984                        </div>' : '\
4985                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4986                            <a href="#" class="cl-lang dropdown-toggle">\
4987                                <span class="slang-active">'+lang_code+'</span>\
4988                            </a>' + dropdownStr + '\
4989                        </li>\
4990                        '; 
4991                    break;
4992
4993                case "11" : 
4994                    str = (!def) ? '\
4995                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4996                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4997                                <img src="//storage.googleapis.com/i.addblock.net/flag/flag_'+lang_code.toLowerCase()+'_rec.png" class="cl-lang-img img-responsive"/>\
4998                            </a>' + dropdownStr + '\
4999                        </div>\
5000                        ' : '\
5001                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
5002                            <a href="#" class="cl-lang dropdown-toggle">\
5003                                <img src="//storage.googleapis.com/i.addblock.net/flag/flag_'+lang_code.toLowerCase()+'_rec.png" class="cl-lang-img img-responsive"/>\
5004                            </a>' + dropdownStr + '\
5005                        </li>\
5006                        '; 
5007                    break;
5008
5009                default : 
5010                    break;
5011            }
5012           
5013            return str;
5014        },
5015        getData : function($h) {
5016            var data = [],
5017                dataFix = ['fixtype','fixlangtype','fh-type','fixsize','fixlangsize','fixtypeText','fixtypeNum','fixlangtypeNum'];
5018                
5019            $.each(dataFix, function(i,v){
5020                var dataV = 'data-'+v;
5021                data[v] = (typeof $h.attr(dataV)!='undefined' && $h.attr(dataV)) ? $h.attr(dataV) : '';
5022                if(data['fixtype']!='undefined' && data['fixtype']) {
5023                    if(v=='fixtypeText') data[v] = data['fixtype'].replace(/\_\d+/gi,'');
5024                    else if(v=='fixtypeNum') data[v] = data['fixtype'].replace(/(top|sidebar)\_/gi,'');  
5025                    else if(v=='fixlangtypeNum') data[v] = data['fixlangtype'].replace(/lang\_/gi,'');
5026                } 
5027                
5028            })
5029
5030            return data;
5031        }
5032    }
5033
5034    /*** shopping Guide Popup ***/
5035    $.guidePopup = {
5036        set: function() {
5037            var str = '\
5038                    <div class="guide-top">\
5039                        <h3 class="modal-title guidetitle">'+$.lang[LANG]['editor.meta.shoppingmall.guide.title']+'</h3>\
5040                        <div class="guide-menu">\
5041                            <ul>\
5042                                <li class="active hand">\
5043                                    <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.1']+'</p>\
5044                                    <div class="line right"></div>\
5045                                </li>\
5046                                <li class="hand">\
5047                                    <div class="line left"></div>\
5048                                    <div class="line right"></div>\
5049                                    <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.2']+'</p>\
5050                                </li>\
5051                                <li class="hand">\
5052                                    <div class="line left"></div>\
5053                                    <div class="line right"></div>\
5054                                    <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.3']+'</p>\
5055                                </li>\
5056                                <li class="hand">\
5057                                    <div class="line left"></div>\
5058                                    <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.4']+'</p>\
5059                                </li>\
5060                            </ul>\
5061                        </div>\
5062                    </div>\
5063                    <div class="guide-wrap">\
5064                        <div class="step">\
5065                            <div id="step1">\
5066                                <h3>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.1.title']+'</h3>\
5067                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.1.1.contents']+'</p>\
5068                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img01_1.jpg">\
5069                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.1.2.contents']+'</p>\
5070                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img01_2.jpg">\
5071                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.1.3.contents']+'</p>\
5072                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img01_3.jpg">\
5073                            </div>\
5074                            <div id="step2">\
5075                                <h3>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.2.title']+'</h3>\
5076                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.2.1.contents']+'</p>\
5077                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img02_1.jpg">\
5078                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.2.2.contents']+'</p>\
5079                                <img src="//storage.googleapis.com/i.addblock.net/guide_img02_2.jpg">\
5080                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.2.3.contents']+'</p>\
5081                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img02_3.jpg">\
5082                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.2.4.contents']+'</p>\
5083                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img02_4.jpg">\
5084                            </div>\
5085                            <div id="step3">\
5086                                <h3>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.3.title']+'</h3>\
5087                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.3.1.contents']+'</p>\
5088                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img03_1.jpg">\
5089                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.3.2.contents']+'</p>\
5090                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img03_2.jpg">\
5091                            </div>\
5092                            <div id="step4">\
5093                                <h3>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.4.title']+'</h3>\
5094                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.4.1.contents']+'</p>\
5095                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img04_1.jpg">\
5096                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.4.2.contents']+'</p>\
5097                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img04_2.jpg">\
5098                            </div>\
5099                        </div>\
5100                        <div class="modal-footer guideClose">\
5101                            <button type="button" class="btn btn-default btn-sm close-button-dialog clostbtnfalse" data-dismiss="modal">닫기</button>\
5102                        </div>\
5103                    </div>\
5104                    ';
5105                                                    
5106            var shopguideModal = $(this).showModalFlat('',str,true,false,'','close','','guidePopup cl-cmmodal cl-s-btn cover w700', false ,'',function() {
5107                $.guidePopup.scrollevent();
5108            });
5109        },
5110        scrollevent : function() {
5111            $('.guidePopup-wrap').on('shown.bs.modal', function(e) {                    
5112                $('.guidePopup .guide-wrap').scroll(function() {
5113                    if($(this).hasClass('moving')) return false;
5114                    var scrollValue = $('.guidePopup .guide-wrap').scrollTop(),
5115                        issclogin = ($('.guidePopup').attr('class').indexOf('sclogin') > 0 || $('.guidePopup').attr('class').indexOf('naverpay-guide') > 0) ? true : false,
5116                        isCert = ($('.guidePopup').attr('class').indexOf('cert-guide-modal') > 0)? true : false;
5117
5118                    if(issclogin || isCert) {
5119                        if( scrollValue >= $("#step2").position().top && scrollValue < $("#step3").position().top) {
5120                            $('.guidePopup ul li:visible').eq(1).addClass('active').siblings().removeClass('active');
5121                            $('.guidePopup ul li:visible').eq(1).css('zIndex', '2').siblings().css('zIndex', '1');
5122                        } else if( scrollValue >= $("#step3").position().top) {
5123                            $('.guidePopup ul li:visible').eq(2).addClass('active').siblings().removeClass('active');
5124                            $('.guidePopup ul li:visible').eq(2).css('zIndex', '2').siblings().css('zIndex', '1');
5125                        } else {
5126                            $('.guidePopup ul li:visible').eq(0).addClass('active').siblings().removeClass('active');
5127                            $('.guidePopup ul li:visible').eq(0).css('zIndex', '2').siblings().css('zIndex', '1');
5128                        }
5129                    } else {
5130                        var hasStep4 = $("#step4").length > 0,
5131                            step4Top = hasStep4 ? $("#step4").position().top : null;
5132
5133                        if( scrollValue >= $("#step2").position().top && scrollValue < $("#step3").position().top) {
5134                            $('.guidePopup ul li').eq(1).addClass('active').siblings().removeClass('active');
5135                            $('.guidePopup ul li').eq(1).css('zIndex', '2').siblings().css('zIndex', '1');
5136                        } else if( scrollValue >= $("#step3").position().top && (!hasStep4 || scrollValue < step4Top)) {
5137                            $('.guidePopup ul li').eq(2).addClass('active').siblings().removeClass('active');
5138                            $('.guidePopup ul li').eq(2).css('zIndex', '2').siblings().css('zIndex', '1');
5139                        } else if(hasStep4 && scrollValue >= step4Top) {
5140                            $('.guidePopup ul li').eq(3).addClass('active').siblings().removeClass('active');
5141                            $('.guidePopup ul li').eq(3).css('zIndex', '2').siblings().css('zIndex', '1');
5142                        } else {
5143                            $('.guidePopup ul li').eq(0).addClass('active').siblings().removeClass('active');
5144                            $('.guidePopup ul li').eq(0).css('zIndex', '2').siblings().css('zIndex', '1');
5145                        }
5146                    }
5147                    
5148                });
5149
5150                $('.guidePopup .guide-menu li').click(function() {
5151                    if($('.guidePopup .guide-wrap').hasClass('moving')) return false;
5152                    var top = ($(this).index())+1,
5153                        $targetStep = $('#step'+top);
5154
5155                    if($targetStep.length === 0) return false;
5156
5157                    $('.guidePopup .guide-wrap').addClass('moving');
5158
5159                    var top_position = (top==1) ? $targetStep.position().top : ($targetStep.position().top)+60;
5160                   
5161                    $('.guidePopup .guide-wrap').animate({scrollTop : top_position}, 1000, 'easeInOutExpo');
5162
5163                    setTimeout(function() {
5164                        $('.guidePopup .guide-wrap').removeClass('moving');
5165                    },1000);
5166
5167                    $(this).addClass('active').siblings().removeClass('active');
5168                    $(this).css('zIndex', '2').siblings().css('zIndex', '1');                    
5169                });
5170            });
5171        }
5172    }
5173
5174    /* Site config - quickmenu ***/    
5175    $.quickmenu = {
5176        init: function(sid,publish,device) {
5177            var result_data = {};
5178            if(PAGE_MODE == 'c' || (PAGE_MODE != 'c' && typeof property != 'undefined')) {
5179                if (PAGE_MODE != 'c' && typeof property != 'undefined' && property && property.QUICKMENU) {
5180                    result_data = property.QUICKMENU;
5181                } else if (typeof QUICKMENU !== 'undefined' && QUICKMENU) {
5182                    result_data = QUICKMENU;
5183                } else {
5184                    result_data = {};
5185                }
5186            }
5187
5188            $.quickmenu['quickmenu'] = result_data || {};
5189            if (Array.isArray($.quickmenu['quickmenu']['visible']) && $.quickmenu['quickmenu']['visible'].length > 0) {
5190                $.quickmenu['quickmenu']['visible'] = $.quickmenu['quickmenu']['visible'].slice();
5191            } else {
5192                $.quickmenu['quickmenu']['visible'] = [];
5193            }
5194
5195            var quickmenu_total_count = parseInt(result_data['total_count'], 10) || 0;
5196
5197            if(quickmenu_total_count!=0) $.quickmenu.setHTML(result_data,device);
5198            else {
5199                result_data = $.quickmenu.add(sid, false) || $.quickmenu['quickmenu'] || result_data;
5200                $.quickmenu.setHTML(result_data,device);
5201            }         
5202        },
5203        get: function(sid,publish) {
5204            var return_data = {};
5205            $.ajax({
5206                type: 'POST',
5207                data: { sid:sid, publish:publish },
5208                dataType: 'json',
5209                url: (CONFIG_URL) ? '/_config/siteConfig/btype/quickmenu/type/get' : '/config/siteConfig/btype/quickmenu/type/get',   
5210                async:false,
5211                success : function(data) {                    
5212                    checkError(data);                 
5213                    return_data = data;
5214                    $.quickmenu['quickmenu'] = return_data;
5215                    if(!Array.isArray($.quickmenu['quickmenu']['visible'])) $.quickmenu['quickmenu']['visible'] = [];
5216                },
5217                error: function(request, status, error){
5218                    console.log("data error");
5219                    
5220                }
5221            }); 
5222
5223            return return_data;
5224        },
5225        setHTML: function(data,device,checkConfig) {
5226            data = data || {};
5227            if(typeof data['sid'] == 'undefined' || !data['sid']) data['sid'] = (typeof SID != 'undefined') ? SID : '';
5228            if(typeof data['list'] == 'undefined' || !data['list']) data['list'] = {};
5229            if(typeof data['img_type'] == 'undefined' || !data['img_type']) data['img_type'] = {};
5230            if(typeof data['img_type_mode'] == 'undefined' || !data['img_type_mode']) data['img_type_mode'] = {};
5231            if(typeof data['img_type'][device] == 'undefined' || !data['img_type'][device]) data['img_type'][device] = (device=='pc') ? 'default' : 'bottom_default';
5232            if(typeof data['total'] == 'undefined' || !data['total']) data['total'] = {};
5233
5234            var site_settings = (typeof property != 'undefined') ? property.SETTINGS : SETTINGS,
5235                quick_hide = (typeof site_settings.qm_onoff != 'undefined' && site_settings.qm_onoff==true) ? '' : 'hide',
5236                quick_str = '',
5237                quick_style = `<style id="quick-menu-${data['sid']}${device}"></style>`,
5238                quick_css = '',
5239                qm_list = {};
5240
5241            qm_list = data['list'];         
5242            var img_type = data['img_type'][device],
5243                img_type_mode = (data['img_type_mode'][device] == 'mixed') ? 'mixed' : 'single',
5244                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))),
5245                render_img_types = [],
5246                img_type_total = ($.isEmptyObject(data['total']) || typeof data['total'][device] == 'undefined' || typeof data['total'][device][img_type] == 'undefined') ? {} : data['total'][device][img_type],
5247                m_icon_settings = [],
5248                link = {},
5249                page_mode = (PAGE_MODE=='c') ? 'c' : '';
5250
5251            var parseQuickmenuSetting = function(setting, fallback) {
5252                var base = $.extend({}, fallback);
5253
5254                if(typeof setting == 'object' && setting) return $.extend(base, setting);
5255                if(typeof setting == 'string' && setting) {
5256                    try {
5257                        return $.extend(base, JSON.parse(setting));
5258                    } catch(e) {
5259                        return base;
5260                    }
5261                }
5262
5263                return base;
5264            };
5265
5266            var getQuickmenuImageValue = function(item, key, current_img_type) {
5267                if(typeof item[key] == 'object' && item[key]) return item[key][current_img_type] || '';
5268                if(typeof item[key] == 'string') return item[key];
5269
5270                return '';
5271            };
5272
5273            var default_icon_settings = {
5274                'onoff': 'true',
5275                '--icon-size': '24px',
5276                '--icon-color': '#000000',
5277                '--icon-bgcolor': '',
5278                '--icon-bgblur': '3px'
5279            };
5280            var default_text_settings = {
5281                'onoff': 'true',
5282                '--text-fname': 'Noto Sans',
5283                '--text-fsize': '12px',
5284                '--text-fweight': '400',
5285                '--text-fcolor': '#000000'
5286            };
5287            var getQuickmenuEffectiveVisible = function(render_img_type, visible) {
5288                if(!is_mixed_img_type && device=='pc' && (img_type=='default' || img_type=='image') && render_img_type!=img_type) return 0;
5289                if(!is_mixed_img_type && device=='mobile' && typeof img_type == 'string' && img_type.indexOf('right_') === 0 && render_img_type!=img_type) return 0;
5290
5291                return visible;
5292            };
5293
5294            var getQuickmenuImageSizeMode = function(render_img_type, icon_settings) {
5295                if(render_img_type.indexOf('image') < 0) return 'common';
5296                if(icon_settings && (icon_settings['quick_img_size_mode']=='common' || icon_settings['quick_img_size_mode']=='origin')) return icon_settings['quick_img_size_mode'];
5297
5298                return 'origin';
5299            };
5300
5301            var getQuickmenuSharedQuickSettings = function(render_img_type) {
5302                var shared_key = '',
5303                    shared_settings = {},
5304                    has_shared_settings = false;
5305
5306                if(device=='pc' && (render_img_type=='default' || render_img_type=='image')) shared_key = 'common';
5307                else if(device=='mobile' && (render_img_type=='right_default' || render_img_type=='right_image')) shared_key = 'right_common';
5308
5309                if(shared_key && qm_list[device] && qm_list[device][shared_key] && qm_list[device][shared_key]['quick_settings']) {
5310                    shared_settings = $.extend({}, qm_list[device][shared_key]['quick_settings']);
5311                    has_shared_settings = true;
5312                } else if(qm_list[device] && qm_list[device][img_type] && qm_list[device][img_type]['quick_settings']) {
5313                    shared_settings = $.extend({}, qm_list[device][img_type]['quick_settings']);
5314                }
5315
5316                if(device=='mobile' && (render_img_type=='right_default' || render_img_type=='right_image') && (!has_shared_settings || typeof shared_settings['--quick-align'] == 'undefined')) {
5317                    shared_settings['--quick-align'] = 'center';
5318                }
5319
5320                return shared_settings;
5321            };
5322
5323            var getQuickmenuRenderTypeOrder = function(render_img_type) {
5324                if(!is_mixed_img_type) return 0;
5325                if(render_img_type==img_type) return 0;
5326
5327                if(device=='pc' && (render_img_type=='default' || render_img_type=='image')) return 1;
5328                if(device=='mobile' && (render_img_type=='right_default' || render_img_type=='right_image')) return 1;
5329
5330                return 2;
5331            };
5332
5333            if(device=='pc') {
5334                $.each(['default', 'image'], function(i, pc_img_type) {
5335                    if(typeof qm_list[device] != 'undefined' && typeof qm_list[device][pc_img_type] != 'undefined') render_img_types.push(pc_img_type);
5336                });
5337            } else if(device=='mobile' && typeof img_type == 'string' && img_type.indexOf('right_') === 0) {
5338                $.each(['right_default', 'right_image'], function(i, right_img_type) {
5339                    if(typeof qm_list[device] != 'undefined' && typeof qm_list[device][right_img_type] != 'undefined') render_img_types.push(right_img_type);
5340                });
5341		            }
5342		            if(render_img_types.length < 1) render_img_types.push(img_type);
5343		            var has_render_image_type = false;
5344		            $.each(render_img_types, function(render_i, render_img_type) {
5345		                if(render_img_type.indexOf('image') > -1) {
5346		                    has_render_image_type = true;
5347		                    return false;
5348		                }
5349		            });
5350		            if(has_render_image_type) {
5351		                quick_css += `
5352		                    .quick-menu-${data['sid']}.quickmenu[data-device='${device}'][data-imgtype='${img_type}'] ul {align-items: center;}
5353		                    .quick-menu-${data['sid']}.quickmenu[data-device='${device}'][data-imgtype='${img_type}'] ul > li {align-self: var(--quick-align, center);}
5354		                `;
5355		            }
5356		            var render_items = [];
5357
5358	            $.each(render_img_types, function(render_i, render_img_type) {
5359	                if(typeof qm_list[device] == 'undefined' || typeof qm_list[device][render_img_type] == 'undefined') return true;
5360
5361	                if(typeof qm_list[device][render_img_type]['quick_settings'] == 'undefined' || !qm_list[device][render_img_type]['quick_settings']) {
5362	                    qm_list[device][render_img_type]['quick_settings'] = {};
5363	                }
5364	                qm_list[device][render_img_type]['quick_settings'] = $.extend({}, qm_list[device][render_img_type]['quick_settings']);
5365
5366	                $.each(qm_list[device][render_img_type], function(i,v){
5367	                    if(i=='quick_settings') {
5368	                        var quick_settings_css = $.extend({}, v, getQuickmenuSharedQuickSettings(render_img_type)),
5369	                            quick_size = parseFloat(String(quick_settings_css['--quick-size'] || '').replace(/[^0-9.]/g, '')),
5370	                            quick_roundedge_per = parseFloat(quick_settings_css['--quick-roundedge-per']);
5371
5372	                        if(!isNaN(quick_size) && !isNaN(quick_roundedge_per)) {
5373	                            quick_settings_css['--quick-roundedge-radius'] = Math.round(quick_size * quick_roundedge_per) + 'px';
5374	                        }
5375
5376	                        v_quick_settings = JSON.stringify(quick_settings_css).replace(/\"/gi,'').replace(/px/gi,'px;').replace(/,|;;/gi,';');
5377	                        quick_css += `.quick-menu-${data['sid']}[data-device='${device}'] li[data-imgtype='${render_img_type}'] ${v_quick_settings}`;
5378
5379	                        return true;
5380	                    }
5381
5382	                    render_items.push({
5383	                        'img_type': render_img_type,
5384	                        'index': i,
5385	                        'val': v
5386	                    });
5387	                });
5388		            });
5389
5390		            var has_duplicate_pos = false,
5391		                seen_pos = {};
5392		            $.each(render_items, function(i, render_item) {
5393		                var item_pos = parseInt(render_item.val.pos, 10);
5394		                if(isNaN(item_pos)) return true;
5395		                if(seen_pos[item_pos]) {
5396		                    has_duplicate_pos = true;
5397		                    return false;
5398		                }
5399		                seen_pos[item_pos] = true;
5400		            });
5401
5402		            render_items.sort(function(a, b) {
5403		                var a_type_order = getQuickmenuRenderTypeOrder(a.img_type),
5404		                    b_type_order = getQuickmenuRenderTypeOrder(b.img_type),
5405		                    a_seq = parseInt(a.val.seq, 10),
5406		                    b_seq = parseInt(b.val.seq, 10);
5407		                var a_pos = parseInt(a.val.pos, 10),
5408		                    b_pos = parseInt(b.val.pos, 10);
5409
5410		                if(has_duplicate_pos && a_type_order != b_type_order) return a_type_order - b_type_order;
5411		                if(!isNaN(a_pos) && !isNaN(b_pos) && a_pos != b_pos) return a_pos - b_pos;
5412		                if(!has_duplicate_pos && a_type_order != b_type_order) return a_type_order - b_type_order;
5413		                if(!isNaN(a_seq) && !isNaN(b_seq) && a_seq != b_seq) return a_seq - b_seq;
5414
5415		                return 0;
5416		            });
5417
5418	            quick_str = `
5419	                <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}">
5420	                    <ul>`
5421	                    $.each(render_items, function(render_i, render_item) {
5422	                        var render_img_type = render_item.img_type,
5423	                            i = render_item.index,
5424	                            v = render_item.val,
5425	                            link_option_str = '';
5426	                        link = $.quickmenu.setLink(v['link'],v['link_target']);
5427                      
5428                        if(!$.isEmptyObject(link['option'])) link_option_str = `${link['option']['type']}="${link['option']['val']}"`;
5429                      
5430                        v['icon_settings'] = parseQuickmenuSetting(v['icon_settings'], default_icon_settings);
5431                        v['text_settings'] = parseQuickmenuSetting(v['text_settings'], default_text_settings);
5432
5433                        if(render_img_type.indexOf('default') > -1 && device=='mobile') m_icon_settings.push(String(v['icon_settings']['--icon-size'] || '24px').replace(/px/gi,''));
5434                       
5435                        var v_img_key = (device=='pc') ? 'img' : 'img2',
5436                            v_img_width_key = (device=='pc') ? 'img_width' : 'img2_width',
5437                            v_img_height_key = (device=='pc') ? 'img_height' : 'img2_height';
5438
5439                        var quick_settings = JSON.stringify(qm_list[device][render_img_type]['quick_settings']),
5440                            v_img = htmlspecialchars_decode(getQuickmenuImageValue(v, v_img_key, render_img_type), 'ENT_QUOTES'),
5441                            v_noimage = (v_img.indexOf('quickmenu-noimage') > -1) ? 'quickmenu-noimage' : '',
5442                            val_br_text = v['text'],
5443                            v_img_width = (v_noimage) ? ((device=='mobile' && render_img_type=='right_image') ? 64 : 72) : parseFloat(v[v_img_width_key]),
5444                            v_img_height = (v_noimage) ? ((device=='mobile' && render_img_type=='right_image') ? 64 : 72) : parseFloat(v[v_img_height_key]),
5445                            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',
5446                            v_img_size_mode = getQuickmenuImageSizeMode(render_img_type, v['icon_settings']),
5447                            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;` : '',
5448                            v_bgblur = v['icon_settings']['--icon-bgblur'] || '3px',
5449                            render_visible = getQuickmenuEffectiveVisible(render_img_type, v['visible']);
5450
5451                        if(render_img_type.indexOf('default') > -1 && typeof isQuickmenuMaterialIconHtml == 'function' && isQuickmenuMaterialIconHtml(v_img)) {
5452                            var v_material_settings = (typeof getQuickmenuMaterialSettings == 'function') ? getQuickmenuMaterialSettings(v['icon_settings'], v_img) : {};
5453                            v['icon_settings'] = $.extend(v['icon_settings'], {
5454                                'material_style': v_material_settings.style || 'outlined',
5455                                '--material-icon-fill': v_material_settings.fill || '0',
5456                                '--material-icon-weight': v_material_settings.weight || '400',
5457                                '--material-icon-grade': v_material_settings.grade || '0',
5458                                '--material-icon-optical-size': v_material_settings.opticalSize || '24'
5459                            });
5460                            if(typeof updateQuickmenuMaterialIconHtml == 'function') v_img = updateQuickmenuMaterialIconHtml(v_img, v['icon_settings']);
5461                        }
5462
5463                        // if(v['text'].indexOf('br') > -1) {
5464                        //     var brRegex = /<br\s*\/?>/gi;
5465                        //     val_text_array = v['text'].split(brRegex);
5466                        //     val_br_text = `${val_text_array[0]}<br />${val_text_array[1]}<br />${val_text_array[2]}`;
5467                        // }
5468
5469                        
5470
5471                            quick_str += `
5472                        <li class="quickmenu-box${(String(render_visible)=="0") ? ' hide' : ''} ${v_noimage}" data-id="${v['seq']}" data-pos="${v['pos']}" data-imgtype="${render_img_type}">
5473                            <a class="quickmenu-alink" href="${link['link']}" target="${link['target']}" ${link_option_str}>
5474                                `;
5475	                    quick_str += (render_img_type.indexOf('default') > -1) ? ((device=='mobile' && render_img_type=='right_default') ? `
5476	                                <span class="quickmenu-default-content">
5477	                                    <span class="quickmenu-icon ${(v['icon_settings']['onoff']=="false") ? 'hide ' : ''}">${v_img}</span>
5478	                                    <span class="quickmenu-text ${(v['text_settings']['onoff']=="false") ? 'hide ' : ''}">${val_br_text}</span>
5479	                                </span>` : `
5480	                                <span class="quickmenu-icon ${(v['icon_settings']['onoff']=="false") ? 'hide ' : ''}">${v_img}</span>
5481	                                <span class="quickmenu-text ${(v['text_settings']['onoff']=="false") ? 'hide ' : ''}">${val_br_text}</span>`)
5482	                                : ((v_img.indexOf('quickmenu-noimage') >
5482 -1) ? `<span class="quickmenu-noimage">${v_img}</span>` : `<img class="quickmenu-img" src="${v_img}"/>`)
5483                    quick_str += `</a>
5484                        </li>
5485	                        `;
5486
5487	                    quick_css += (render_img_type.indexOf('default') > -1) ? `
5488                            .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'};}
5489                            .quick-menu-${data['sid']}[data-device='${device}'] li[data-id='${v['seq']}'] a {--icon-size: ${v['icon_settings']['--icon-size']};}
5490                            .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']};}
5491                            .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};}
5492                            .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']};}
5493                            .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;}
5494                            .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;}
5495                            .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;}
5496                            .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;}
5497                            .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;}
5498                            .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;}
5499	                        ` : `
5500                            .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}}
5501                            .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;}
5502                        `;
5503	                    });
5504
5505	                    // quick_css += (img_type.indexOf('default') > -1 && device=='mobile') ? `
5506                    //     .quick-menu-${data['sid']}.quickmenu[data-imgtype="bottom_default"][data-device='mobile'] {--order-nav: ${Object.keys(img_type_total).length};}` : '';
5507                    quick_str += `</ul>`;
5508
5509                //quick_str += (device == 'pc') ? '' : `<div class="bg-nowrap-btn next"></div>`;
5510                quick_str +=  `</div>`;
5511                
5512
5513            var selector = (device=='pc') ? '' : ' .quickmenu_viewer',
5514                screen_device = ($('body').width() > 768) ? 'pc' : 'mobile';
5515
5516            $(`style#quick-menu-${data['sid']}${device}`).remove();
5517
5518
5519            $('body').prepend($(quick_style).prop('outerHTML'));    
5520            $(`#quick-menu-${data['sid']}${device}`).append(quick_css);              
5521            $(`.sc-quickmenu${selector} .quick-menu-${data['sid']}`).remove();            
5522
5523            $(`.sc-quickmenu${selector}`).append(quick_str);
5524
5525            if(checkConfig !='c' || device == screen_device) {
5526                $(`.el-footer`).siblings(`.quick-menu-${data['sid']}`).remove();         
5527                $('.el-footer').after(quick_str);
5528                $(`.el-footer`).siblings(`.quick-menu-${data['sid']}`).removeClass('non_config').addClass('non_config');
5529                
5530                
5531                if(PAGE_MODE=='c') {
5532                    $('.quickmenu-hover-buffer').remove();
5533                    $('.el_quickmenu_ctrl').remove();
5534                    $(`.quick-menu-${data['sid']}`).before('<div class="quickmenu-hover-buffer"></div>');
5535                    $('.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>`);
5536                
5537                    updateQuickmenuHoverBuffer();
5538                }
5539            } 
5540            
5541            setTimeout(() => {
5542                if(device=='mobile' && img_type=='bottom_default') {
5543                    var mobile_bottom_height = $(`.quick-menu-${data['sid']}.quickmenu[data-device="mobile"] ul`).height(),
5544                        body_width = (checkConfig !='c' || device == screen_device) ? $('body').width() : 279,
5545                        quick_li_width = 0;
5546  
5547                    $.each($(`.quick-menu-${data['sid']}.quickmenu[data-device="mobile"] ul li`), function(s,q) {
5548                        quick_li_width += $(this).innerWidth();
5549                    })
5550                    
5551                    if(quick_li_width <= body_width) {
5552                        $('.bg-nowrap-btn').remove();
5553                        $(`.quick-menu-${data['sid']}.quickmenu[data-device="mobile"]`).removeClass('width100').addClass('width100');
5554                    } else {
5555                        $(`.quick-menu-${data['sid']}.quickmenu[data-device="mobile"]`).append('<div class="bg-nowrap-btn"></div>');
5556                        $(`.quick-menu-${data['sid']}.quickmenu[data-device="mobile"]`).find('.bg-nowrap-btn').css('height',mobile_bottom_height);
5557                    }
5558                }
5559            }, 500);
5560            
5561                       
5562        },
5563        setLink: function(org_link,org_ltarget) {
5564            var link = (typeof org_link == 'string' && org_link != 'javascript:;' && org_link.length > 0) ? org_link : 'javascript:;',
5565                link_target = (typeof org_ltarget != 'undefined' && (org_ltarget == '1' || org_ltarget == 'ON')) ? '_blank' : '',
5566                link_option = {};
5567
5568            // Keep previously saved phone links usable even when an empty last
5569            // input caused the old editor to append a trailing hyphen.
5570            if(/^tel:/i.test(link)) link = link.replace(/-+$/g, '');
5571
5572            if(link != '' && link != 'javascript:;') {
5573                var _menuList = (PAGE_MODE == 'c') ? MENULIST : property.MENULIST;
5574            
5575                if(link.match(/^\@/g) !== null) {                                                  // link-type: link-bookmark ==> a[attr-bookmark]
5576                    var _settings = (PAGE_MODE == 'c') ? SETTINGS : property.SETTINGS,
5577                        bookmark_seq = link.replace(/^\@/g,'');
5578                        
5579                    if(typeof _settings == 'undefined' || typeof _settings.blockBookmarkList == 'undefined' || _settings.blockBookmarkList['bookmark' + bookmark_seq] == 'undefined') {
5580                        link = '';
5581                        link_option = {};
5582                    } else {
5583                        link_option = {
5584                            'type' : 'attr-bookmark',
5585                            'val' : bookmark_seq
5586                        }
5587                    }
5588                } else if(link.match(/^flink\@[0-9]/gi) !== null) {           
5589                    link_option = {
5590                        'type' : 'attr-flink',
5591                        'val' : link.replace(/^flink\@/gi,'')
5592                    }                     // link-type: link-file     ==> a[attr-flink]                   
5593                    link_target = '';
5594                } else if(_menuList.indexOf(link.replace(/^\//g,"").replace(/ /g,"-")) > -1) {     // link-type: link-menu     ==> a[data-user-link]
5595                    link_option = {
5596                        'type' : 'data-user-link',
5597                        'val' : link
5598                    }
5599                } else {   
5600                    link_option = {
5601                        'type' : 'attr-link',
5602                        'val' : link
5603                    }                                                                         // link-type: link-out      ==> a[attr-link]
5604                }
5605
5606                link = (PAGE_MODE == 'c') ? makeLinkUrl(link, ONE, VIEW) : makeLinkUrl(link, property.ONE, property.VIEW);
5607            }
5608         
5609            return {'link':link, 'target':link_target, 'option':link_option};
5610        },
5611        getCss: function(sid, device) {
5612            let quickmenuCss;
5613
5614            var quick_css = ($(`#quick-menu-${sid}${device}`).text()) ? $(`#quick-menu-${sid}${device}`).text().trim() : '';
5615            quickmenuCss = CSSJSON.toJSON(quick_css);
5616
5617            return quickmenuCss;
5618        },
5619        add: function(sid, publish) {
5620            var return_data = {};
5621
5622            $.ajax({
5623                type: 'POST',
5624                data: { sid:sid, publish:publish, data: $.quickmenu['quickmenu'], sample: true},
5625                dataType: 'json',
5626                url: (CONFIG_URL) ? '/_config/siteConfig/btype/quickmenu/type/add' : '/config/siteConfig/btype/quickmenu/type/add',
5627                async:false,
5628                success : function(data) {
5629                    checkError(data);
5630                    return_data = data;
5631                    $.quickmenu['quickmenu'] = return_data;
5632                },
5633                error: function(request, status, error){
5634                    console.log(error);
5635                    console.log("data error");
5636                }
5637            });
5638
5639            return return_data;
5640        },
5641        getSetting: function(tag) {
5642            var data_obj = $(tag).data(),
5643                obj_etc = ['link','target','visible','name','imgtype'],
5644                settings_obj = {};
5645
5646            $.each(data_obj, function(i,v){
5647                var key_icon = (obj_etc.includes(i)) ? i : `--icon-${i}`;
5648                settings_obj[key_icon] = v;
5649            });
5650
5651            return settings_obj;
5652        },
5653        setCss: function(sid, device, seq, target, css_val, img_type) {
5654            var quick_imgtype = (typeof img_type != 'undefined' && img_type) ? img_type : $.quickmenu['quickmenu']['img_type'][device];
5655
5656            if(target=='quick_settings') $.quickmenu['quickmenu']['list'][device][quick_imgtype]['quick_settings'] = css_val;
5657            else $.quickmenu['quickmenu']['list'][device][quick_imgtype][seq][target] = css_val;
5658        }
5659    }
5660
5661    $.siteBanner = {
5662        checkOffer: function(type) {
5663            // console.log(`$.siteBanner.checkOffer(type ${type})`);
5664            var checkPlan = (typeof VALIDPLAN == 'undefined') ? property.VALIDPLAN : VALIDPLAN,
5665                checkPlanType = (typeof VALIDTYPE == 'undefined') ? property.VALIDTYPE : VALIDTYPE;
5666            if(!checkPlan || checkPlanType == 'PK') {
5667                return false;
5668            }
5669
5670            var site_settings = (typeof property != 'undefined') ? property.SETTINGS : SETTINGS
5671            $.siteBanner.sid = (typeof property != 'undefined') ? property.SID : SID;
5672            if(typeof $.siteBanner.sid == 'undefined' || !$.siteBanner.sid || typeof site_settings == 'undefined' || !site_settings) {
5673                return false;
5674            }
5675
5676            if(type == 'popup') {
5677                if(site_settings.SITELOCK) return false;
5678
5679                var tmp_view = (PAGE_MODE == 'c') ? VIEW : ((typeof property != 'undefined') ? property.VIEW : ''),
5680                    tmp_one = (PAGE_MODE == 'c') ? ONE : ((typeof property != 'undefined') ? property.ONE : ''),
5681                    tmp_page  = (PAGE_MODE == 'c') ? PAGE : ((typeof property != 'undefined') ? property.PAGE : ''),
5682                    tmp_menu  = (PAGE_MODE == 'c') ? MENULINK[0] : ((typeof property != 'undefined') ? property.MENULINK[0] : ''),
5683                    tmp_clpage = ($('div:is(.element.cl-s-page, .psearch-view)').length > 0) ? true : false,
5684                    checkFirstPage = (!tmp_view && !tmp_clpage && (tmp_one || !tmp_one && tmp_page == tmp_menu)) ? true : false;
5685
5686                if(!checkFirstPage) return false;
5687            }
5688
5689            return true;
5690        },
5691        getBannerCookieName: function(type, id, viewType) {
5692            var bannerName = $.siteBanner.sid + (type.charAt(0).toUpperCase() + type.slice(1)) + 'Banner';
5693            if(type == 'band' || (type == 'popup' && viewType == 'slide')) return bannerName;
5694            return bannerName + id;
5695        },
5696	        clearCloseCookie: function(type) {
5697	            // console.log(`$.siteBanner.clearCloseCookie(type ${type})`);
5698	            var isBoth = (typeof type == 'undefined') ? true : false,
5699	                isBand = (isBoth || !isBoth && type == 'band') ? true : false,
5700	                isPopup = (isBoth || !isBoth && type == 'popup') ? true : false;
5701
5702            if(isBand) {
5703                var band_id = $.siteBanner.sid + 'BandBanner';
5704                $.removeCookie(band_id, { path : '/' });
5705            }
5706            if(isPopup) {
5707                var popup_name = $.siteBanner.sid + 'PopupBanner';
5708                $.removeCookie(popup_name, { path : '/' });
5709                if(typeof $.siteBanner.popup != 'undefined' && typeof $.siteBanner.popup.list != 'undefined') {
5710                    $.each($.siteBanner.popup.list, function(id,o) {
5711                        var popup_id = $.siteBanner.sid + 'PopupBanner' + id;
5712                        $.removeCookie(popup_id, { path : '/' });
5713                    });
5714	                }
5715	            }
5716	        },
5717	        getCssColorValue: function(color, fallback) {
5718	            color = color || fallback || '#000000';
5719	            if(typeof Coloris != 'undefined' && typeof Coloris.getColorRegex == 'function' && Coloris.getColorRegex().test(color)) {
5720	                return Coloris.getColorInfo(color, 'rgba');
5721	            }
5722
5723	            return color;
5724	        },
5725	        doNotOffer: function(type,isSC) {
5726	            // console.log(`[siteBanner_step_END (off) /5] $.siteBanner.doNotOffer(type ${type},isSC ${isSC})`);
5727	            if(isSC) $.siteBanner.clearCloseCookie(type);
5728
5729            var isBoth = (typeof type == 'undefined') ? true : false,
5730                isBand = (isBoth || !isBoth && type == 'band') ? true : false,
5731                isPopup = (isBoth || !isBoth && type == 'popup') ? true : false;
5732
5733            if(isBand) {
5734                $.siteBanner.stopBandRolling();
5735
5736                $('body, .cl-bandBanner').removeClass('openBandBanner');
5737                $('.cl-bandBanner, .el-menu_ctrl, .header.el-menu > header').removeInlineCss('margin-top');
5738                document.querySelector('body').style.setProperty('--bandBanner-height-pc', null, null);
5739                document.querySelector('body').style.setProperty('--bandBanner-height-mobile', null, null);
5740                if($('.dsgn-body').hasClass('sidebar')) $('.dsgn-body').removeInlineCss('padding-top');
5741                $('.cl-bandBanner').remove();
5742                $('.element[data-type="gallery"][data-type2="premium"]').refreshRootCss();
5743
5744                $.fheader.position();
5745                $.clnav.setRootcss();
5746            }
5747            if(isPopup) {
5748                $.siteBanner.stopPopupSlideRolling();
5749                $('body, .cl-popupBanner').removeClass('openPopupBanner');
5750                $('.cl-popupBanner').remove();
5751            }
5752        },
5753        init: function(checkBand,checkPopup) {
5754            // console.log(`[siteBanner_step_1 /5] $.siteBanner.init(checkBand ${checkBand},checkPopup ${checkPopup})`);
5755
5756            if(checkBand) $.siteBanner.call('band',false,true,true,true);
5757            if(checkPopup) $.siteBanner.call('popup',false,true,true,true);
5758
5759            if(typeof property == 'undefined') {
5760                $(document).on('mouseenter', '.cl-bandBanner, .cl-popupBanner', function() {
5761                    if(isEDIT) return;
5762                    else outElementButtonDisplay();
5763                });
5764            }
5765
5766            $(document).on('mouseenter', '.cl-bandBanner', function() {
5767                $.siteBanner.band.paused = true;
5768            }).on('mouseleave', '.cl-bandBanner', function() {
5769                $.siteBanner.band.paused = false;
5770            });
5771
5772            $(document).off('click', '.cl-bandBanner .banner-body > a, .cl-popupBanner .banner-body > a')
5773                       .on('click', '.cl-bandBanner .banner-body > a, .cl-popupBanner .banner-body > a', function() {
5774                if($(this).is('[href="javascript:;"]') || $(this).hasClass('clicked')) return false;
5775                var $clicked = $(this);
5776                $clicked.addClass('clicked');
5777
5778                setTimeout(function() {
5779                    $clicked.removeClass('clicked');
5780                }, 3000);
5781            });
5782
5783            $(document).on('click','.cl-bandBanner .banner-closetoday,\
5784                                    .cl-bandBanner .banner-close,\
5785                                    .cl-popupBanner .banner-closetoday,\
5786                                    .cl-popupBanner .banner-close', function() {
5787	                var bannerEL = $(this).closest('.banner-box'),
5788	                    banner_id = bannerEL.attr('id'),
5789	                    banner_type = bannerEL.attr('data-type'),
5790	                    banner_closetime = bannerEL.attr('data-closetime'),
5791	                    clickBtn = $(this),
5792	                    isCloseToday = $(this).is('.banner-closetoday'),
5793	                    banner_render_view_type = (banner_type == 'popup' && typeof $.siteBanner.popup != 'undefined') ? ($.siteBanner.popup.render_view_type || $.siteBanner.popup.view_type || 'individual') : '',
5794	                    date = new Date();
5795                if(banner_type == 'band' && !clickBtn.closest('.banner-header').find('.banner-closetoday').hasClass('hide')) isCloseToday = true;
5796
5797                var time_val = {
5798                    'always'    : 0,
5799                    'onlyone'   : 365 * 24 * 60 * 60 * 1000,
5800                    'week'      : 7 * 24 * 60 * 60 * 1000, 
5801                    'day'       : 24 * 60 * 60 * 1000, 
5802                    '12hours'    : 12 * 60 * 60 * 1000, 
5803                    '6hours'     : 6 * 60 * 60 * 1000, 
5804                    '2hours'     : 2 * 60 * 60 * 1000, 
5805                    '1hours'     : 60 * 60 * 1000, 
5806                    '30min'     : 30 * 60 * 1000, 
5807                    '10min'     : 10 * 60 * 1000, 
5808                    '3min'      : 3 * 60 * 1000,
5809                };
5810
5811                if(isCloseToday) date.setTime(date.getTime() + time_val['day']);
5812                else date.setTime(date.getTime() + time_val[banner_closetime]);
5813
5814                if(banner_type == 'band') {
5815                    $.siteBanner.stopBandRolling();
5816                    banner_id = banner_id.replace(/BandBanner[0-9]+$/,'BandBanner');
5817                }
5818
5819		                if(banner_type == 'popup' && banner_render_view_type == 'slide') {
5820	                    var $popupModal = clickBtn.closest('.banner-modal'),
5821	                        $popupBanner = clickBtn.closest('.cl-popupBanner'),
5822	                        $popupItems = $popupModal.find('> ul > li.banner-box:not(.hide)'),
5823	                        popupTotal = $popupItems.length;
5824
5825	                    $.siteBanner.stopPopupSlideRolling('.cl-popupBanner');
5826	                    $popupItems.addClass('hide');
5827	                    $popupModal.find('.banner-slide-arrow').addClass('hide');
5828	                    $popupModal.find('.banner-slide-pagination').addClass('hide').empty();
5829	                    $popupBanner.removeClass('openPopupBanner').addClass('hide');
5830	                    $('body').removeClass('openPopupBanner');
5831
5832	                    if(isCloseToday || (typeof banner_closetime != 'undefined' && banner_closetime != 'always' && banner_closetime != '')) {
5833	                        $.cookie($.siteBanner.getBannerCookieName('popup', '', 'slide'), true, { path: '/', expires: date});
5834	                    }
5835
5836	                    $.siteBanner.popup.total = Math.max(Number($.siteBanner.popup.total || popupTotal) - popupTotal, 0);
5837	                    return;
5838	                }
5839
5840	                $('#'+banner_id).addClass('hide');
5841	                if(isCloseToday || (typeof banner_closetime != 'undefined' && banner_closetime != 'always' && banner_closetime != '')) {
5842	                    $.cookie(banner_id, true, { path: '/', expires: date});
5843	                }
5844	                $.siteBanner[banner_type].total--;
5845	                if(banner_type == 'popup') {
5846	                    var $popupBanner = clickBtn.closest('.cl-popupBanner'),
5847	                        popupRemain = $popupBanner.find('> .banner-modal > ul > li.banner-box:not(.hide)').length;
5848
5849	                    if(popupRemain < 1 || $.siteBanner.popup.total < 1) {
5850	                        $popupBanner.removeClass('openPopupBanner').addClass('hide');
5851	                        $('body').removeClass('openPopupBanner');
5852	                    }
5853	                }
5854	                if(banner_type == 'band') {
5855	                    $.siteBanner.band.used = false;
5856	                    $.siteBanner.call('band',false,false,true,true);
5857	                }
5858            });
5859	        },
5860
5861	        isPopupSlidePublishableItem: function(item) {
5862	            var period = null,
5863	                periodChk = false,
5864	                periodLabel = '';
5865
5866	            if(!item || item.visible != 'ON') return false;
5867
5868	            period = item.period || {};
5869	            periodChk = (period.chk === true || period.chk == 1 || period.chk == '1');
5870	            periodLabel = String(period.label || '');
5871	            if(!periodChk && (period.visible === false || period.visible == 'false' || periodLabel !== '')) return false;
5872
5873	            return true;
5874	        },
5875
5876	        getPopupRenderableViewType: function(type) {
5877	            var viewType = (type == 'popup' && typeof $.siteBanner[type] != 'undefined') ? ($.siteBanner[type].view_type || 'individual') : 'individual',
5878	                count = 0,
5879	                list = (type == 'popup' && $.siteBanner[type]) ? $.siteBanner[type].list : null,
5880	                sort = (type == 'popup' && $.siteBanner[type]) ? $.siteBanner[type].sort : null;
5881
5882	            if(type != 'popup' || viewType != 'slide' || !list || !sort || typeof sort.length == 'undefined') return viewType;
5883
5884	            $.each(sort, function(idx, id) {
5885	                var item = list[id];
5886
5887	                if(!$.siteBanner.isPopupSlidePublishableItem(item)) return true;
5888	                count++;
5889	            });
5890
5891	            return (count > 1) ? viewType : 'individual';
5892	        },
5893
5894		        call: function(type,isSC,isGet,isSet,isPosition) {
5895	            // console.log(`[siteBanner_step_2 /5] $.siteBanner.call(type ${type}, isSC ${isSC}, isGet ${isGet}, isSet ${isSet}, isPosition ${isPosition})`);
5896	            var parentDocument = $(window.parent.document),
5897	                $detail_modal = parentDocument.find('.product-detail-modal');
5898	            if($detail_modal.length) return false;
5899	            var isOffer = $.siteBanner.checkOffer(type);
5900	            if(!isSC && !isOffer) {
5901	                $.siteBanner.doNotOffer(type,isSC);
5902	                return false;
5903	            }
5904
5905	            var isBand = (type == 'band') ? true : false,
5906	                isPopup = (type == 'popup') ? true : false,
5907	                banner_fn_obj = {'call':false, 'get':false, 'set':false, 'position':false},
5908	                deferredCall = $.Deferred();
5909
5910            if(isBand) {
5911                if(typeof $.siteBanner.band == 'undefined') $.siteBanner.band = {'seqs':[], 'paused':false};
5912                else $.siteBanner.stopBandRolling();
5913
5914                $.siteBanner.band.body = ($.inArray(PAGE_MODE, ['s','r']) > -1) ? window : '.dsgn-body';
5915                if($('html').is('._scroll')) $.siteBanner.band.body = window;
5916                if(isSC) {
5917                    var band_fn = banner_fn_obj;
5918                    if( typeof $.siteBanner.band != 'undefined' && 
5919                        typeof $.siteBanner.band.fn != 'undefined' &&
5920                        typeof $.siteBanner.band.fn_keep != 'undefined'
5921                    ) {
5922                        band_fn = $.siteBanner.band.fn;
5923                        delete $.siteBanner.band.fn_keep;
5924                    }
5925                    $.siteBanner.band.fn = band_fn;
5926                }
5927            }
5928            if(isPopup) {
5929                if(typeof $.siteBanner.popup == 'undefined') $.siteBanner.popup = {};
5930                if(isSC) {
5931                    var popup_fn = banner_fn_obj;
5932                    if( typeof $.siteBanner.popup != 'undefined' && 
5933                        typeof $.siteBanner.popup.fn != 'undefined' &&
5934                        typeof $.siteBanner.popup.fn_keep != 'undefined'
5935                    ) {
5936                        popup_fn = $.siteBanner.popup.fn;
5937                        delete $.siteBanner.popup.fn_keep;
5938                    }
5939                    $.siteBanner.popup.fn = popup_fn;
5940                }
5941            }
5942
5943	            var step1 = $.siteBanner.get(type,isSC,isGet);
5944	            step1.done(function() {
5945	                var step2 = $.siteBanner.set(type,isSC,isSet);
5946	                step2.done(function() {
5947	                    if($.siteBanner[type].used) {
5948	                        var step3 = $.siteBanner.position(type,isSC,isPosition);
5949	                        step3.done(function(step3_r) {
5950	                            fixedConfigBtn();
5951
5952	                            setTimeout(function() {
5953	                                $.clnav.setRootcss();
5954	                            }, 500);
5955	                            deferredCall.resolve();
5956	                        }).fail(function(step3_error) {
5957	                            deferredCall.reject(step3_error);
5958	                        });
5959	                    } else {
5960	                        deferredCall.resolve();
5961	                    }
5962	                }).fail(function(step2_error) {
5963	                    deferredCall.reject(step2_error);
5964	                });
5965	            }).fail(function(step1_error) {
5966	                deferredCall.reject(step1_error);
5967	            });
5968
5969	            return deferredCall.promise();
5970	        },
5971
5972        get: function(type,isSC,isGet) {
5973            // console.log(`[siteBanner_step_3 /5] $.siteBanner.get(type ${type}, isSC ${isSC}, isGet ${isGet})`);
5974            var deferred01 = $.Deferred(),
5975                isBand = (type == 'band') ? true : false,
5976                isPopup = (type == 'popup') ? true : false,
5977                publish = (typeof property != 'undefined') ? property.PUBLISH : false;
5978
5979            if(!isGet) deferred01.resolve();
5980            else {
5981                if(PAGE_MODE == 'c'){ // config(사이트편집)
5982                    $.post('/template/siteBanner/type/get',{ publish:publish, sid:$.siteBanner.sid, v:type }, function(data) {
5983                        checkError(data);
5984                        if(typeof data == 'object') {
5985                            $.siteBanner[type]['sort'] = data.sort;
5986                            $.siteBanner[type]['list'] = data.list;
5987                            $.siteBanner[type]['used'] = data.used;
5988                            $.siteBanner[type]['total'] = data.sort.length;
5989                            $.siteBanner[type]['close_time'] = data.close_time;
5990                            $.siteBanner[type]['close_today'] = data.close_today;
5991    
5992                            if(isBand) {
5993                                $.siteBanner[type]['close_onoff'] = data.close_onoff;
5994                                $.siteBanner[type]['interval'] = data.interval;
5995                            }
5996                            if(isPopup) {
5997                                $.siteBanner[type]['position'] = data.position;
5998                                $.siteBanner[type]['radius'] = data.radius;
5999                                $.siteBanner[type]['close_btn'] = data.close_btn;
6000                                $.siteBanner[type]['btn_style'] = data.btn_style;
6001                                $.siteBanner[type]['btn_color'] = data.btn_color;
6002                                $.siteBanner[type]['bg_layer'] = data.bg_layer;
6003                                $.siteBanner[type]['bg_color'] = data.bg_color;
6004	                                $.siteBanner[type]['view_type'] = data.view_type;
6005	                                $.siteBanner[type]['slide_auto'] = data.slide_auto;
6006	                                $.siteBanner[type]['slide_speed'] = data.slide_speed;
6007	                                $.siteBanner[type]['slide_move_time'] = data.slide_move_time;
6008	                                $.siteBanner[type]['slide_stop_time'] = data.slide_stop_time;
6009	                                $.siteBanner[type]['slide_size_origin'] = data.slide_size_origin;
6010                                $.siteBanner[type]['slide_size_width'] = data.slide_size_width;
6011                                $.siteBanner[type]['slide_arrow'] = data.slide_arrow;
6012	                                $.siteBanner[type]['slide_arrow_style'] = data.slide_arrow_style || '1';
6013	                                $.siteBanner[type]['slide_arrow_size'] = data.slide_arrow_size || '64';
6014                                $.siteBanner[type]['slide_arrow_color'] = data.slide_arrow_color;
6015	                                $.siteBanner[type]['slide_arrow_bg_color'] = data.slide_arrow_bg_color;
6016	                                $.siteBanner[type]['slide_pagination_display'] = data.slide_pagination_display;
6017	                                $.siteBanner[type]['slide_pagination'] = data.slide_pagination;
6018	                                $.siteBanner[type]['slide_pagination_style'] = data.slide_pagination_style || ((data.slide_pagination == 'dot') ? '1' : '11');
6019	                                $.siteBanner[type]['slide_pagination_align'] = data.slide_pagination_align;
6020	                                $.siteBanner[type]['slide_pagination_size'] = data.slide_pagination_size || '52';
6021	                                $.siteBanner[type]['slide_pagination_color'] = data.slide_pagination_color;
6022	                                $.siteBanner[type]['slide_pagination_active_color'] = data.slide_pagination_active_color;
6023                            }
6024                            deferred01.resolve();
6025                        } else {
6026                            deferred01.reject('get error');
6027                        }
6028                    }, 'json');
6029
6030                }else{ // render / site
6031                    // console.log(RENDER.b);
6032                    if(isBand && RENDER.b.BAND != '') {
6033                        $.siteBanner['band']['close_onoff'] = RENDER.b.BAND.close_onoff;
6034                        $.siteBanner['band']['interval'] = RENDER.b.BAND.interval;
6035                        $.siteBanner['band']['sort'] = RENDER.b.BAND.sort;
6036                        $.siteBanner['band']['list'] = RENDER.b.BAND.list;
6037                        $.siteBanner['band']['used'] = RENDER.b.BAND.used;
6038                        $.siteBanner['band']['total'] = RENDER.b.BAND.sort.length;
6039                        $.siteBanner['band']['close_time'] = RENDER.b.BAND.close_time;
6040                        $.siteBanner['band']['close_today'] = RENDER.b.BAND.close_today;
6041                    }
6042                    if(isPopup && RENDER.b.POPUP != '') {
6043                        $.siteBanner['popup']['position'] = RENDER.b.POPUP.position;
6044                        $.siteBanner['popup']['sort'] = RENDER.b.POPUP.sort;
6045                        $.siteBanner['popup']['list'] = RENDER.b.POPUP.list;
6046                        $.siteBanner['popup']['used'] = RENDER.b.POPUP.used;
6047                        $.siteBanner['popup']['total'] = RENDER.b.POPUP.sort.length;
6048                        $.siteBanner['popup']['close_time'] = RENDER.b.POPUP.close_time;
6049                        $.siteBanner['popup']['close_today'] = RENDER.b.POPUP.close_today;
6050                        $.siteBanner['popup']['radius'] = RENDER.b.POPUP.radius;
6051                        $.siteBanner['popup']['close_btn'] = RENDER.b.POPUP.close_btn;
6052                        $.siteBanner['popup']['btn_style'] = RENDER.b.POPUP.btn_style;
6053                        $.siteBanner['popup']['btn_color'] = RENDER.b.POPUP.btn_color;
6054                        $.siteBanner['popup']['bg_layer'] = RENDER.b.POPUP.bg_layer;
6055                        $.siteBanner['popup']['bg_color'] = RENDER.b.POPUP.bg_color;
6056	                        $.siteBanner['popup']['view_type'] = RENDER.b.POPUP.view_type;
6057	                        $.siteBanner['popup']['slide_auto'] = RENDER.b.POPUP.slide_auto;
6058	                        $.siteBanner['popup']['slide_speed'] = RENDER.b.POPUP.slide_speed;
6059	                        $.siteBanner['popup']['slide_move_time'] = RENDER.b.POPUP.slide_move_time;
6060	                        $.siteBanner['popup']['slide_stop_time'] = RENDER.b.POPUP.slide_stop_time;
6061	                        $.siteBanner['popup']['slide_size_origin'] = RENDER.b.POPUP.slide_size_origin;
6062                        $.siteBanner['popup']['slide_size_width'] = RENDER.b.POPUP.slide_size_width;
6063                        $.siteBanner['popup']['slide_arrow'] = RENDER.b.POPUP.slide_arrow;
6064	                        $.siteBanner['popup']['slide_arrow_style'] = RENDER.b.POPUP.slide_arrow_style || '1';
6065	                        $.siteBanner['popup']['slide_arrow_size'] = RENDER.b.POPUP.slide_arrow_size || '64';
6066                        $.siteBanner['popup']['slide_arrow_color'] = RENDER.b.POPUP.slide_arrow_color;
6067	                        $.siteBanner['popup']['slide_arrow_bg_color'] = RENDER.b.POPUP.slide_arrow_bg_color;
6068	                        $.siteBanner['popup']['slide_pagination_display'] = RENDER.b.POPUP.slide_pagination_display;
6069	                        $.siteBanner['popup']['slide_pagination'] = RENDER.b.POPUP.slide_pagination;
6070	                        $.siteBanner['popup']['slide_pagination_style'] = RENDER.b.POPUP.slide_pagination_style || ((RENDER.b.POPUP.slide_pagination == 'dot') ? '1' : '11');
6071	                        $.siteBanner['popup']['slide_pagination_align'] = RENDER.b.POPUP.slide_pagination_align;
6072		                        $.siteBanner['popup']['slide_pagination_size'] = RENDER.b.POPUP.slide_pagination_size || '52';
6073	                        $.siteBanner['popup']['slide_pagination_color'] = RENDER.b.POPUP.slide_pagination_color;
6074	                        $.siteBanner['popup']['slide_pagination_active_color'] = RENDER.b.POPUP.slide_pagination_active_color;
6075                    }
6076                    deferred01.resolve();
6077                }
6078                
6079            }
6080
6081            return deferred01.promise();
6082        },
6083        set: function(type,isSC,isSet) {
6084            // console.log(`[siteBanner_step_4 /5] $.siteBanner.set(type ${type}, isSC ${isSC}, isSet ${isSet})`);
6085            var deferred02 = $.Deferred(),
6086                isBand = (type == 'band') ? true : false,
6087                isPopup = (type == 'popup') ? true : false,
6088                onoff = $.siteBanner[type].used;
6089
6090            if(isSet && onoff) {
6091
6092                var CHK_LANG = LANG;
6093                if (typeof PAGE_MODE != 'undefined' && PAGE_MODE=='c' ) {
6094                    if(typeof SLANG != 'undefined' && typeof SLANG.select_code != 'undefined' && SLANG.select_code && SLANG.use_language == 'on') {
6095                        CHK_LANG = (SLANG.select_code == 'ko') ? 'ko' : 'en';
6096                    }
6097                }
6098
6099                var banner_name = $.siteBanner.sid + (type.charAt(0).toUpperCase() + type.slice(1)) + 'Banner',
6100                    b_list = '',
6101                    b_idx = 0, b_show = 0,
6102                    min = [120, 150],
6103                    max = [0, 0],
6104                    sum = [0, 0],
6105		                    popupViewType = (isPopup && typeof $.siteBanner.getPopupRenderableViewType == 'function') ? $.siteBanner.getPopupRenderableViewType(type) : ((isPopup) ? ($.siteBanner[type].view_type || 'individual') : 'individual'),
6106	                    popupSlideSizeOrigin = (isPopup && $.siteBanner[type].slide_size_origin == 'OFF') ? 'OFF' : 'ON',
6107	                    popupSlideSizeWidth = (isPopup) ? Number($.siteBanner[type].slide_size_width || 500) : 0,
6108	                    popupSlideSizeInfo = null,
6109	                    scPreviewDevice = (isSC) ? ($('#el-siteConfig .sc-device-wrap > li.active').attr('data-device') || 'p') : '',
6110	                    isPopupMobileRender = (isPopup && ((isSC && scPreviewDevice == 'm') || (!isSC && $(window).width() <= 767))),
6111	                    popupMobileMaxWidth = 0;
6112	                if(isPopup) $.siteBanner[type].render_view_type = popupViewType;
6113	                if(isPopup && (!popupSlideSizeWidth || popupSlideSizeWidth < 1)) popupSlideSizeWidth = 500;
6114                if(isPopup && popupViewType == 'slide') popupSlideSizeInfo = $.siteBanner.getPopupSli
6114deSizeInfo(type, popupSlideSizeOrigin, popupSlideSizeWidth, isSC);
6115	                if(isPopup && popupViewType != 'slide' && isPopupMobileRender && typeof $.siteBanner.getPopupMobileIndividualMaxWidth == 'function') popupMobileMaxWidth = $.siteBanner.getPopupMobileIndividualMaxWidth(isSC);
6116
6117	                $.each($.siteBanner[type].sort, function(idx,id) {
6118	                    var o = $.siteBanner[type].list[id],
6119	                        isVisible = (o.visible == 'ON') ? true : false;
6120	                        // console.log(o);
6121	                    if(!isSC && o.period.set && o.period.visible === false) isVisible = false;
6122	                    if(!isSC && isVisible || isSC) {
6123	                        var banner_id =  banner_name + id,
6124	                            banner_cookie = $.siteBanner.getBannerCookieName(type, id, popupViewType),
6125	                            isCookie = (typeof $.cookie(banner_cookie) != 'undefined' && $.cookie(banner_cookie)) ? true : false,
6126	                            popupSize = (type == 'popup' && typeof o.size != 'undefined') ? o.size : {},
6127	                            popupSizeOrigin = (popupSize.origin == 'OFF') ? 'OFF' : 'ON',
6128	                            popupSizeWidth = Number(popupSize.width || o.img.pc.width || 0),
6129	                            popupMobileAutoImage = (type == 'popup' && o.img.mobile && o.img.mobile.chk == '1') ? true : false,
6130	                            popupMobileSourceWidth = Number(((popupMobileAutoImage) ? o.img.pc.width : o.img.mobile.width) || o.img.pc.width || 0),
6131	                            popupMobileSourceHeight = Number(((popupMobileAutoImage) ? o.img.pc.height : o.img.mobile.height) || o.img.pc.height || 0),
6132	                            popupPcDisplayWidth = (popupViewType == 'slide' && popupSlideSizeInfo) ? popupSlideSizeInfo.pc.width : ((popupSizeOrigin == 'OFF' && popupSizeWidth > 0) ? popupSizeWidth : Number(o.img.pc.width)),
6133	                            popupMobileDisplayWidth = (popupViewType == 'slide' && popupSlideSizeInfo) ? popupSlideSizeInfo.mobile.width : ((popupSizeOrigin == 'OFF' && popupSizeWidth > 0) ? popupSizeWidth : popupMobileSourceWidth),
6134	                            popupPcDisplayHeight = (popupViewType == 'slide' && popupSlideSizeInfo) ? popupSlideSizeInfo.pc.height : Number(o.img.pc.height),
6135	                            popupMobileDisplayHeight = (popupViewType == 'slide' && popupSlideSizeInfo) ? popupSlideSizeInfo.mobile.height : popupMobileSourceHeight;
6136
6137		                        if(type == 'popup' && popupViewType != 'slide') {
6138		                            if(isPopupMobileRender && popupMobileMaxWidth > 0) {
6139		                                popupMobileDisplayWidth = popupMobileMaxWidth;
6140		                                if(popupMobileSourceWidth > 0 && popupMobileSourceHeight > 0) {
6141		                                    popupMobileDisplayHeight = Math.round(popupMobileDisplayWidth * popupMobileSourceHeight / popupMobileSourceWidth);
6142		                                }
6143		                            } else if(popupSizeOrigin == 'OFF' && popupSizeWidth > 0 && popupMobileSourceWidth > 0 && popupMobileSourceHeight > 0) {
6144		                                popupMobileDisplayHeight = Math.round(popupMobileDisplayWidth * popupMobileSourceHeight / popupMobileSourceWidth);
6145		                            }
6146		                        }
6147
6148	                        b_idx++;
6149	                        if(!isCookie || isSC) {
6150	                            b_show++;
6151
6152	                            if(isVisible) {
6153	                                if(min[0] > popupPcDisplayHeight) min[0] = popupPcDisplayHeight;
6154	                                if(max[0] < popupPcDisplayHeight) max[0] = popupPcDisplayHeight;
6155	                                if(max[1] < popupMobileDisplayHeight) max[1] = popupMobileDisplayHeight;
6156	                                if(type == 'popup') {
6157	                                    sum[0] += popupPcDisplayWidth;
6158	                                    sum[1] += popupMobileDisplayWidth;
6159	                                } else {
6160	                                    sum[0] += Number(o.img.pc.width);
6161	                                    sum[1] += Number(o.img.mobile.width);
6162	                                }
6163	                            }
6164	                        }
6165                        
6166                        var period_label = (o.period.chk == 1) ? '' : o.period.label;
6167                        var banner_label = (isSC) ? '\
6168                                            <ul class="banner-label" data-period-label="'+period_label+'">\
6169                                                <li class="period-start">' + $.lang[LANG]['sc.banner.period.label.start'] + '</li>\
6170                                                <li class="period-end">' + $.lang[LANG]['sc.banner.period.label.end'] + '</li>\
6171                                            </ul>\
6172                            ' : '',
6173                            banner_str = '';
6174                        if(type == 'band') {
6175                            var band_img_arr = [o.img.pc.path, o.img.mobile.path],
6176                                band_img_mobile = (o.img.mobile.chk == '0') ? true : false,
6177                                band_img_root = (isSC) ? ['--scbandBanner-img-pc','--scbandBanner-img-mobile'] : ['--bandBanner-img-pc','--bandBanner-img-mobile'];
6178                            $.each(band_img_arr, function(img_i,img_v) {
6179                                var check_img = $('<img data-id="' + id + '" data-root="' + band_img_root[img_i] + '" data-sc="' + isSC + '"/>').attr('src',img_v);
6180                                check_img.error(function() {
6181                                    var img_id = $(this).attr('data-id'),
6182                                        img_root = $(this).attr('data-root'),
6183                                        checkSC = $(this).attr('data-sc'),
6184                                        img_s = (checkSC == 'true') ? 'sc-bandBanner' : 'cl-bandBanner';
6185                                    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);
6186                                });
6187                            });
6188
6189                            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]});`;
6190
6191                            banner_str = '\
6192                                <li class="banner-box" id="' + banner_id + '">\
6193                                    <div class="banner-content">\
6194                                        <div class="banner-body">\
6195                                            <a href="javascript:;">\
6196                                                <div class="banner-img" style="' + banner_img_style + '">\
6197                                                    <div class="img-banner"></div>\
6198                                                </div>\
6199                                            </a>\
6200                                            ' + banner_label + '\
6201                                        </div>\
6202                                        <div class="banner-header">\
6203                                            <span class="banner-closetoday">' + $.lang[CHK_LANG]['editor.banner.close.today'] + '</span>\
6204                                            ' + clSVG('close',12,12,true,'banner-close') + '\
6205                                        </div>\
6206                                    </div>\
6207                                </li>\
6208                            ';
6209                        } else if(type == 'popup') {
6210
6211                            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\'"/>`;
6212                            banner_str = '\
6213                                <li class="banner-box" id="' + banner_id + '">\
6214                                    <div class="banner-content">\
6215                                        <div class="banner-header">' + clSVG('close',17,17,true,'banner-close') + '</div>\
6216                                        <div class="banner-body">\
6217                                            <a href="javascript:;">\
6218                                                <div class="banner-img">\
6219                                                    '+ popup_img_style +'\
6220                                                </div>\
6221                                            </a>\
6222                                            ' + banner_label + '\
6223                                        </div>\
6224                                        <div class="banner-footer clearfix">\
6225                                            <div class="banner-btn-wrap">\
6226                                                <span class="banner-btn banner-closetoday">' + $.lang[CHK_LANG]['editor.banner.close.today'] + '</span>\
6227                                                <span class="banner-btn banner-close">' + $.lang[CHK_LANG]['config.close'] + '</span>\
6228                                            </div>\
6229                                        </div>\
6230                                    </div>\
6231                                </li>\
6232                            ';
6233                        }
6234
6235	                        var bannerItem = $(banner_str),
6236	                            closeColor = $.siteBanner.getCssColorValue(o.close.color, '#000000');
6237                        bannerItem.attr('data-id', id);
6238                        bannerItem.attr('data-type', type);
6239                        if(isSC) {
6240                            if(!isVisible) bannerItem.addClass('hide');
6241                            if(o.link.val) {
6242                                var blink_o = $.siteBanner.getLINK(o.link.val, o.link.target);
6243                                if(blink_o.link) {
6244                                    bannerItem.find('a').addClass('active');
6245                                }                            
6246                            }
6247                        } else {
6248                            if(isCookie) bannerItem.addClass('hide');
6249                            bannerItem.attr('data-closetime', $.siteBanner[type].close_time);
6250                            if(o.link.val) {
6251                                var blink_o = $.siteBanner.getLINK(o.link.val, o.link.target);
6252                                if(blink_o.link) {
6253                                    bannerItem.find('a').attr('href', blink_o.link);
6254                                    if(blink_o.target) bannerItem.find('a').attr('target', blink_o.target);
6255                                    $.each(blink_o.option, function(o_k, o_v) {
6256                                        bannerItem.find('a').attr(o_k, o_v);
6257                                    });
6258                                }
6259                            }
6260                        }
6261		                        bannerItem.find('.banner-content').css('background-color',o.img.bgcolor);
6262		                        bannerItem.find('.banner-header .banner-closetoday').css('color',closeColor);
6263		                        bannerItem.find('.banner-header .banner-close.cl-icon > svg').css('fill',closeColor);
6264	                        if(type == 'popup' && popupViewType == 'slide' && popupSlideSizeInfo) {
6265	                            $.siteBanner.applyPopupSlideBoxSize(bannerItem, popupSlideSizeInfo);
6266	                        } else if(type == 'popup' && popupViewType != 'slide' && isPopupMobileRender && popupMobileDisplayWidth > 0) {
6267	                            bannerItem.css('width', popupMobileDisplayWidth + 'px');
6268	                            bannerItem.find('.banner-content, .banner-body, .banner-img, .banner-img > img').css('width', '100%');
6269	                        } else if(type == 'popup' && popupSizeOrigin == 'OFF' && popupSizeWidth > 0) {
6270	                            bannerItem.css('width', popupSizeWidth + 'px');
6271	                            bannerItem.find('.banner-content, .banner-body, .banner-img, .banner-img > img').css('width', '100%');
6272	                        }
6273
6274	                        if($.siteBanner[type].close_today == 'OFF') bannerItem.find('.banner-closetoday').addClass('hide');
6275                        if(type == 'band' && $.siteBanner[type].close_onoff == 'OFF') bannerItem.find('.banner-header').addClass('hide');
6276
6277                        if(type == 'popup' && $.siteBanner[type].close_btn == '1') {
6278                            bannerItem.find('.banner-content').css('background-color','');
6279                            bannerItem.find('.banner-body').css('background-color',o.img.bgcolor);
6280                        }
6281
6282                        b_list += bannerItem.outerHTML();
6283                    }
6284                });
6285
6286                if(b_show > 0) {
6287                    $.siteBanner[type].total = b_show;
6288                    if(isBand) {
6289                        $.siteBanner[type].min_h = min;
6290                    } else if(isPopup) {
6291                        $.siteBanner[type].total_w = sum;
6292                        $.siteBanner[type].max_h = max;
6293                    }
6294
6295					                    var popup_slide_arrow_style_for_html = $.siteBanner[type].slide_arrow_style || '1',
6296					                        popup_slide_arrow_color_for_html = $.siteBanner[type].slide_arrow_color || '#ffffff',
6297					                        popup_slide_arrow_size_for_html = $.siteBanner.getPopupSli
6297deControlSizeValue($.siteBanner[type].slide_arrow_size, '64'),
6298					                        popup_slide_arrow_mobile_size_for_html = (!isSC && typeof $.siteBanner.getPopupSlideMobileArrowSize == 'function') ? $.siteBanner.getPopupSlideMobileArrowSize() : 0,
6299					                        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),
6300					                        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),
6301					                        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);
6302
6303				                    if(isSC) {
6304					                        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>' : '';
6305				                        var popup_mobile_mockup = (isPopup) ? '<img class="sc-popup-mobile-mockup" src="https://storage.googleapis.com/i.addblock.net/sample/popup_mockup.png" alt="">' : '';
6306				                        $('#el-siteConfig .sc-siteBanner').replaceWith(`
6307				                            <div class="sc-siteBanner sc-${type}Banner ${scPreviewDevice}">
6308			                                ${popup_mobile_mockup}
6309			                                <div class="banner-modal">
6310		                                    <ul>${b_list}</ul>
6311		                                    ${popup_slide_control}
6312                                    <div class="banner-description" data-closetoday="m"><span>${clSVG('info',18,18,true,'')}${$.lang[LANG]['sc.banner.band.close.today.m']}</span></div>
6313                                    <div class="banner-description" data-overflow="x"><span>${clSVG('info',18,18,true,'')}${$.lang[LANG]['sc.banner.popup.position.overflow']}</span></div>
6314                                </div>
6315                            </div>
6316	                        `);
6317		                    } else {
6318		                        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>' : '';
6319	                        var bannerEL = $(`
6320	                            <div class="cl-${type}Banner">
6321	                                <div class="banner-modal">
6322                                    <ul>${b_list}</ul>
6323                                    ${popup_slide_control}
6324                                </div>
6325                            </div>
6326                        `);
6327
6328                        if($(`.cl-${type}Banner`).length > 0) $(`.cl-${type}Banner`).remove();
6329                        if($('html').is('._scroll')) {
6330                            if($('.editor-navbar').length > 0) $('.editor-navbar').after(bannerEL);
6331                            else $('body').prepend(bannerEL);
6332                        } else {
6333                            $('.dsgn-body').prepend(bannerEL);
6334                        }
6335                    }
6336
6337                    if(Number($.siteBanner[type].radius) > 0) {
6338                        $.siteBanner.setPopupRadiusCss('.banner-modal', $.siteBanner[type].radius);
6339                    }
6340                    if(isPopup) {
6341                        var popupBtnStyle = $.siteBanner[type].btn_style || '1',
6342                            popupBtnColor = $.siteBanner[type].btn_color || '#696c71',
6343                            popupBgLayer = $.siteBanner[type].bg_layer || 'OFF',
6344                            popupBgColor = $.siteBanner[type].bg_color || 'rgba(0, 0, 0, 0.6)',
6345		                            popupViewType = $.siteBanner[type].render_view_type || $.siteBanner[type].view_type || 'individual',
6346	                            popupSlideAuto = $.siteBanner[type].slide_auto || 'OFF',
6347	                            popupSlideSpeed = $.siteBanner[type].slide_speed || '3',
6348	                            popupSlideMoveTime = $.siteBanner[type].slide_move_time || '1',
6349		                            popupSlideStopTime = $.siteBanner[type].slide_stop_time || '3',
6350			                            popupSlideArrow = $.siteBanner[type].slide_arrow || 'OFF',
6351			                            popupSlideArrowStyle = $.siteBanner[type].slide_arrow_style || '1',
6352			                            popupSlideArrowSize = $.siteBanner.getPopupSli
6352deControlSizeValue($.siteBanner[type].slide_arrow_size, '64'),
6353			                            popupSlideArrowColor = $.siteBanner[type].slide_arrow_color || '#ffffff',
6354			                            popupSlideArrowBgColor = $.siteBanner[type].slide_arrow_bg_color || '#000000',
6355			                            popupSlidePaginationDisplay = $.siteBanner[type].slide_pagination_display || 'ON',
6356			                            popupSlidePagination = $.siteBanner[type].slide_pagination || 'number',
6357			                            popupSlidePaginationStyle = $.siteBanner[type].slide_pagination_style || ((popupSlidePagination == 'dot') ? '1' : '11'),
6358			                            popupSlidePaginationAlign = $.siteBanner[type].slide_pagination_align || 'right',
6359		                            popupSlidePaginationSize = $.siteBanner.getPopupSlideControlSizeValue($.siteBanner[type].slide_pagination_size, '52'),
6360		                            popupSlidePaginationColor = $.siteBanner[type].slide_pagination_color || '#ffffff',
6361		                            popupSlidePaginationActiveColor = $.siteBanner[type].slide_pagination_active_color || '#000000';
6362
6363	                        if($.inArray(popupSlidePaginationAlign, ['left','center','right']) < 0) popupSlidePaginationAlign = 'right';
6364	                        if(!$.siteBanner.isPopupSlideArrowStyleValue(popupSlideArrowStyle)) popupSlideArrowStyle = '1';
6365	                        if(!$.siteBanner.isPopupSlidePaginationStyleValue(popupSlidePaginationStyle)) popupSlidePaginationStyle = (popupSlidePagination == 'dot') ? '1' : '11';
6366	                        popupSlidePagination = $.siteBanner.getPopupSlidePaginationTypeByStyle(popupSlidePaginationStyle);
6367	                        $('.sc-popupBanner .banner-modal, .cl-popupBanner .banner-modal').each(function() {
6368                            $(this).attr('data-btnstyle', popupBtnStyle)
6369                                   .attr('data-bglayer', popupBgLayer)
6370		                                   .attr('data-viewtype', popupViewType)
6371		                                   .attr('data-slidesizeorigin', popupSlideSizeOrigin)
6372	                                   .attr('data-slideauto', popupSlideAuto)
6373	                                   .attr('data-slidespeed', popupSlideSpeed)
6374	                                   .attr('data-slidemovetime', popupSlideMoveTime)
6375				                                   .attr('data-slidestoptime', popupSlideStopTime)
6376				                                   .attr('data-slidearrow', popupSlideArrow)
6377				                                   .attr('data-slidearrowstyle', popupSlideArrowStyle)
6378				                                   .attr('data-slidearrowsize', popupSlideArrowSize)
6379				                                   .attr('data-slidepaginationdisplay', popupSlidePaginationDisplay)
6380			                                   .attr('data-slidepagination', popupSlidePagination)
6381			                                   .attr('data-slidepaginationstyle', popupSlidePaginationStyle)
6382			                                   .attr('data-slidepaginationalign', popupSlidePaginationAlign)
6383		                                   .attr('data-slidepaginationsize', popupSlidePaginationSize);
6384	                            this.style.setProperty('--popup-btn-color', popupBtnColor);
6385	                            this.style.setProperty('--popup-bg-color', popupBgColor);
6386		                            this.style.setProperty('--popup-slide-arrow-color', popupSlideArrowColor);
6387		                            this.style.setProperty('--slider-nav-color', popupSlideArrowColor);
6388		                            this.style.setProperty('--popup-slide-arrow-bg-color', popupSlideArrowBgColor);
6389		                            this.style.setProperty('--popup-slide-pagination-color', popupSlidePaginationColor);
6390		                            this.style.setProperty('--slider-page-color', popupSlidePaginationColor);
6391		                            this.style.setProperty('--popup-slide-pagination-active-color', popupSlidePaginationActiveColor);
6392		                            this.style.setProperty('--slider-page-align', popupSlidePaginationAlign);
6393		                            $.siteBanner.applyPopupSlideControlSize(this, popupSlideArrowSize, popupSlidePaginationSize);
6394		                            $.siteBanner.updatePopupSlideArrowIcons(this, popupSlideArrowStyle, popupSlideArrowColor);
6395		                        });
6396	                        $.siteBanner.setPopupSlide(isSC);
6397	                    }
6398	                    if(Number($.siteBanner[type].close_btn) > 0) {
6399	                        $('.banner-modal').each(function() {
6400                            $(this).attr('data-closebtn',$.siteBanner[type].close_btn)
6401                        });
6402                    }
6403                } else {
6404                    delete $.siteBanner[type].min_h;
6405                    delete $.siteBanner[type].total_w;
6406
6407                    $.siteBanner[type].total = 0;
6408                    $.siteBanner[type].used = false;
6409                    $.siteBanner.doNotOffer(type,isSC);
6410                }
6411
6412                deferred02.resolve();
6413            } else {
6414                if(isSet && !onoff) $.siteBanner.doNotOffer(type,isSC);
6415                deferred02.resolve();
6416            }
6417
6418            return deferred02.promise();
6419        },
6420        position: function(type,isSC,isPosition) {
6421            // console.log(`[siteBanner_step_END (on) /5] $.siteBanner.position(type ${type}, isSC ${isSC}, isPosition ${isPosition})`);
6422            var deferred03 = $.Deferred(),
6423                isClnav = $('header').is('.cl-nav'),
6424                isBand = (type == 'band') ? true : false,
6425                isPopup = (type == 'popup') ? true : false;
6426
6427            if(!isPosition) {
6428                deferred03.resolve();
6429            } else {
6430
6431                if(isBand) {
6432                    $.siteBanner.stopBandRolling();
6433
6434                    var m_h = $.siteBanner[type].min_h[0],
6435                        m_h2 = $.siteBanner[type].min_h[1];
6436                    if(m_h > 120) m_h = 120;
6437                    if(m_h2 != 50) m_h2 = 50;
6438
6439                    if(isSC) {
6440                        $('#el-siteConfig .sc-siteBanner').attr('data-min-p',m_h).attr('data-min-m',m_h2);
6441                        document.querySelector('#el-siteConfig .sc-siteBanner').style.setProperty('--scbandBanner-height-pc', m_h+'px', null);
6442                        document.querySelector('#el-siteConfig .sc-siteBanner').style.setProperty('--scbandBanner-height-mobile', m_h2+'px', null);
6443
6444                        var sc_device = $('#el-siteConfig .sc-device-wrap > li.active').attr('data-device');
6445                        if(sc_device == 'm') $('#el-siteConfig .sc-siteBanner .banner-description[data-closetoday="m"]').addClass('active');
6446                        else $('#el-siteConfig .sc-siteBanner .banner-description[data-closetoday="m"]').removeClass('active');
6447                    } else {
6448                        document.querySelector('body').style.setProperty('--bandBanner-height-pc', m_h+'px', null);
6449                        document.querySelector('body').style.setProperty('--bandBanner-height-mobile', m_h2+'px', null);
6450
6451                        $('body, .cl-bandBanner').addClass('openBandBanner');
6452                        $('.element[data-type="gallery"][data-type2="premium"]').refreshRootCss();
6453
6454                        var parentDocument = $(window.parent.document),
6455                            $detail_modal = parentDocument.find('.product-detail-modal');
6456                        if($detail_modal.length) $('.cl-bandBanner').addClass('detail');                  
6457
6458                        if(!isClnav) {
6459                            var isHeader = ($('.el-menu header.navbar').hasClass('transparent')) ? true : false,
6460                                isSidebar = ($('.el-menu header.navbar').hasClass('sidebar')) ? true : false,
6461                                header_h = (isHeader || (isSidebar && $('body').width() > 767)) ? 0 : $('.el-menu header.navbar').outerHeight(),
6462                                band_h = ($('body').width() > 767) ? m_h : m_h2;
6463                            $('.dsgn-body').css('padding-top', (band_h+header_h)+'px'); 
6464                        }
6465
6466                        if($.siteBanner.band.total > 1) {
6467                            var rolling_id = setInterval($.siteBanner.setBandRolling, $.siteBanner.band.interval);
6468                            $.siteBanner.band.seqs.push(rolling_id);
6469                            $('.cl-bandBanner').attr('data-seq',rolling_id);
6470                        }
6471
6472                        if(!isClnav) {
6473                            $($.siteBanner.band.body).scroll(function(event) {
6474                                if($('.cl-bandBanner').hasClass('openBandBanner') && $('.element[data-type="gallery"][data-type2="premium"][data-feature*="fixedscroll"]').length == 0) {
6475                                    if($(this).scrollTop() < $('.cl-bandBanner').outerHeight()) {
6476                                        if($('.header.el-menu > header').hasClass('transparent')) $('.dsgn-body').css('padding-top',$.siteBanner.getBandHeight()+'px');
6477                                        $('.cl-bandBanner, .el-menu_ctrl, .header.el-menu > header').css('margin-top',-$(this).scrollTop()+'px');
6478                                    } else {
6479                                        if($('.header.el-menu > header').hasClass('transparent')) $('.dsgn-body').css('padding-top',$.siteBanner.getBandHeight()+'px');
6480                                        $('.cl-bandBanner, .el-menu_ctrl, .header.el-menu > header').css('margin-top',-$('.cl-bandBanner').outerHeight()+'px');
6481                                    }
6482                                }
6483                            });
6484                        }
6485                    }
6486
6487                    deferred03.resolve();
6488                } else if(isPopup) {
6489	                    var sc_device = (isSC) ? ($('#el-siteConfig .sc-device-wrap > li.active').attr('data-device') || 'p') : '',
6490	                        p_selector = (isSC) ? '.sc-popupBanner' : '.cl-popupBanner',
6491	                        $popupPositionContainer = (isSC && sc_device == 'm') ? $(p_selector+' > .banner-modal') : $(p_selector),
6492	                        body_w = (isSC) ? $popupPositionContainer.width() : $('.dsgn-body').width(),
6493	                        device_idx = (isSC) ? ((sc_device == 'm') ? 1 : 0) : ((body_w <= 767) ? 1 : 0),
6494	                        isScMobileStack = (isSC && sc_device == 'm'),
6495	                        isMobileStack = isScMobileStack || (!isSC && device_idx == 1),
6496		                        device_offset = (isMobileStack) ? 0 : 30 + (($.siteBanner.popup.total - 1) * 30),
6497		                        popupViewType = $.siteBanner.popup.render_view_type || $.siteBanner.popup.view_type || 'individual',
6498		                        p_overflow = (popupViewType == 'slide') ? false : (((body_w - device_offset) < $.siteBanner.popup.total_w[device_idx]) ? true : false),
6499		                        p_position = $.siteBanner.popup.position || 'center center',
6500		                        p_arr = p_position.split(' '),
6501		                        p_justify = (p_arr[0]) ? p_arr[0] : 'center',
6502		                        p_align = (p_arr[1]) ? p_arr[1] : 'center',
6503		                        preview_justify = (isMobileStack) ? 'center' : p_justify,
6504		                        preview_align = (isMobileStack) ? 'center' : p_align,
6505		                        setPopupOverflowPosition = function() {
6506		                            var step = (isMobileStack) ? 35 : 30,
6507		                                mobileStackGutter = (isMobileStack) ? ((isScMobileStack) ? 0 : 30) : 0,
6508		                                alignGap = (isSC) ? 0 : (step * 2),
6509		                                topStart = (isSC && sc_device == 'p') || isMobileStack ? 0 : step,
6510		                                $banner = $popupPositionContainer,
6511		                                $items = $(p_selector+' .banner-box:not(.hide)'),
6512                                bannerOffset = $banner.offset() || {top:0},
6513                                containerWidth = $banner.innerWidth() || body_w,
6514                                containerHeight = $banner.innerHe
6514ight(),
6515                                visualWidth = 0,
6516                                visualHeight = 0,
6517		                                baseLeft = (isMobileStack) ? mobileStackGutter : ((isSC) ? 0 : step),
6518                                baseTop = topStart,
6519                                pi_i = $items.length;
6520
6521                            if(!containerHeight || containerHeight < 1) {
6522                                containerHeight = (!isSC) ? ($(window).height() - bannerOffset.top) : $banner.height();
6523                            }
6524                            if(!containerHeight || containerHeight < 1) containerHeight = 0;
6525
6526                            $items.each(function(i) {
6527                                var $item = $(this),
6528                                    itemWidth = $item.outerWidth() || parseInt($item.css('width'), 10) || 0,
6529                                    itemHeight = $item.outerHeight() || parseInt($item.css('height'), 10) || 0;
6530
6531                                visualWidth = Math.max(visualWidth, ((isMobileStack) ? 0 : (i * step)) + itemWidth);
6532                                visualHeight = Math.max(visualHeight, (i * step) + itemHeight);
6533                            });
6534
6535	                            if((!isMobileStack || isScMobileStack) && containerWidth > visualWidth + alignGap) {
6536	                                if(preview_justify == 'center') baseLeft = Math.round((containerWidth - visualWidth) / 2);
6537		                                else if(preview_justify == 'right') baseLeft = containerWidth - visualWidth - ((isSC) ? 0 : step);
6538		                            }
6539		                            if(containerHeight > visualHeight + alignGap) {
6540		                                if(preview_align == 'center') baseTop = Math.round((containerHeight - visualHeight) / 2);
6541		                                else if(preview_align == 'bottom') baseTop = containerHeight - visualHeight - ((isSC) ? 0 : step);
6542		                            }
6543
6544	                            baseLeft = (isMobileStack) ? mobileStackGutter : ((isSC) ? Math.max(0, baseLeft) : Math.max(step, baseLeft));
6545                            baseTop = Math.max(topStart, baseTop);
6546
6547	                            $items.each(function(i) {
6548	                                var $item = $(this),
6549	                                    itemWidth = $item.outerWidth() || parseInt($item.css('width'), 10) || 0,
6550	                                    itemLeft = baseLeft + (i * step);
6551
6552		                                if(isScMobileStack) {
6553		                                    if(preview_justify == 'center') itemLeft = Math.round((containerWidth - itemWidth) / 2);
6554		                                    else if(preview_justify == 'right') itemLeft = containerWidth - itemWidth - mobileStackGutter;
6555		                                    else itemLeft = mobileStackGutter;
6556	                                    itemLeft = Math.max(mobileStackGutter, itemLeft);
6557	                                } else if(isMobileStack) {
6558	                                    itemLeft = Math.max(mobileStackGutter, Math.round((containerWidth - itemWidth) / 2));
6559	                                }
6560
6561	                                $item.css({'top':(baseTop + (i * step))+'px', 'left':itemLeft+'px', 'margin-right':((isMobileStack) ? 0 : pi_i * step)+'px'});
6562                                pi_i--;
6563                            });
6564                        };
6565
6566	                    $(p_selector+' > .banner-modal').attr('data-justify', preview_justify)
6567                                                        .attr('data-align', preview_align)
6568                                                        .attr('data-overflow', p_overflow);
6569
6570                    if(p_overflow) {
6571                        // 계단식
6572                        if(isSC) setPopupOverflowPosition();
6573                    } else {
6574                        // 나열
6575                        $(p_selector+' .banner-box:not(.hide)').each(function(i) {
6576	                            $(this).removeInlineCss('top left margin-right');
6577	                        });
6578	                    }
6579		                    if(popupViewType == 'slide') $.siteBanner.setPopupSlide(isSC);
6580
6581	                    if(!isSC) {
6582	                        $(window).resize(function() {
6583                            if(this.resizeTO) {
6584                                clearTimeout(this.resizeTO);
6585                            }
6586                            this.resizeTO = setTimeout(function() {
6587                                $(this).trigger('resizeEnd');
6588                            }, 500);
6589                        });
6590                        $(window).on('resizeEnd', function() {
6591                            if($('.cl-popupBanner').hasClass('openPopupBanner')) {
6592                                var reposition = $.siteBanner.position('popup',isSC,true);
6593                                reposition.done(function(rp_r) {
6594                                }).fail(function(rp_error) {
6595                                });
6596                            }
6597	                        });
6598
6599	                        setTimeout(function() {
6600	                            if(typeof $.siteBanner.popup != 'undefined' && $.siteBanner.popup.site_config_hidden === true) {
6601	                                $.siteBanner.stopPopupSlideRolling('.cl-popupBanner');
6602	                                $('body, .cl-popupBanner').removeClass('openPopupBanner');
6603	                                return;
6604	                            }
6605
6606	                            var isPB = (typeof property != 'undefined') ? true : false,
6607	                                band_h = $.siteBanner.getBandHeight(),
6608	                                header_h = ($('.el-menu header.navbar').hasClass('transparent')) ? 0 : $('.el-menu header.navbar').outerHeight(),
6609	                                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,
6610	                                popup_t = band_h + header_h,
6611                                popup_l = 0;
6612                            if($('.el-menu header.navbar').hasClass('sidebar')) {
6613                                if($('body').width() > 767) {
6614                                    popup_t = band_h;
6615                                    if(isPB) popup_l = 260;
6616                                    if($('.dsgn-body').hasClass('mode-render')) document.querySelector('.cl-popupBanner').style.setProperty('width', 'calc(100% - 260px)', null);
6617                                }
6618                            }
6619                            if(editor_navbar_t > 0) popup_t = Math.max(popup_t, editor_navbar_t);
6620
6621                            $('.cl-popupBanner').css({'top':parseInt(popup_t)+'px','left':popup_l+'px'});
6622                            if(!p_overflow) $(p_selector).css('bottom',0);
6623                            $('body, .cl-popupBanner').addClass('openPopupBanner');
6624	                            if(p_overflow) setPopupOverflowPosition();
6625	                            if(popupViewType == 'slide') $.siteBanner.setPopupSli
6625de(isSC);
6626                        }, 300);
6627	                    }
6628                    deferred03.resolve();
6629                }
6630            }
6631            return deferred03.promise();
6632        },
6633
6634        getLINK: function(org_link,org_ltarget) {
6635            var link = (typeof org_link == 'string' && org_link != 'javascript:;' && org_link.length > 0) ? org_link : 'javascript:;',
6636                link_target = (typeof org_ltarget != 'undefined' && (org_ltarget == '1' || org_ltarget == 'ON')) ? '_blank' : '',
6637                link_option = {};
6638
6639            if(link != '' && link != 'javascript:;') {
6640                var _menuList = (PAGE_MODE == 'c') ? MENULIST : property.MENULIST;
6641            
6642                if(link.match(/^\@/g) !== null) {                                                  // link-type: link-bookmark ==> a[attr-bookmark]
6643                    var _settings = (PAGE_MODE == 'c') ? SETTINGS : property.SETTINGS,
6644                        bookmark_seq = link.replace(/^\@/g,'');
6645                        
6646                    if(typeof _settings == 'undefined' || typeof _settings.blockBookmarkList == 'undefined' || _settings.blockBookmarkList['bookmark' + bookmark_seq] == 'undefined') {
6647                        link = '';
6648                        link_option = {};
6649                    } else {
6650                        link_option['attr-bookmark'] = bookmark_seq;
6651                    }
6652                } else if(link.match(/^flink\@[0-9]/gi) !== null) {                                // link-type: link-file     ==> a[attr-flink]
6653                    link_option['attr-flink'] = link.replace(/^flink\@/gi,'');
6654                    link_target = '';
6655                } else if(_menuList.indexOf(link.replace(/^\//g,"").replace(/ /g,"-")) > -1) {     // link-type: link-menu     ==> a[data-user-link]
6656                    link_option['data-user-link'] = link;
6657                } else {                                                                            // link-type: link-out      ==> a[attr-link]
6658                    link_option['attr-link'] = link;
6659                }
6660
6661                link = (PAGE_MODE == 'c') ? makeLinkUrl(link, ONE, VIEW) : makeLinkUrl(link, property.ONE, property.VIEW);
6662            }
6663
6664            return {'link':link, 'target':link_target, 'option':link_option};
6665        },
6666	        getBandHeight: function() {
6667	            if($('body').hasClass('openBandBanner')) {
6668	                var bandbanner_p = getComputedStyle(document.querySelector('body')).getPropertyValue('--bandBanner-height-pc'),
6669	                    bandbanner_m = getComputedStyle(document.querySelector('body')).getPropertyValue('--bandBanner-height-mobile');
6670
6671	                if($('body').width()>767) return parseInt(bandbanner_p);
6672	                else return parseInt(bandbanner_m);
6673	            } else {
6674	                return 0;
6675	            }
6676	        },
6677	        getPopupMobileIndividualMaxWidth: function(isSC) {
6678	            var maxWidth = 0,
6679	                $modal = null,
6680	                windowWidth = 0,
6681	                bodyWidth = 0;
6682
6683		            if(isSC) {
6684		                $modal = $('#el-siteConfig .sc-popupBanner.m > .banner-modal');
6685		                maxWidth = (($modal.innerWidth() || 294) - 34);
6686		            } else {
6687	                windowWidth = $(window).width() || 0;
6688	                bodyWidth = $('.dsgn-body').width() || 0;
6689	                maxWidth = ((windowWidth > 0) ? windowWidth : bodyWidth) - 60;
6690	            }
6691
6692	            return (maxWidth > 0) ? maxWidth : 0;
6693	        },
6694	        bindPopupSlideEvents: function() {
6695	            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',
6696	                dotSelector = '.cl-popupBanner .banner-modal[data-viewtype="slide"] .banner-slide-dot, #el-siteConfig .sc-popupBanner .banner-modal[data-viewtype="slide"] .banner-slide-dot',
6697	                swipeSelector = '.cl-popupBanner .banner-modal[data-viewtype="slide"] .banner-body';
6698
6699	            $(document).off('click.sitePopupSlide', arrowSelector)
6700	                       .on('click.sitePopupSlide', arrowSelector, function(e) {
6701	                e.preventDefault();
6702	                e.stopPropagation();
6703
6704		                var direction = ($(this).hasClass('banner-slide-prev')) ? -1 : 1,
6705		                    $modal = $(this).closest('.banner-modal');
6706
6707		                if($.siteBanner.isPopupSlideManualMoving($modal)) return;
6708		                $.siteBanner.stopPopupSlideRollingModal($modal);
6709		                $.siteBanner.finishPopupSlide($modal);
6710		                $.siteBanner.nextPopupSlide($modal, direction, true);
6711		                $.siteBanner.startPopupSlideRollingModal($modal);
6712		            });
6713
6714	            $(document).off('click.sitePopupSlideDot', dotSelector)
6715	                       .on('click.sitePopupSlideDot', dotSelector, function(e) {
6716	                e.preventDefault();
6717	                e.stopPropagation();
6718
6719	                var $modal = $(this).closest('.banner-modal'),
6720	                    index = Number($(this).attr('data-index') || 0),
6721	                    currentIndex = Number($modal.attr('data-slide-index') || 0),
6722	                    direction = (index > currentIndex) ? 1 : -1;
6723
6724		                if(index == currentIndex) return;
6725		                if($.siteBanner.isPopupSlideManualMoving($modal)) return;
6726		                $.siteBanner.stopPopupSlideRollingModal($modal);
6727		                $.siteBanner.finishPopupSlide($modal);
6728		                $.siteBanner.showPopupSlide($modal, index, direction, true);
6729		                $.siteBanner.startPopupSlideRollingModal($modal);
6730		            });
6731
6732		            $(document).off('touchstart.sitePopupSlideSwipe touchmove.sitePopupSlideSwipe touchend.sitePopupSlideSwipe touchcancel.sitePopupSlideSwipe', swipeSelector)
6733		                       .on('touchstart.sitePopupSlideSwipe', swipeSelector, function(e) {
6734		                var event = e.originalEvent,
6735		                    touch = (event && event.touches && event.touches.length) ? event.touches[0] : null,
6736		                    $modal = $(this).closest('.banner-modal');
6737
6738		                if(!touch || ($(window).width() || window.innerWidth) > 767) return;
6739		                $modal.data('popupSlideTouch', {
6740		                    x: touch.clientX,
6741		                    y: touch.clientY
6742		                });
6743		            }).on('touchmove.sitePopupSlideSwipe', swipeSelector, function(e) {
6744		                var event = e.originalEvent,
6745		                    touch = (event && event.touches && event.touches.length) ? event.touches[0] : null,
6746		                    $modal = $(this).closest('.banner-modal'),
6747		                    touchData = $modal.data('popupSlideTouch');
6748
6749		                if(!touch || !touchData) return;
6750
6751		                var moveX = touch.clientX - touchData.x,
6752		                    moveY = touch.clientY - touchData.y,
6753		                    absX = Math.abs(moveX),
6754		                    absY = Math.abs(moveY);
6755
6756		                if(absX > 10 && absX > absY) {
6757		                    e.preventDefault();
6758		                }
6759		            }).on('touchend.sitePopupSlideSwipe', swipeSelector, function(e) {
6760		                var event = e.originalEvent,
6761		                    touch = (event && event.changedTouches && event.changedTouches.length) ? event.changedTouches[0] : null,
6762		                    $modal = $(this).closest('.banner-modal'),
6763		                    touchData = $modal.data('popupSlideTouch');
6764
6765		                $modal.removeData('popupSlideTouch');
6766		                if(!touch || !touchData) return;
6767
6768		                var moveX = touch.clientX - touchData.x,
6769		                    moveY = touch.clientY - touchData.y,
6770		                    absX = Math.abs(moveX),
6771		                    absY = Math.abs(moveY);
6772
6773		                if(absX < 40 || absX <= absY || $modal.find('> ul > li.banner-box:not(.hide)').length < 2) return;
6774
6775			                e.preventDefault();
6776			                e.stopPropagation();
6777			                if($.siteBanner.isPopupSlideManualMoving($modal)) return;
6778			                $.siteBanner.stopPopupSlideRollingModal($modal);
6779			                $.siteBanner.finishPopupSlide($modal);
6780			                $.siteBanner.nextPopupSlide($modal, (moveX < 0) ? 1 : -1, true);
6781			                $.siteBanner.startPopupSlideRollingModal($modal);
6782			            }).on('touchcancel.sitePopupSlideSwipe', swipeSelector, function(e) {
6783			                $(this).closest('.banner-modal').removeData('popupSlideTouch');
6784			            });
6785		        },
6786		        getPopupCloseButtonHeight: function(type, isSC, device, width) {
6787		            type = type || 'popup';
6788		            if(typeof $.siteBanner[type] != 'undefined' && $.siteBanner[type].close_btn == '1') return 0;
6789		            if(device != 'mobile') return 44;
6790		            if(isSC) return 36;
6791
6792		            var minWidth = 360,
6793		                maxWidth = 768,
6794		                minHeight = 44,
6795		                maxHeight = 56,
6796		                viewportWidth = Number(width || 0);
6797
6798		            if(!viewportWidth || viewportWidth < 1) viewportWidth = minWidth;
6799		            if(viewportWidth < minWidth) viewportWidth = minWidth;
6800		            if(viewportWidth > maxWidth) viewportWidth = maxWidth;
6801
6802		            return Math.round(minHeight + ((viewportWidth - minWidth) * (maxHeight - minHeight) / (maxWidth - minWidth)));
6803		        },
6804	        getPopupSlideSizeInfo: function(type, origin, width, isSC) {
6805	            type = type || 'popup';
6806
6807
6808	            var list = (typeof $.siteBanner[type] != 'undefined' && typeof $.siteBanner[type].list != 'undefined') ? $.siteBanner[type].list : {},
6809	                sort = (typeof $.siteBanner[type] != 'undefined' && typeof $.siteBanner[type].sort != 'undefined') ? $.siteBanner[type].sort : [],
6810	                targetWidth = Number(width || 0),
6811	                sizeInfo = {
6812	                    pc: {width: 0, height: 0},
6813	                    mobile: {width: 0, height: 0}
6814	                },
6815	                baseSize = {
6816	                    pc: {width: 0, height: 0},
6817	                    mobile: {width: 0, height: 0}
6818	                };
6819
6820	            if(!targetWidth || targetWidth < 1) targetWidth = 500;
6821
6822	            $.each(sort, function(idx, id) {
6823	                var o = list[id],
6824	                    isVisible = (type == 'popup') ? $.siteBanner.isPopupSlidePublishableItem(o) : ((o && o.visible == 'ON') ? true : false),
6825	                    isCookie = false,
6826	                    pcImg = null,
6827	                    mobileImg = null,
6828	                    pcWidth = 0,
6829	                    pcHeight = 0,
6830	                    mobileWidth = 0,
6831	                    mobileHeight = 0;
6832
6833	                if(!o || !o.img) return true;
6834	                if(!isVisible) return true;
6835
6836	                if(!isSC) {
6837	                    var cookieName = $.siteBanner.getBannerCookieName(type, id, 'slide');
6838	                    isCookie = (typeof $.cookie(cookieName) != 'undefined' && $.cookie(cookieName)) ? true : false;
6839	                    if(isCookie) return true;
6840	                }
6841
6842	                pcImg = o.img.pc || {};
6843	                mobileImg = (o.img.mobile && o.img.mobile.chk == '1') ? pcImg : (o.img.mobile || {});
6844
6845	                pcWidth = Number(pcImg.width || 0);
6846	                pcHeight = Number(pcImg.height || 0);
6847	                mobileWidth = Number(mobileImg.width || pcWidth || 0);
6848	                mobileHeight = Number(mobileImg.height || pcHeight || 0);
6849
6850		                if(pcWidth > 0 && pcHeight > 0) {
6851		                    if(baseSize.pc.width < pcWidth || (baseSize.pc.width == pcWidth && baseSize.pc.height < pcHeight)) {
6852		                        baseSize.pc.width = pcWidth;
6853		                        baseSize.pc.height = pcHeight;
6854		                    }
6855		                }
6856		                if(mobileWidth > 0 && mobileHeight > 0) {
6857		                    if(baseSize.mobile.width < mobileWidth || (baseSize.mobile.width == mobileWidth && baseSize.mobile.height < mobileHeight)) {
6858		                        baseSize.mobile.width = mobileWidth;
6859		                        baseSize.mobile.height = mobileHeight;
6860		                    }
6861		                }
6862		            });
6863
6864		            sizeInfo.pc.width = baseSize.pc.width;
6865		            sizeInfo.pc.height = baseSize.pc.height;
6866		            sizeInfo.mobile.width = baseSize.mobile.width;
6867		            sizeInfo.mobile.height = baseSize.mobile.height;
6868
6869		            if(sizeInfo.pc.width < 1) sizeInfo.pc.width = targetWidth;
6870		            if(sizeInfo.pc.height < 1) sizeInfo.pc.height = targetWidth;
6871		            if(sizeInfo.mobile.width < 1) sizeInfo.mobile.width = sizeInfo.pc.width;
6872		            if(sizeInfo.mobile.height < 1) sizeInfo.mobile.height = sizeInfo.pc.height;
6873
6874		            if(origin == 'OFF') {
6875		                var pcHeight = (baseSize.pc.width > 0) ? Math.round(targetWidth * baseSize.pc.height / baseSize.pc.width) : 0,
6876		                    mobileHeight = (baseSize.mobile.width > 0) ? Math.round(targetWidth * baseSize.mobile.height / baseSize.mobile.width) : 0;
6877
6878		                sizeInfo.pc.width = targetWidth;
6879		                sizeInfo.mobile.width = targetWidth;
6880	                if(pcHeight > 0) sizeInfo.pc.height = pcHeight;
6881	                if(mobileHeight > 0) sizeInfo.mobile.height = mobileHeight;
6882	            }
6883
6884	            if(sizeInfo.pc.height < 1) sizeInfo.pc.height = sizeInfo.mobile.height;
6885	            if(sizeInfo.mobile.height < 1) sizeInfo.mobile.height = sizeInfo.pc.height;
6886
6887		            var maxPcWidth = 0,
6888		                maxPcHeight = 0,
6889		                maxMobileWidth = 0,
6890		                maxMobileHeight = 0,
6891		                previewPcWidth = 0,
6892		                previewPcHeight = 0,
6893		                previewMobileWidth = 0,
6894		                previewMobileHeight = 0,
6895			                bodyWidth = 0,
6896			                windowWidth = 0,
6897			                windowHeight = 0,
6898			                pcCloseBtnHeight = 0,
6899			                mobileCloseBtnHeight = 0,
6900			                renderCloseBtnHeight = 0,
6901				                fitPopupSlideSize = function(size, maxWidth, maxHeight) {
6902			                    var nextWidth = Number(size.width || 0),
6903			                        nextHeight = Number(size.height || 0),
6904			                        ratio = 1;
6905
6906		                    if(nextWidth < 1 || nextHeight < 1) return;
6907		                    if(maxWidth > 0 && nextWidth > maxWidth) {
6908		                        ratio = maxWidth / nextWidth;
6909		                        nextWidth = maxWidth;
6910		                        nextHeight = Math.round(nextHeight * ratio);
6911		                    }
6912		                    if(maxHeight > 0 && nextHeight > maxHeight) {
6913		                        ratio = maxHeight / nextHeight;
6914		                        nextHeight = maxHeight;
6915		                        nextWidth = Math.round(nextWidth * ratio);
6916		                    }
6917			                    size.width = nextWidth;
6918			                    size.height = nextHeight;
6919			                },
6920			                fillPopupSlideWidth = function(size, maxWidth) {
6921			                    var nextWidth = Number(size.width || 0),
6922			                        nextHeight = Number(size.height || 0),
6923			                        ratio = 1;
6924
6925			                    if(maxWidth < 1 || nextWidth < 1 || nextHeight < 1) return;
6926			                    ratio = maxWidth / nextWidth;
6927			                    size.width = maxWidth;
6928			                    size.height = Math.round(nextHeight * ratio);
6929			                };
6930
6931		            if(isSC) {
6932		                previewPcWidth = $('#el-siteConfig .sc-body').innerWidth();
6933		                if(!previewPcWidth || previewPcWidth < 1) previewPcWidth = $('#el-siteConfig .sc-popupBanner.p').innerWidth();
6934		                if(!previewPcWidth || previewPcWidth < 1) previewPcWidth = $('#el-siteConfig .sc-popupBanner').innerWidth();
6935		                if(previewPcWidth > 0) maxPcWidth = previewPcWidth - 60;
6936		                previewPcHeight = $('#el-siteConfig .sc-popupBanner.p').innerHeight();
6937		                if(!previewPcHeight || previewPcHeight < 1) previewPcHeight = $('#el-siteConfig .sc-popupBanner').innerHeight();
6938		                if(!previewPcHeight || previewPcHeight < 1) {
6939		                    previewPcHeight = $('#el-siteConfig .sc-body').height();
6940		                    if(previewPcHeight > 216) previewPcHeight = previewPcHeight - 216;
6941		                }
6942		                pcCloseBtnHeight = $.siteBanner.getPopupCloseButtonHeight(type, isSC, 'pc', previewPcWidth);
6943		                if(previewPcHeight > 0) maxPcHeight = previewPcHeight - 30 - pcCloseBtnHeight;
6944		                previewMobileWidth = $('#el-siteConfig .sc-popupBanner.m').innerWidth();
6945		                if(!previewMobileWidth || previewMobileWidth < 1) previewMobileWidth = 480;
6946		                maxMobileWidth = previewMobileWidth - 60;
6947		                previewMobileHeight = $('#el-siteConfig .sc-popupBanner.m > .banner-modal').innerHeight();
6948		                if(!previewMobileHeight || previewMobileHeight < 1) previewMobileHeight = 526;
6949		                mobileCloseBtnHeight = $.siteBanner.getPopupCloseButtonHeight(type, isSC, 'mobile', previewMobileWidth);
6950		                if(previewMobileHeight > 0) maxMobileHeight = previewMobileHeight - 30 - mobileCloseBtnHeight;
6951		            } else {
6952		                bodyWidth = $('.dsgn-body').width();
6953		                windowWidth = $(window).width();
6954		                windowHeight = $(window).height();
6955		                renderCloseBtnHeight = $.siteBanner.getPopupCloseButtonHeight(type, isSC, (windowWidth > 0 && windowWidth <= 768) ? 'mobile' : 'pc', windowWidth || bodyWidth);
6956		                if(windowWidth > 0 && windowWidth <= 767) maxMobileWidth = windowWidth - 60;
6957		                else if(bodyWidth > 0) maxPcWidth = bodyWidth - 60;
6958		                else if(windowWidth > 0) maxPcWidth = windowWidth - 60;
6959		                if(windowHeight > 0) {
6960		                    maxPcHeight = windowHeight - 60 - renderCloseBtnHeight;
6961		                    maxMobileHeight = windowHeight - 60 - renderCloseBtnHeight;
6962		                }
6963		            }
6964
6965			            fitPopupSlideSize(sizeInfo.pc, maxPcWidth, 0);
6966			            fitPopupSlideSize(sizeInfo.mobile, maxMobileWidth, maxMobileHeight);
6967			            fillPopupSlideWidth(sizeInfo.mobile, maxMobileWidth);
6968
6969	            return sizeInfo;
6970	        },
6971	        applyPopupSlideBoxSize: function(target, sizeInfo) {
6972	            var $items = $(target),
6973	                pcWidth = Number(sizeInfo && sizeInfo.pc ? sizeInfo.pc.width : 0),
6974	                pcHeight = Number(sizeInfo && sizeInfo.pc ? sizeInfo.pc.height : 0),
6975	                mobileWidth = Number(sizeInfo && sizeInfo.mobile ? sizeInfo.mobile.width : 0),
6976	                mobileHeight = Number(sizeInfo && sizeInfo.mobile ? sizeInfo.mobile.height : 0);
6977
6978	            if(!$items.length) return;
6979	            if(pcWidth < 1) pcWidth = mobileWidth || 500;
6980	            if(pcHeight < 1) pcHeight = mobileHeight || pcWidth;
6981	            if(mobileWidth < 1) mobileWidth = pcWidth;
6982	            if(mobileHeight < 1) mobileHeight = pcHeight;
6983
6984	            $items.each(function() {
6985	                this.style.setProperty('--popup-slide-box-width-pc', pcWidth + 'px');
6986	                this.style.setProperty('--popup-slide-box-height-pc', pcHeight + 'px');
6987	                this.style.setProperty('--popup-slide-box-width-mobile', mobileWidth + 'px');
6988	                this.style.setProperty('--popup-slide-box-height-mobile', mobileHeight + 'px');
6989	            });
6990		            $items.css({'width': '', 'height': ''});
6991		            $items.find('.banner-content, .banner-body, .banner-body > a, .banner-img').css({'width': '', 'height': ''});
6992		            $items.find('.banner-img > img').css({'width': '', 'height': '', 'max-width': '', 'max-height': ''});
6993		        },
6994		        setPopupRadiusCss: function(target, radius) {
6995		            var popupRadius = Number(radius || 0),
6996		                popupMobileRadius = popupRadius * 0.75;
6997
6998		            $(target).each(function() {
6999		                this.style.setProperty('--popup-radius', popupRadius + 'px');
7000		                this.style.setProperty('--popup-radius-mobile', popupMobileRadius + 'px');
7001		            });
7002		        },
7003		        getPopupSlideControlSizeValue: function(val, fallback) {
7004		            var sizes = [28, 40, 52, 64, 76],
7005		                n = parseInt(String(val || fallback || 52).replace(/[^0-9]/g, ''), 10),
7006		                closest = parseInt(fallback || 52, 10),
7007		                minDiff = 9999;
7008
7009		            if(isNaN(n)) n = parseInt(fallback || 52, 10);
7010		            $.each(sizes, function(i, size) {
7011		                var diff = Math.abs(size - n);
7012		                if(diff < minDiff) {
7013		                    minDiff = diff;
7014		                    closest = size;
7015		                }
7016		            });
7017
7018		            return String(closest);
7019		        },
7020		        getPopupSlideStyleValues: function(max) {
7021		            var values = [];
7022
7023		            for(var i = 1; i <= max; i++) values.push(String(i));
7024
7025		            return values;
7026		        },
7027		        isPopupSlideArrowStyleValue: function(val) {
7028		            return ($.inArray(String(val), $.siteBanner.getPopupSlideStyleValues(27)) > -1);
7029		        },
7030		        isPopupSlidePaginationStyleValue: function(val) {
7031		            return ($.inArray(String(val), $.siteBanner.getPopupSlideStyleValues(18)) > -1);
7032		        },
7033		        getPopupSlidePaginationTypeByStyle: function(style) {
7034		            style = String(style || '11');
7035
7036		            return ($.inArray(style, ['11','12','13']) > -1) ? 'number' : 'dot';
7037		        },
7038		        setPopupSvgColor: function(svg, color) {
7039		            var $svg = $(svg),
7040		                fillTargets = 'path, circle, rect, polygon, line, polyline, ellipse, text';
7041
7042			            color = $.siteBanner.getCssColorValue(color, '#222428');
7043			            $svg.attr('data-color', color);
7044		            $svg.find(fillTargets).each(function() {
7045		                var $el = $(this),
7046		                    fill = $el.attr('fill'),
7047		                    stroke = $el.attr('stroke'),
7048		                    styleAttr = $el.attr('style') || '';
7049
7050		                if(fill != 'none' && styleAttr.indexOf('fill:none') < 0) {
7051		                    $el.attr('fill', color).css('fill', color);
7052		                }
7053		                if(stroke && stroke != 'none') {
7054		                    $el.attr('stroke', color).css('stroke', color);
7055		                }
7056		            });
7057
7058		            return $svg;
7059		        },
7060		        getPopupSlideArrowStylePreviewMap: function() {
7061		            return {
7062		                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>',
7063		                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>',
7064		                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>',
7065		                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>',
7066		                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>',
7067		                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>',
7068		                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>',
7069		                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 
70691.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>',
7070		                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>',
7071		                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>',
7072		                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>',
7073		                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>',
7074		                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>',
7075		                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>',
7076		                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>',
7077		                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>',
7078		                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>',
7079		                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>',
7080		                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>',
7081		                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>',
7082		                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>',
7083		                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>',
7084		                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>',
7085		                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>',
7086		                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>',
7087		                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
7087ZM6.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 
70871.87.53l.32-.95c-.65-.22-1.31-.41-1.97-.56ZM20.67 32l8.66-8-8.66-8v16z"/></svg>',
7088		                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>'
7089		            };
7090		        },
7091		        getPopupSlideArrowStylePreviewSvg: function(style) {
7092		            var navObj = $.siteBanner.getPopupSlideArrowStylePreviewMap();
7093
7094		            style = String(style || '1');
7095		            if(typeof navObj[style] == 'undefined') style = '1';
7096
7097		            return navObj[style] || '';
7098		        },
7099		        getPopupSlideArrowStyleSvg: function(style, color, size) {
7100		            var svgHtml = '',
7101		                svgSize = parseInt(String(size || '52').replace(/[^0-9]/g, ''), 10),
7102		                $wrap = null,
7103		                $svg = null;
7104
7105		            if(isNaN(svgSize) || svgSize < 1) svgSize = 52;
7106		            style = String(style || '1');
7107		            if(!$.siteBanner.isPopupSlideArrowStyleValue(style)) style = '1';
7108		            color = color || '#222428';
7109
7110		            if(typeof contentsSliderNav == 'function') {
7111		                $wrap = $('<div></div>').append(contentsSliderNav(Number(svgSize), Number(style)));
7112		                $svg = $wrap.find('.slider-nav-btn.next svg').eq(0).clone();
7113		                if(!$svg.length) $svg = $wrap.find('svg').eq(0).clone();
7114		                if($svg.length) {
7115		                    $svg.addClass('banner-slide-arrow-icon').attr({'width':svgSize,'height':svgSize});
7116		                    if(!$svg.attr('viewBox')) $svg.attr('viewBox', '0 0 ' + svgSize + ' ' + svgSize);
7117		                    $.siteBanner.setPopupSvgColor($svg, color);
7118		                    svgHtml = $('<div></div>').append($svg).html();
7119		                }
7120		            }
7121		            if(!svgHtml) {
7122		                $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>');
7123		                svgHtml = $('<div></div>').append($svg).html();
7124		            }
7125
7126		            return svgHtml;
7127		        },
7128		        getPopupSlideArrowStyleListHtml: function() {
7129		            var html = '',
7130		                navObj = $.siteBanner.getPopupSlideArrowStylePreviewMap();
7131
7132		            $.each(navObj, function(n, v) {
7133		                html += '<li role="presentation"><a data-value="' + n + '">' + v + '</a></li>';
7134		            });
7135
7136		            return html;
7137		        },
7138		        getPopupSlidePaginationStyleMap: function() {
7139		            return {
7140		                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>',
7141		                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>',
7142		                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>',
7143		                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>',
7144		                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>',
7145		                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>',
7146		                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>',
7147		                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>',
7148		                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
7148-.67-.13c-.33 0-.58.04-.75.13-.17.09-.34.21-.52.37Z" style="fill:#fff;"/></g></svg>',
7149		                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>',
7150		                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>',
7151		                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>',
7152		                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>',
7153		                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>',
7154		                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>',
7155		                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>',
7156		                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>',
7157		                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;" />
7157<path id="Rectangle_1719" d="M64.5 20.5h31v1h-31z" style="opacity:.25;"/><path id="Rectangle_1718" d="M2.5 20.5h31v1h-31z" /></svg>'
7158		            };
7159		        },
7160		        getPopupSlidePaginationStyleOrder: function() {
7161		            return $.siteBanner.getPopupSlideStyleValues(18);
7162		        },
7163		        getPopupSlidePaginationStylePreviewSvg: function(style) {
7164		            var pageObj = $.siteBanner.getPopupSlidePaginationStyleMap();
7165
7166		            style = String(style || '11');
7167		            if(typeof pageObj[style] == 'undefined') style = '11';
7168
7169		            return pageObj[style] || '';
7170		        },
7171		        getPopupSlidePaginationStyleSvg: function(style, color) {
7172		            var pageObj = $.siteBanner.getPopupSlidePaginationStyleMap(),
7173		                $svg = null;
7174
7175		            style = String(style || '11');
7176		            if(!$.siteBanner.isPopupSlidePaginationStyleValue(style)) style = '11';
7177		            color = color || '#222428';
7178		            $svg = $(pageObj[style] || pageObj['11']).clone();
7179		            $svg.attr('data-color', color);
7180
7181		            return $('<div></div>').append($svg).html();
7182		        },
7183		        getPopupSlidePaginationStyleListHtml: function() {
7184		            var html = '',
7185		                pageObj = $.siteBanner.getPopupSlidePaginationStyleMap();
7186
7187		            $.each($.siteBanner.getPopupSlidePaginationStyleOrder(), function(i, n) {
7188		                html += '<li role="presentation"><a data-value="' + n + '">' + (pageObj[n] || '') + '</a></li>';
7189		            });
7190
7191		            return html;
7192		        },
7193		        isPopupSlideMobilePreviewModal: function(modal) {
7194		            var $modal = $(modal);
7195
7196		            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')));
7197		        },
7198		        isPopupSlideMobileRenderModal: function(modal) {
7199		            var $modal = $(modal);
7200
7201		            return ($.siteBanner.isPopupSlideMobilePreviewModal($modal) || ($modal.closest('.cl-popupBanner').length > 0 && $.siteBanner.getPopupSli
7201deMobileArrowSize() > 0));
7202		        },
7203		        getPopupSlideMobileArrowSize: function(width) {
7204		            var w = Number(width || $(window).width() || $('body').width() || 0);
7205
7206		            if(w > 768 || w < 1) return 0;
7207		            if(w >= 721) return 52;
7208		            if(w >= 621) return 51;
7209		            if(w >= 521) return 50;
7210		            if(w >= 421) return 49;
7211		            return 48;
7212		        },
7213		        getPopupSlideArrowIconRenderSize: function(modal, fallback) {
7214		            var $modal = $(modal),
7215		                size = Number($.siteBanner.getPopupSlideControlSizeValue(fallback, '64')),
7216		                mobileSize = 0;
7217
7218		            if($.siteBanner.isPopupSlideMobilePreviewModal($modal)) return 36;
7219		            if($modal.closest('.cl-popupBanner').length) {
7220		                mobileSize = $.siteBanner.getPopupSlideMobileArrowSize();
7221		                if(mobileSize > 0) return mobileSize;
7222		            }
7223
7224		            return size;
7225		        },
7226				        getPopupSlidePaginationRenderSize: function(modal, fallback, style) {
7227				            var $modal = $(modal),
7228				                styleString = String(style || $modal.attr('data-slidepaginationstyle') || (($modal.attr('data-slidepagination') == 'dot') ? '1' : '11')),
7229				                compactMobileStyles = ['9','10','11','12','13','14'],
7230				                isCompactMobileStyle = ($.inArray(styleString, compactMobileStyles) > -1);
7231
7232				            if($.siteBanner.isPopupSlideMobilePreviewModal($modal)) return (isCompactMobileStyle) ? '28' : '40';
7233				            if($.siteBanner.isPopupSlideMobileRenderModal($modal)) return (isCompactMobileStyle) ? '40' : '52';
7234
7235				            return $.siteBanner.getPopupSlideControlSizeValue(fallback, '52');
7236				        },
7237		        updatePopupSlideArrowIcons: function(modal, style, color) {
7238		            var $modal = $(modal),
7239		                arrowSize = $.siteBanner.getPopupSlideControlSizeValue($modal.attr('data-slidearrowsize') || $.siteBanner.getPopupSlideCssValue($modal, '--popup-slide-arrow-icon-size', '64'), '64'),
7240		                arrowIconSize = $.siteBanner.getPopupSlideArrowIconRenderSize($modal, arrowSize),
7241		                prevSvgHtml = $.siteBanner.getPopupSlideArrowStyleSvg(style, color, arrowIconSize),
7242		                nextSvgHtml = $.siteBanner.getPopupSlideArrowStyleSvg(style, color, arrowIconSize);
7243
7244		            $modal.find('.banner-slide-arrow > .banner-slide-prev').html(prevSvgHtml)
7245		                .find('.banner-slide-arrow-icon').attr({'width':arrowIconSize,'height':arrowIconSize}).css({
7246		                    'width': arrowIconSize + 'px',
7247		                    'height': arrowIconSize + 'px',
7248		                    'transform': '',
7249		                    'transform-origin': ''
7250		                });
7251		            $modal.find('.banner-slide-arrow > .banner-slide-next').html(nextSvgHtml)
7252		                .find('.banner-slide-arrow-icon').attr({'width':arrowIconSize,'height':arrowIconSize}).css({
7253		                    'width': arrowIconSize + 'px',
7254		                    'height': arrowIconSize + 'px',
7255		                    'transform': '',
7256		                    'transform-origin': ''
7257		                });
7258		        },
7259		        applyPopupSlideControlSize: function(modal, arrowSize, paginationSize) {
7260		            var $modal = $(modal),
7261		                modalEl = $modal.get(0),
7262					                aSize = Number($.siteBanner.getPopupSlideControlSizeValue(arrowSize, '64')),
7263					                arrowIconSize = $.siteBanner.getPopupSlideArrowIconRenderSize($modal, aSize),
7264					                mobileArrowBoxSize = ($.siteBanner.isPopupSlideMobilePreviewModal($modal)) ? 36 : (($modal.closest('.cl-popupBanner').length) ? $.siteBanner.getPopupSlideMobileArrowSize() : 0),
7265							                pSize = Number($.siteBanner.getPopupSlideControlSizeValue(paginationSize, '52')),
7266							                paginationStyleValue = $modal.attr('data-slidepaginationstyle') || (($modal.attr('data-slidepagination') == 'dot') ? '1' : '11'),
7267							                pRenderSize = Number($.siteBanner.getPopupSli
7267dePaginationRenderSize($modal, pSize, paginationStyleValue)),
7268						                isMobilePaginationRender = $.siteBanner.isPopupSlideMobileRenderModal($modal),
7269				                arrowBoxSize = 76,
7270				                pRatio = pSize / 52,
7271						                pRenderRatio = pRenderSize / 52,
7272				                paginationSizeMap = {
7273				                    '28': { width: 32, height: 18, fontSize: 12 },
7274				                    '40': { width: 38, height: 23, fontSize: 14 },
7275				                    '52': { width: 50, height: 28, fontSize: 15 },
7276			                    '64': { width: 52, height: 30, fontSize: 16 },
7277			                    '76': { width: 56, height: 32, fontSize: 18 }
7278				                },
7279				                paginationStyle = paginationSizeMap[String(pSize)] || paginationSizeMap['52'],
7280						                paginationMobileStyle = paginationSizeMap[String(pRenderSize)] || paginationSizeMap['52'],
7281				                paginationWidth = paginationStyle.width,
7282				                paginationHeight = paginationStyle.height,
7283				                paginationPaddingY = 0,
7284				                paginationPaddingX = 0,
7285			                paginationFontSize = paginationStyle.fontSize,
7286			                paginationDotSize = Math.max(Math.round(7 * pRatio), 4),
7287			                paginationGap = Math.max(Math.round(6 * pRatio), 4);
7288
7289			            if(!modalEl) return;
7290			            $(modal).attr({'data-slidearrowsize':String(aSize), 'data-slidepaginationsize':String(pSize)});
7291			            modalEl.style.setProperty('--popup-slide-arrow-size', arrowBoxSize + 'px');
7292			            modalEl.style.setProperty('--popup-slide-arrow-margin-top', '-' + Math.round(arrowBoxSize / 2) + 'px');
7293					            modalEl.style.setProperty('--popup-slide-arrow-icon-size', aSize + 'px');
7294					            modalEl.style.setProperty('--popup-slide-arrow-tablet-size', arrowBoxSize + 'px');
7295					            modalEl.style.setProperty('--popup-slide-arrow-tablet-margin-top', '-' + Math.round(arrowBoxSize / 2) + 'px');
7296					            modalEl.style.setProperty('--popup-slide-arrow-tablet-icon-size', aSize + 'px');
7297				            if(mobileArrowBoxSize > 0) {
7298				                modalEl.style.setProperty('--popup-slide-arrow-mobile-size', mobileArrowBoxSize + 'px');
7299				                modalEl.style.setProperty('--popup-slide-arrow-mobile-margin-top', '-' + (mobileArrowBoxSize / 2) + 'px');
7300				                modalEl.style.setProperty('--popup-slide-arrow-mobile-icon-size', mobileArrowBoxSize + 'px');
7301				            } else {
7302				                modalEl.style.removeProperty('--popup-slide-arrow-mobile-size');
7303				                modalEl.style.removeProperty('--popup-slide-arrow-mobile-margin-top');
7304				                modalEl.style.removeProperty('--popup-slide-arrow-mobile-icon-size');
7305				            }
7306				            $modal.find('.banner-slide-arrow-icon').attr({'width':String(arrowIconSize),'height':String(arrowIconSize)}).css({'width':arrowIconSize + 'px','height':arrowIconSize + 'px'});
7307			            modalEl.style.setProperty('--popup-slide-pagination-width', paginationWidth + 'px');
7308			            modalEl.style.setProperty('--popup-slide-pagination-height', paginationHeight + 'px');
7309			            modalEl.style.setProperty('--popup-slide-pagination-padding', paginationPaddingY + 'px ' + paginationPaddingX + 'px');
7310				            modalEl.style.setProperty('--popup-slide-pagination-font-size', paginationFontSize + 'px');
7311				            modalEl.style.setProperty('--popup-slide-pagination-dot-size', paginationDotSize + 'px');
7312				            modalEl.style.setProperty('--popup-slide-pagination-gap', paginationGap + 'px');
7313					            modalEl.style.setProperty('--slider-page-size', pRenderSize + 'px');
7314				            modalEl.style.setProperty('--slider-nav-size', arrowIconSize + 'px');
7315				            if(isMobilePaginationRender) {
7316				                modalEl.style.setProperty('--popup-slide-pagination-mobile-width', paginationMobileStyle.width + 'px');
7317				                modalEl.style.setProperty('--popup-slide-pagination-mobile-height', paginationMobileStyle.height + 'px');
7318				                modalEl.style.setProperty('--popup-slide-pagination-mobile-padding', '0');
7319				                modalEl.style.setProperty('--popup-slide-pagination-mobile-font-size', paginationMobileStyle.fontSize + 'px');
7320				                modalEl.style.setProperty('--popup-slide-pagination-mobile-dot-size', Math.max(Math.round(7 * pRenderRatio), 4) + 'px');
7321				                modalEl.style.setProperty('--popup-slide-pagination-mobile-gap', Math.max(Math.round(6 * pRenderRatio), 4) + 'px');
7322				            } else {
7323				                modalEl.style.removeProperty('--popup-slide-pagination-mobile-width');
7324				                modalEl.style.removeProperty('--popup-slide-pagination-mobile-height');
7325				                modalEl.style.removeProperty('--popup-slide-pagination-mobile-padding');
7326				                modalEl.style.removeProperty('--popup-slide-pagination-mobile-font-size');
7327				                modalEl.style.removeProperty('--popup-slide-pagination-mobile-dot-size');
7328				                modalEl.style.removeProperty('--popup-slide-pagination-mobile-gap');
7329				            }
7330			        },
7331		        setPopupSlide: function(isSC) {
7332	            var selector = (isSC) ? '#el-siteConfig .sc-popupBanner' : '.cl-popupBanner',
7333	                $banner = $(selector);
7334
7335	            $.siteBanner.bindPopupSlideEvents();
7336	            $.siteBanner.stopPopupSlideRolling(selector);
7337
7338	            $banner.find('> .banner-modal').each(function() {
7339	                var $modal = $(this),
7340	                    isSlide = ($modal.attr('data-viewtype') == 'slide'),
7341	                    isAuto = (($modal.attr('data-slideauto') || ((typeof $.siteBanner.popup != 'undefined') ? $.siteBanner.popup.slide_auto : 'OFF')) != 'OFF'),
7342	                    isScPopupPanelOpen = (isSC && $('#el-siteConfig[data-fn="banner"] #popup-banner-accordion .panel-banner-item.open').length > 0) ? true : false,
7343	                    $items = $modal.find('> ul > li.banner-box:not(.hide)'),
7344	                    total = $items.length;
7345
7346	                if(!isSlide) {
7347	                    $modal.find('> ul > li.banner-box').removeClass('active').css('display', '');
7348	                    $modal.find('.banner-slide-pagination').empty();
7349	                    return;
7350	                }
7351		                if(total < 1) {
7352		                    $modal.find('.banner-slide-arrow').addClass('hide');
7353		                    $modal.find('.banner-slide-pagination').addClass('hide').empty();
7354		                    return;
7355		                }
7356
7357		                $.siteBanner.applyPopupSlideControlSize($modal, $modal.attr('data-slidearrowsize'), $modal.attr('data-slidepaginationsize'));
7358		                $.siteBanner.updatePopupSlideArrowIcons($modal, $modal.attr('data-slidearrowstyle') || '1', $.siteBanner.getPopupSlideCssValue($modal, '--popup-slide-arrow-color', '#ffffff'));
7359		                if($modal.attr('data-slide-moving')) $.siteBanner.finishPopupSlide($modal);
7360		                $.siteBanner.showPopupSlide($modal, Number($modal.attr('data-slide-index') || 0), 0);
7361
7362			                if(total >
7362 1 && isAuto && !isScPopupPanelOpen) $.siteBanner.startPopupSlideRollingModal($modal);
7363		            });
7364	        },
7365	        getPopupSlideCssValue: function(modal, key, fallback) {
7366	            var $modal = $(modal),
7367	                modalEl = $modal.get(0),
7368	                val = '';
7369
7370	            if(modalEl && window.getComputedStyle) val = window.getComputedStyle(modalEl).getPropertyValue(key);
7371	            if(!val) val = $modal.css(key);
7372	            val = $.trim(val || '');
7373
7374	            return val || fallback;
7375	        },
7376			        applyPopupSlideControlColors: function(modal) {
7377			            var $modal = $(modal),
7378			                arrowColor = $.siteBanner.getPopupSlideCssValue($modal, '--popup-slide-arrow-color', '#ffffff'),
7379		                paginationColor = $.siteBanner.getPopupSlideCssValue($modal, '--popup-slide-pagination-color', '#ffffff'),
7380		                paginationActiveColor = $.siteBanner.getPopupSlideCssValue($modal, '--popup-slide-pagination-active-color', '#000000');
7381
7382		            $modal.find('.banner-slide-arrow > button').css('background-color', '');
7383		            $modal.find('.banner-slide-arrow-icon').each(function() {
7384		                $.siteBanner.setPopupSvgColor(this, arrowColor);
7385		            });
7386
7387		            $modal.find('.banner-slide-pagination').css({'color': '', 'background-color': ''});
7388		            $modal.find('.banner-slide-pagination .active').css('color', '');
7389			            $modal.find('.banner-slide-dot').css('background-color', '');
7390			            $modal.find('.banner-slide-dot.active').css('background-color', '');
7391			        },
7392		        placePopupSlideControls: function(modal, item) {
7393		            var $modal = $(modal),
7394			                $item = $(item),
7395			                $body = $item.find('.banner-body').eq(0),
7396			                $content = $item.find('> .banner-content').eq(0),
7397			                $imageArea = $body.find('.banner-img').eq(0),
7398			                $arrow = $modal.find('.banner-slide-arrow').eq(0),
7399			                $pagination = $modal.find('.banner-slide-pagination').eq(0),
7400			                imageHeight = ($imageArea.length) ? $imageArea.outerHeight() : 0,
7401			                imageTop = ($imageArea.length) ? $imageArea.position().top : 0,
7402			                bodyHeight = ($body.length) ? $body.outerHeight() : 0,
7403			                contentHeight = ($content.length) ? $content.outerHeight() : 0,
7404			                arrowTop = (imageHeight > 0) ? (imageTop + (imageHeight / 2)) : ((bodyHeight || contentHeight) / 2);
7405
7406		            if(!$body.length) return;
7407		            if(arrowTop > 0) $body.get(0).style.setProperty('--popup-slide-arrow-top', arrowTop + 'px');
7408		            if($arrow.length) $body.append($arrow);
7409		            if($pagination.length) $body.append($pagination);
7410		        },
7411		        getPopupSlideSpeedValue: function(modal) {
7412		            var $modal = $(modal),
7413		                speed = $modal.attr('data-slidespeed') || ((typeof $.siteBanner.popup != 'undefined') ? $.siteBanner.popup.slide_speed : '3');
7414
7415	            speed = String(speed || '3');
7416	            if($.inArray(speed, ['1','2','3','4','5']) < 0) speed = '3';
7417
7418	            return speed;
7419	        },
7420	        getPopupSlideDelay: function(modal) {
7421	            var stopTime = $.siteBanner.getPopupSlideTimeValue(modal, 'data-slidestoptime', 'slide_stop_time', ''),
7422	                fallbackStopTime = '3';
7423
7424	            if(!stopTime) {
7425	                var speed = $.siteBanner.getPopupSlideSpeedValue(modal),
7426	                    delayMap = {
7427	                    '1': 7000,
7428	                    '2': 5000,
7429	                    '3': 3000,
7430	                    '4': 2000,
7431	                    '5': 1200
7432	                };
7433	                fallbackStopTime = String(Math.max(Math.round((delayMap[speed] || delayMap['3']) / 1000), 1));
7434	                stopTime = $.siteBanner.getPopupSlideTimeValue(modal, 'data-slidestoptime', 'slide_stop_time', fallbackStopTime);
7435	            }
7436
7437			            return $.siteBanner.getPopupSlideDuration(modal) + (Number(stopTime) * 1000);
7438			        },
7439				        updatePopupSlidePaginationState: function(pagination, style, index, total) {
7440				            var $pagination = $(pagination),
7441				                styleString = String(style || '11'),
7442				                bulletStyles = ['1','2','3','4','5','6','7','8','9','10','14','15','16','17','18'],
7443				                pageNumberStyles = ['9','10','14'],
7444				                dynamicBulletStyles = ['2','4'],
7445				                isDynamicBulletStyle = ($.inArray(styleString, dynamicBulletStyles) > -1),
7446				                $widthWrap = $pagination.find('> .swiper-pagination-width').eq(0),
7447				                $dots = (styleString == '18') ? $pagination.find('> span.banner-slide-dot') : $widthWrap.find('> span.banner-slide-dot'),
7448				                $indicator = $pagination.find('> .nav-indicator').eq(0),
7449				                dynamicMainBullets = 1,
7450				                dynamicWindowLength = dynamicMainBullets + 4,
7451				                dynamicBulletsLength = Math.min(total, dynamicWindowLength),
7452				                firstIndex = index,
7453				                lastIndex = index,
7454				                midIndex = index,
7455				                bulletSize = 0,
7456				                bulletsOffset = 0,
7457				                indicatorWidth = 100,
7458				                animateState = ($pagination.attr('data-popup-slide-pagination-ready') == '1'),
7459				                stateToken = Number($pagination.data('popupSlidePaginationFrame') || 0) + 1,
7460				                updates = [],
7461				                applyState,
7462				                i = 0,
7463				                dotClass = '',
7464				                num = '';
7465
7466				            if(!$pagination.length || $.inArray(styleString, bulletStyles) < 0 || $dots.length != total) return false;
7467				            if(styleString == '18' && !$indicator.length) return false;
7468
7469				            if(isDynamicBulletStyle && total > 0) {
7470				                bulletSize = $dots.eq(0).outerWidth(true) || parseInt($dots.eq(0).css('width'), 10) || 0;
7471				                if(bulletSize > 0 && $widthWrap.length) {
7472				                    bulletsOffset = (((bulletSize * dynamicBulletsLength) - bulletSize) / 2) - (midIndex * bulletSize);
7473				                    $pagination.css('width', (bulletSize * dynamicWindowLength) + 'px');
7474				                    $widthWrap.css('width', (bulletSize * dynamicWindowLength) + 'px');
7475				                }
7476				            } else {
7477				                $pagination.css('width', '');
7478				                if($widthWrap.length) $widthWrap.css('width', '');
7479				                $dots.css('left', '');
7480				            }
7481
7482				            for(i = 0; i < total; i++) {
7483				                dotClass = 'banner-slide-dot swiper-pagination-bullet';
7484				                if(i == index) dotClass += ' swiper-pagination-bullet-active active';
7485				                if(isDynamicBulletStyle) {
7486				                    if(i >= firstIndex && i <= lastIndex) dotClass += ' swiper-pagination-bullet-active-main';
7487				                    if(i == firstIndex - 1) dotClass += ' swiper-pagination-bullet-active-prev';
7488				                    if(i == firstIndex - 2) dotClass += ' swiper-pagination-bullet-active-prev-prev';
7489				                    if(i == lastIndex + 1) dotClass += ' swiper-pagination-bullet-active-next';
7490				                    if(i == lastIndex + 2) dotClass += ' swiper-pagination-bullet-active-next-next';
7491				                }
7492				                num = (i + 1);
7493				                if($.inArray(styleString, pageNumberStyles) > -1 && num < 10 && styleString != '14') num = '0' + num;
7494				                $dots.eq(i).attr('data-index', i).text(($.inArray(styleString, pageNumberStyles) > -1) ? num : '');
7495				                updates.push({el:$dots.get(i), className:dotClass});
7496				            }
7497
7498				            $pagination.attr('data-popup-slide-pagination-ready', '1');
7499				            $pagination.data('popupSlidePaginationFrame', stateToken);
7500				            applyState = function() {
7501				                var j = 0;
7502				                if(Number($pagination.data('popupSlidePaginationFrame')) !== stateToken) return;
7503				                for(j = 0; j < updates.length; j++) {
7504				                    if(!updates[j].el) continue;
7505				                    updates[j].el.className = updates[j].className;
7506				                    if(isDynamicBulletStyle && bulletSize > 0) updates[j].el.style.left = bulletsOffset + 'px';
7507				                    else updates[j].el.style.left = '';
7508				                }
7509				                if(styleString == '18') {
7510				                    indicatorWidth = (total > 0) ? (100 / total) : 100;
7511				                    $indicator.css({'width':indicatorWidth + '%','height':'2px','transform':'translateX(' + (index * 100) + '%)'});
7512				                }
7513				            };
7514
7515				            if(animateState && typeof window != 'undefined' && window.requestAnimationFrame) window.requestAnimationFrame(applyState);
7516				            else applyState();
7517
7518				            return true;
7519				        },
7520				        getPopupSlideDuration: function(modal, isManual) {
7521				            return 1000;
7522				        },
7523	        getPopupSlideTimeValue: function(modal, attr, stateKey, fallback) {
7524	            var $modal = $(modal),
7525	                val = $modal.attr(attr) || ((typeof $.siteBanner.popup != 'undefined') ? $.siteBanner.popup[stateKey] : '') || fallback || '';
7526
7527	            val = String(val || '').replace(/[^0-9]/g, '');
7528	            if(val == '') return '';
7529	            if(Number(val) < 1) val = '1';
7530	            if(Number(val) > 10) val = '10';
7531
7532		            return val;
7533		        },
7534		        getPopupSlidePaginationHtml: function(style, index, total) {
7535		            var html = '',
7536		                i = 0,
7537		                num = '',
7538		                bulletClass = '',
7539		                pageNumberStyles = ['9','10','14'],
7540		                fractionStyle = ($.inArray(String(style), ['11','12','13']) > -1),
7541		                dynamicBulletStyles = ['2','4'],
7542		                isDynamicBulletStyle = false,
7543		                prevIndex = -1,
7544		                nextIndex = -1,
7545		                indicatorWidth = 100,
7546		                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>';
7547
7548		            style = String(style || '11');
7549		            if(!$.siteBanner.isPopupSlidePaginationStyleValue(style)) style = '11';
7550		            isDynamicBulletStyle = ($.inArray(style, dynamicBulletStyles) > -1);
7551		            if(isDynamicBulletStyle && total > 1) {
7552		                prevIndex = index - 1;
7553		                nextIndex = index + 1;
7554		            }
7555
7556		            if(fractionStyle) {
7557		                html = '<div class="fraction-capsule">';
7558		                if(style == '12') {
7559		                    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>';
7560		                    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>';
7561		                } else {
7562		                    html += '<span class="swiper-pagination-current">' + (index + 1) + '</span><span class="separator">/</span><span class="swiper-pagination-total">' + total + '</span>';
7563		                }
7564		                html += '</div>';
7565		                return html;
7566		            }
7567
7568		            if(style != '18') html += '<div class="swiper-pagination-width">';
7569		            for(i = 0; i < total; i++) {
7570		                bulletClass = 'banner-slide-dot swiper-pagination-bullet';
7571		                if(i == index) {
7572		                    bulletClass += ' swiper-pagination-bullet-active active';
7573		                    if(isDynamicBulletStyle) bulletClass += ' swiper-pagination-bullet-active-main';
7574		                } else if(isDynamicBulletStyle && i == prevIndex) {
7575		                    bulletClass += ' swiper-pagination-bullet-active-prev';
7576		                } else if(isDynamicBulletStyle && i == nextIndex) {
7577		                    bulletClass += ' swiper-pagination-bullet-active-next';
7578		                } else if(isDynamicBulletStyle && i == prevIndex - 1) {
7579		                    bulletClass += ' swiper-pagination-bullet-active-prev-prev';
7580		                } else if(isDynamicBulletStyle && i == nextIndex + 1) {
7581		                    bulletClass += ' swiper-pagination-bullet-active-next-next';
7582		                }
7583		                num = (i + 1);
7584		                if($.inArray(style, pageNumberStyles) > -1 && num < 10 && style != '14') num = '0' + num;
7585		                html += '<span class="' + bulletClass + '" data-index="' + i + '">' + (($.inArray(style, pageNumberStyles) > -1) ? num : '') + '</span>';
7586		            }
7587		            if(style != '18') html += '</div>';
7588		            if(style == '18') {
7589		                indicatorWidth = (total > 0) ? (100 / total) : 100;
7590		                html += '<div class="nav-indicator" style="width:' + indicatorWidth + '%;height:2px;transform:translateX(' + (index * 100) + '%);"></div>';
7591		            }
7592
7593		            return html;
7594		        },
7595			        showPopupSlide: function(modal, index, direction, isManual) {
7596			            var $modal = $(modal),
7597			                $ul = $modal.find('> ul'),
7598		                $items = $modal.find('> ul > li.banner-box:not(.hide)'),
7599		                total = $items.length;
7600
7601		            if(!isManual && $modal.attr('data-slide-moving')) return;
7602		            if(total < 1) {
7603		                $modal.removeAttr('data-slide-moving');
7604		                return;
7605		            }
7606		            if(index < 0) index = total - 1;
7607		            if(index >= total) index = 0;
7608
7609	            var $activeItem = $items.eq(index),
7610	                $currentItem = $items.filter('.active').eq(0),
7611	                hasCurrent = ($currentItem.length > 0 && $currentItem.get(0) !== $activeItem.get(0)),
7612	                activeItemWidth = 0,
7613	                basePosition = {top:0, left:0};
7614
7615	            if(typeof direction == 'undefined') direction = 1;
7616	            if(!hasCurrent) direction = 0;
7617
7618		            if(!hasCurrent) {
7619			                $items.removeClass('active sliding').css({'display':'', 'position':'', 'top':'', 'left':'', 'z-index':''});
7620			                $items.find('> .banner-content, .banner-body > a').css('left', '');
7621			                $activeItem.addClass('active').css('display', 'block');
7622			                $modal.removeAttr('data-slide-moving');
7623			            }
7624
7625		            var $controlItem = (hasCurrent) ? $currentItem : $activeItem,
7626		                $controlBody = $controlItem.find('.banner-body').eq(0),
7627		                modalOffset = $modal.offset() || {top:0, left:0},
7628	                bodyOffset = ($controlBody.length) ? $controlBody.offset() : $controlItem.offset(),
7629	                bodyPosition = {
7630	                    top: ((bodyOffset && typeof bodyOffset.top != 'undefined') ? bodyOffset.top : modalOffset.top) - modalOffset.top,
7631	                    left: ((bodyOffset && typeof bodyOffset.left != 'undefined') ? bodyOffset.left : modalOffset.left) - modalOffset.left
7632	                },
7633	                bodyWidth = (($controlBody.length) ? $controlBody.outerWidth() : 0) || $controlItem.outerWidth() || parseInt($controlItem.css('width')),
7634	                bodyHeight = (($controlBody.length) ? $controlBody.outerHeight() : 0) || $controlItem.outerHeight();
7635
7636		            activeItemWidth = bodyWidth;
7637		            $.siteBanner.placePopupSlideControls($modal, $controlItem);
7638		            if(activeItemWidth > 0 && $modal.get(0)) {
7639		                $modal.get(0).style.setProperty('--popup-slide-control-width', activeItemWidth + 'px');
7640		                $modal.get(0).style.setProperty('--popup-slide-control-left', bodyPosition.left + 'px');
7641	                $modal.get(0).style.setProperty('--popup-slide-control-top', (bodyPosition.top + (bodyHeight / 2)) + 'px');
7642	            }
7643
7644				            var paginationStyle = $modal.attr('data-slidepaginationstyle') || (($modal.attr('data-slidepagination') == 'dot') ? '1' : '11'),
7645				                paginationType = $.siteBanner.getPopupSlidePaginationTypeByStyle(paginationStyle),
7646				                paginationSize = $.siteBanner.getPopupSlideControlSizeValue($modal.attr('data-slidepaginationsize'), '52'),
7647				                paginationRenderSize = $.siteBanner.getPopupSlidePaginationRenderSize($modal, paginationSize, paginationStyle),
7648				                paginationHtml = $.siteBanner.getPopupSlidePaginationHtml(paginationStyle, index, total),
7649				                $paginationWrap = $modal.find('.banner-slide-pagination').eq(0),
7650				                $pagination = $paginationWrap.find('> .slider-pagination-popup').eq(0);
7651
7652			            $modal.attr('data-slidepagination', paginationType);
7653			            if($paginationWrap.length && !$pagination.length) {
7654			                $paginationWrap.addClass('el_popup_slide_pagination').empty().append('<div class="slider-pagination-popup"></div>');
7655			                $pagination = $paginationWrap.find('> .slider-pagination-popup').eq(0);
7656					            }
7657				            $paginationWrap.toggleClass('hide', total < 2 || $modal.attr('data-slidepaginationdisplay') == 'OFF');
7658				            $pagination.attr({'data-style': paginationStyle, 'data-size': paginationRenderSize + 'px'});
7659				            $pagination.toggleClass('swiper-pagination-bullets-dynamic', $.inArray(String(paginationStyle), ['2','4']) > -1);
7660					            if(!$.siteBanner.updatePopupSlidePaginationState($pagination, paginationStyle, index, total)) {
7661					                $pagination.html(paginationHtml).removeAttr('data-popup-slide-pagination-ready');
7662					                if(!$.siteBanner.updatePopupSlidePaginationState($pagination, paginationStyle, index, total)) $pagination.attr('data-popup-slide-pagination-ready', '1');
7663					            }
7664					            $modal.find('.banner-slide-arrow').toggleClass('hide', total < 2 || $modal.attr('data-slidearrow') != 'ON' || paginationStyle == '12');
7665	            $.siteBanner.applyPopupSlideControlColors($modal);
7666
7667	            basePosition = (hasCurrent) ? $currentItem.position() : $activeItem.position();
7668	            var paginationHeight = $paginationWrap.outerHeight() || 0,
7669	                paginationWidth = $paginationWrap.outerWidth() || 0,
7670	                paginationTop = bodyPosition.top + bodyHeight - paginationHeight - 15,
7671	                paginationLeft = bodyPosition.left + ((bodyWidth - paginationWidth) / 2),
7672	                paginationRight = ($modal.innerWidth() || 0) - (bodyPosition.left + bodyWidth) + 15;
7673
7674	            if($modal.get(0)) {
7675	                $modal.get(0).style.setProperty('--popup-slide-pagination-top', paginationTop + 'px');
7676	                $modal.get(0).style.setProperty('--popup-slide-pagination-left', paginationLeft + 'px');
7677	                $modal.get(0).style.setProperty('--popup-slide-pagination-right', paginationRight + 'px');
7678	            }
7679	            if(hasCurrent && total > 1) {
7680			                var moveWidth = activeItemWidth * ((direction < 0) ? -1 : 1),
7681			                    slideDuration = $.siteBanner.getPopupSlideDuration($modal, isManual),
7682		                    slideEasing = (typeof $.easing != 'undefined' && typeof $.easing.easeInOutQuart == 'function') ? 'easeInOutQuart' : 'swing',
7683		                    $currentBody = $currentItem.find('.banner-body').eq(0),
7684		                    $currentSlide = $currentBody.find('> a').eq(0),
7685		                    $activeSlide = $activeItem.find('.banner-body > a').eq(0),
7686			                    $slideClone = null,
7687			                    finishPopupSlide = function() {
7688			                        $currentItem.removeClass('active sliding').css({'display':'', 'position':'', 'top':'', 'left':'', 'z-index':''});
7689			                        $currentItem.find('> .banner-content, .banner-body > a').css({'left':'', 'position':'', 'z-index':''});
7690			                        $activeItem.removeClass('sliding').addClass('active').css({'display':'block', 'position':'', 'top':'', 'left':'', 'z-index':''});
7691			                        $activeItem.find('> .banner-content, .banner-body > a').css({'left':'', 'position':'', 'z-index':''});
7692			                        $.siteBanner.placePopupSlideControls($modal, $activeItem);
7693			                        $modal.removeAttr('data-slide-moving');
7694			                    };
7695			                if(!$currentSlide.length) $currentSlide = $currentItem.find('> .banner-content');
7696			                if(!$activeSlide.length) $activeSlide = $activeItem.find('> .banner-content');
7697
7698			                $modal.attr('data-slide-moving', isManual ? 'manual' : 'auto');
7699			                $ul.stop(true, true);
7700		                $items.not($currentItem).not($activeItem).removeClass('active sliding').css({'display':'', 'position':'', 'top':'', 'left':'', 'z-index':''});
7701		                $items.not($currentItem).not($activeItem).find('> .banner-content, .banner-body > a').css({'left':'', 'position':'', 'z-index':''});
7702		                $items.find('.banner-body > .banner-slide-clone').remove();
7703		                $activeItem.stop(true, true).removeClass('active sliding').css({'display':'', 'position':'', 'top':'', 'left':'', 'z-index':''});
7704		                $activeItem.find('> .banner-content, .banner-body > a').css({'left':'', 'position':'', 'z-index':''});
7705		                $currentItem.stop(true, true).addClass('active').css({'display':'block', 'position':'relative', 'top':'auto', 'left':0, 'z-index':2});
7706		                if(!$currentBody.length || !$currentSlide.length || !$activeSlide.length) {
7707		                    finishPopupSlide();
7708		                } else {
7709		                    $slideClone = $activeSlide.clone(false, false).addClass('banner-slide-clone');
7710		                    $slideClone.removeAttr('id').find('[id]').removeAttr('id');
7711		                    $slideClone.css({'position':'absolute', 'top':0, 'left':moveWidth + 'px', 'width':bodyWidth + 'px', 'height':bodyHeight + 'px', 'margin':0, 'z-index':1, 'pointer-events':'none'});
7712		                    $currentBody.append($slideClone);
7713		                    $currentSlide.stop(true, true).css({'position':'relative', 'left':0, 'z-index':1}).animate({'left':(-moveWidth) + 'px'}, slideDuration, slideEasing);
7714		                    $slideClone.stop(true, true).animate({'left':'0px'}, slideDuration, slideEasing, function() {
7715		                        $currentSlide.css({'left':'', 'position':'', 'z-index':''});
7716		                        $slideClone.remove();
7717		                        finishPopupSlide();
7718		                    });
7719		                }
7720		            }
7721
7722		            $modal.attr('data-slide-index', index).attr('data-slide-total', total);
7723		        },
7724		        finishPopupSlide: function(modal) {
7725		            var $modal = $(modal),
7726		                $items = $modal.find('> ul > li.banner-box:not(.hide)'),
7727		                total = $items.length,
7728		                index = Number($modal.attr('data-slide-index') || 0),
7729		                $activeItem = null;
7730
7731		            if(total < 1) return;
7732		            if(index < 0) index = total - 1;
7733		            if(index >= total) index = 0;
7734
7735		            $items.stop(true, true);
7736		            $items.find('.banner-body > .banner-slide-clone').remove();
7737		            $items.find('> .banner-content, .banner-body > a').stop(true, true).css({'left':'', 'position':'', 'z-index':''});
7738		            $items.removeClass('active sliding').css({'display':'', 'position':'', 'top':'', 'left':'', 'z-index':''});
7739
7740		            $activeItem = $items.eq(index);
7741		            $activeItem.addClass('active').css('display', 'block');
7742		            $.siteBanner.placePopupSlideControls($modal, $activeItem);
7743		            $modal.attr('data-slide-index', index).attr('data-slide-total', total).removeAttr('data-slide-moving');
7744		        },
7745		        isPopupSlideManualMoving: function(modal) {
7746		            return ($(modal).attr('data-slide-moving') == 'manual');
7747		        },
7748		        nextPopupSlide: function(modal, direction, isManual) {
7749		            var $modal = $(modal),
7750		                index = Number($modal.attr('data-slide-index') || 0);
7751
7752		            $.siteBanner.showPopupSlide($modal, index + direction, direction, isManual);
7753		        },
7754		        startPopupSlideRollingModal: function(modal) {
7755		            var $modal = $(modal),
7756		                isSlide = ($modal.attr('data-viewtype') == 'slide'),
7757		                isAuto = (($modal.attr('data-slideauto') || ((typeof $.siteBanner.popup != 'undefined') ? $.siteBanner.popup.slide_auto : 'OFF')) != 'OFF'),
7758		                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,
7759		                total = $modal.find('> ul > li.banner-box:not(.hide)').length,
7760		                seq = null,
7761		                slideDelay = 0;
7762
7763		            if(!isSlide || !isAuto || total < 2 || $modal.attr('data-slide-seq') || isScPopupPanelOpen) return;
7764
7765		            slideDelay = $.siteBanner.getPopupSlideDelay($modal);
7766		            seq = setInterval(function() {
7767		                $.siteBanner.nextPopupSlide($modal, 1, false);
7768		            }, slideDelay);
7769
7770		            $modal.attr('data-slide-seq', seq);
7771		            if(typeof $.siteBanner.popup != 'undefined') {
7772		                if(typeof $.siteBanner.popup.slide_seqs == 'undefined') $.siteBanner.popup.slide_seqs = [];
7773		                $.siteBanner.popup.slide_seqs.push(seq);
7774		            }
7775		        },
7776		        stopPopupSlideRollingModal: function(modal) {
7777		            var $modal = $(modal),
7778		                seq = $modal.attr('data-slide-seq'),
7779		                seqArr = (typeof $.siteBanner.popup != 'undefined' && typeof $.siteBanner.popup.slide_seqs != 'undefined') ? $.siteBanner.popup.slide_seqs : [],
7780		                nextSeqArr = [];
7781
7782		            if(seq) {
7783		                clearInterval(Number(seq));
7784		                $modal.removeAttr('data-slide-seq');
7785		            }
7786		            $.each(seqArr, function(i, rollingSeq) {
7787		                if(seq && String(rollingSeq) == String(seq)) {
7788		                    clearInterval(rollingSeq);
7789		                } else {
7790		                    nextSeqArr.push(rollingSeq);
7791		                }
7792		            });
7793		            if(typeof $.siteBanner.popup != 'undefined') $.siteBanner.popup.slide_seqs = nextSeqArr;
7794		        },
7795		        stopPopupSlideRolling: function(selector) {
7796		            var $modal = (selector) ? $(selector).find('.banner-modal') : $('.sc-popupBanner .banner-modal, .cl-popupBanner .banner-modal'),
7797		                seqArr = (typeof $.siteBanner.popup != 'undefined' && typeof $.siteBanner.popup.slide_seqs != 'undefined') ? $.siteBanner.popup.slide_seqs : [];
7798
7799	            $modal.each(function() {
7800	                var seq = $(this).attr('data-slide-seq');
7801	                if(seq) clearInterval(seq);
7802	                $(this).removeAttr('data-slide-seq');
7803	            });
7804
7805	            $.each(seqArr, function(i, seq) {
7806	                clearInterval(seq);
7807	            });
7808
7809	            if(typeof $.siteBanner.popup != 'undefined') $.siteBanner.popup.slide_seqs = [];
7810	        },
7811	        setBandRolling: function() {
7812	            if($.siteBanner.band.paused) return false;
7813
7814            var bannerEL = $('.cl-bandBanner[data-seq="'+$.siteBanner.band.seqs[$.siteBanner.band.seqs.length - 1]+'"]');
7815            if(bannerEL.length == 0) return false;
7816            var bannerUL = bannerEL.find('.banner-modal > ul'),
7817                banner_h = $.siteBanner.getBandHeight(),
7818                banner_l = bannerUL.children('.banner-box:not(.hide)').length;
7819
7820            bannerUL.animate({ top: -banner_h+'px' }, 1000, 'easeInOutQuart', function() {
7821                $(this).append($(this).find('li.banner-box:not(.hide)').eq(0).clone().wrapAll('<li />').parent().html());
7822
7823                $(this).find('li.banner-box:not(.hide)').eq(0).remove();
7824                $(this).css('top', 0);
7825            });
7826        },
7827        stopBandRolling: function() {
7828            var seq = ($('.cl-bandBanner').length > 0) ? $('.cl-bandBanner').attr('data-seq') : 0,
7829                seq_arr = (typeof $.siteBanner.band != 'undefined' && typeof $.siteBanner.band.seqs != 'undefined') ? $.siteBanner.band.seqs : [];
7830
7831            if(seq) clearInterval(seq);
7832            $.each(seq_arr, function(i,v) {
7833                clearInterval(v);
7834            });
7835
7836            if(seq_arr.length > 0) {
7837                $.siteBanner.band.seqs = [];
7838                $.siteBanner.band.paused = false;
7839            }
7840        },
7841    }
7842
7843    $.fixedContact = {
7844        init: function($el) {
7845            // console.log('fixedContact init');
7846            let sid = (typeof property != 'undefined')? property.SID : SID;
7847            let settings = (typeof property != 'undefined')? property.SETTINGS : SETTINGS;
7848            let onoff = (typeof $.cookie('fixedcontact-' + sid) != 'undefined')? $.cookie('fixedcontact-' + sid) : 'on';
7849            let device = ($('body').width() > 768) ? 'pc' : 'mobile';
7850
7851            $el.addClass('el-fixedcontact');
7852            if(onoff == 'off') $el.addClass('down');
7853            
7854            if($.fnav.checkFnavON()) {
7855                if(typeof settings.qm_onoff == 'undefined') $el.addClass('has-fnav');
7856            }
7857
7858            if(typeof settings.viewportMode != 'undefined' && settings.vpMode_onoff===true && $('.mobilepc_ch').length > 0) {
7859                $el.addClass('has-vpmode');
7860            }
7861
7862            setTimeout(function(){
7863                $.fixedContact.addBtn($el);
7864            }, 100);
7865        },
7866        addBtn: function($el) {
7867            let bgcolor = $el.css('background-color');
7868            let bgimg = $el.css('background-image');
7869            let bgPos = $el.css('background-position');
7870            let btnBackground = 'background-color:'+bgcolor+';';
7871            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>';
7872            $el.append(btnHTML);
7873
7874            if(PAGE_MODE != 'c') {                
7875                $(document).off('click', '.fixedcontact-onoff');
7876                $(document).on('click', '.fixedcontact-onoff', function(){
7877                    let sid = property.SID;
7878                    let date = new Date();
7879                    
7880                    date.setTime(date.getTime() + 6*60*60*1000); // 6h
7881                    $('.el-fixedcontact').toggleClass('down');
7882                    
7883                    if($('.el-fixedcontact').hasClass('down')) {
7884                        $.cookie('fixedcontact-' + sid, 'off', { expires: date, path : '/' });
7885                    } else {
7886                        $.cookie('fixedcontact-' + sid, 'on', { expires: date, path : '/' });
7887                    }
7888
7889                    let scrollTop = $(window).scrollTop(),
7890                        device_type = ($('body').width() > 768) ? 'pc' : 'mobile',
7891                        gotoTop_position = $(window).height() - $('#goto-top').outerHeight() - $('#goto-top').position().top,
7892                        el_fixedheight = $('.element.el-fixedcontact').innerHeight(),
7893                        el_fixedonoff = 22,
7894                        el_fixedblocktotalHeight = el_fixedheight + el_fixedonoff,
7895                        music_position = (($('#cl-music-player-icon').length > 0)) ? Number($('#cl-music-player-icon').css('bottom').replace(/px/gi,'')) : 0,
7896                        quickmenu_position = (($(`.quick-menu-${sid}.quickmenu`).length > 0)) ? Number($(`.quick-menu-${sid}.quickmenu`).css('bottom').replace(/px/gi,'')) : 0;
7897                    
7898                        if($('.el-fixedcontact').hasClass('down')) {                           
7899                            if(device_type=='pc') $('#goto-top').css('bottom',gotoTop_position - el_fixedheight);
7900                            if(typeof $.quickmenu['quickmenu'] != 'undefined' && $.quickmenu['quickmenu']['img_type'][device_type]!='bottom_default') $(`.quick-menu-${sid}.quickmenu`).css('bottom',quickmenu_position - el_fixedheight);	
7901                            if($('#cl-music-player-icon').length > 0) $('#cl-music-player-icon, #cl-music-container').css('bottom',music_position - el_fixedheight);	                            
7902                        } else {
7903                            if(device_type=='pc') $('#goto-top').css('bottom',gotoTop_position + el_fixedheight);
7904                            if(typeof $.quickmenu['quickmenu'] != 'undefined' && $.quickmenu['quickmenu']['img_type'][device_type]!='bottom_default') $(`.quick-menu-${sid}.quickmenu`).css('bottom',quickmenu_position + el_fixedheight);	
7905                            if($('#cl-music-player-icon').length > 0) $('#cl-music-player-icon, #cl-music-container').css('bottom',music_position + el_fixedheight);	
7906                        }
7907                });
7908
7909                $.fixedContact.checkPosition($('.el-fixedcontact'));
7910
7911                $(window).on('scroll', function() {
7912                    $.fixedContact.checkPosition($('.el-fixedcontact'));
7913                });
7914            }
7915        },
7916        checkPosition: function($el) {
7917            if(PAGE_MODE != 'c' && $el.length > 0) {
7918                let isNotFixed = $el.hasClass('notfixed');
7919                let scrollTop = $(window).scrollTop();
7920                let windowHeight = $(window).height();
7921                let documentHeight = $(document).height();
7922                let footerTop = ($('.el-footer').length > 0 && $('.el-footer').hasClass('hide') == false)? $('.el-footer').offset().top : documentHeight - $el.outerHeight();
7923                if($el.hasClass('has-fnav')) footerTop -= 53;
7924                let distanceScrolled = (isNotFixed)? Math.max(0, scrollTop + windowHeight - footerTop + $el.outerHeight()) : Math.max(0, scrollTop + windowHeight - footerTop);
7925                // console.log('windowHeight', windowHeight);
7926                // console.log('scrollTop', scrollTop);
7927                // console.log('footerTop', footerTop);
7928                // console.log('documentHeight', documentHeight);
7929                // console.log('distanceScrolled', distanceScrolled);
7930
7931                if (distanceScrolled > 0 && !isNotFixed) {
7932                    $el.addClass('notfixed');
7933                } else if (distanceScrolled <= 0 && isNotFixed) {
7934                    $el.removeClass('notfixed');
7935                }
7936            }
7937        }
7938    }
7939
7940    // $(".element").removeInlineCss("color font-size font-weight");
7941    jQuery.fn.removeInlineCss = function (properties) {
7942        if (properties == null) return this.removeAttr('style');
7943        properties = properties.split(/\s+/);
7944        return this.each(function () {
7945            for (var i = 0; i < properties.length; i++)
7946                this.style.removeProperty(properties[i])
7947        });
7948    }
7949
7950    jQuery.fn.refreshRootCss = function(property_key) {
7951        var isAll = (typeof property_key == 'undefined' || property_key == '') ? true : false;
7952
7953        // property_key == '--menu-height'
7954        var mh = getMenuHeight(),
7955            bh = $.siteBanner.getBandHeight();
7956        this.each(function() {
7957            if(!$(this).is('[data-el^="el_"]') || !$(this).is('[data-type="gallery"][data-type2="premium"]')) return true;
7958
7959            if(isAll || property_key == '--menu-height') {
7960                var __target = $(this).attr('data-el'),
7961                    __menu_height = getComputedStyle(document.querySelector('.'+__target)).getPropertyValue('--menu-height');
7962                if(typeof __menu_height != 'undefined' && __menu_height) document.querySelector('.'+__target).style.setProperty('--menu-height', (mh+bh)+'px', null);
7963            }
7964        });
7965    }
7966
7967    //mobile정보 가져오기
7968    var mrequest_uri = location.pathname + location.search;
7969    function getMobileInfo(data) {        
7970        var page = location.pathname.split('/')[1],
7971            mb = data.mb,
7972            paidUser = data.paidUser,
7973            settings_url = data.settings_url,
7974            sid = data.sid,
7975            valid_plan = data.valid_plan,
7976            site_nickname =  (typeof $('.site-username').text() != 'undefined' && $('.site-username').text()) ? $('.site-username').text() : data.site_nickname,
7977            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,
7978            umprofile = data.umprofile,
7979            newCount = data.newCount,
7980            checkGabia = (data.service.indexOf('gabia') > -1) ? true : false;
7981
7982        mb.mb_id = (mb.mb_id) ? mb.mb_id : mb.um_id;
7983
7984        if(mb.mb_id){
7985            var empty = (mb.mb_id) ? '' : 'empty',
7986                newMessage = (newCount == 0) ? false : true,
7987                badge = newMessage ? "<span class='badge'></span>" : "";
7988
7989            var adminhtml = (mb.mb_level >= 10) ? '<li><a href="/adm" target="_blank">Admin</a></li>' : '',
7990                mypage = (checkGabia) ? '/dashboard' : '/mypage',
7991                uadminmypage = (data.is_uadmin == false) ? mypage : 'javascript:;',
7992                siteum = (data.is_uadmin == false) ? '' : 'siteUM',
7993                mypage = (data.is_uadmin == false) ? '' : 'mypage',
7994                dashboarduadmin = (data.is_uadmin == false) ? '/' : '/_admin/dashboard', 
7995                marketinguadmin = (data.is_uadmin == false) ? '/marketing' : '/_admin/marketing';
7996
7997
7998                
7999
8000            var str = '<div class="nav navbar-nav navbar-right">\
8001                            <div class="mobile-menu">\
8002                                    <div class="m-myinfo">\
8003                                        <div class="profile_left">\
8004                                            <label class="m-profile hand '+umprofile+'" data-user-img="'+site_profile+'" data-user-plan="'+paidUser+'" data-user-um="'+umprofile+'">\
8005                                                <svg viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >\
8006                                                <pattern id="m-dashboard-image-top" patternUnits="userSpaceOnUse" width="60" height="60">\
8007                                                    <image xlink:href='+site_profile+' x="-10" width="60" height="40"></image>\
8008                                                </pattern><circle cx="20" cy="20" r="20" fill="url(#m-dashboard-image-top)"></circle></svg>\
8009                                            </label>\
8010                                            <div class="inner-box hand">\
8011                                                <span class="name-text m-profile m-text-size">'+site_nickname+'</span>\
8012                                            </div>\
8013                                        </div>\
8014                                        <div class="profile_right">';
8015                                            if(data.is_uadmin) {
8016                                                str += '<div class="mlogout siteUM"><a href="javascript:;" class="logout">'+$.lang[LANG]['header.logout']+'</a></div>';
8017                                            } else {
8018                                                str += '<div class="mlogout"><a href="/member/login/out">'+$.lang[LANG]['header.logout']+'</a></div>';
8019                                            }
8020                                str +=  '</div>\
8021                                    </div>\
8022                                    <div class="mMymenu-wrap"><ul class="mMymenu">'; 
8023                                    var newCountlink = (data.is_uadmin == false) ? '/' : '/_admin';
8024                                            str +=  '<li class="newCount prorightmenu">\
8025                                                    <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>\
8026                                                </li>\
8027                                                <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>\
8028                                                <span class="menu-title">'+$.lang[LANG]['header.mypage']+'</span></a></li>';
8029                                        
8030                                        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>\
8031                                            <span class="menu-title">'+$.lang[LANG]['header.changeLang']+'</span></li>';
8032                                        str += '</ul></div>\
8033                                    <ul class="dropdown-menu" role="menu">'+adminhtml+
8034                                        '<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>';
8035                                    
8036                                    var supportlink = (checkGabia) ? 'https://creatorlink-gabia.com/support' : ((LANG == 'ko') ? 'https://supportcenter.creatorlink.net/creatorlink/' : 'https://supportcenter.creatorlink.net/creatorlink-support-center'),
8037                                        helplink = (checkGabia) ? 'https://creatorlink.gabia.com/consult' : '#helpdeskopen',
8038                                        helptext = (checkGabia) ? $.lang[LANG]['mobile.menu.title.gabia.gotocts'] : $.lang[LANG]['mobile.menu.title.gotocts'],
8039                                        is_uadminMember = (data.is_uadmin) ? '_admin' : 'manager',
8040                                        memberlink = '/'+is_uadminMember+'/member/list',
8041                                        siteNotice = (valid_plan=='' || $.inArray(valid_plan['type'], ['BN','SM']) == -1) ? 'siteNotice("manager");' : '',
8042                                        kakaositeNotice = "",
8043                                        kakaotalkuadmin = (data.is_uadmin == false ) ? '/notificationtalkmail' : '/_admin/notificationtalkmail';
8044
8045                                    if(data.is_uadmin) helplink = (checkGabia) ? 'https://creatorlink.gabia.com/consult' : '#helpdeskopen';
8046
8047                                    str += '<li class="m_memberlist"><a href="'+memberlink+'">'+$.lang[LANG]['mobile.menu.title.memberlist']+'</a></li>';
8048
8049                                    if(LANG == 'ko' && (!checkGabia || (checkGabia && valid_plan['type'] == 'SM'))) {
8050                                        var applySm = (valid_plan['type'] == 'SM') ? '' : 'siteNotice(\'shopping\')',
8051                                            collapsed = (valid_plan['type'] == 'SM') ? 'collapsed' : '',
8052                                            smHide = ((valid_plan['type'] == 'BN') && (data.is_uadmin==true)) ? 'hide' : '';
8053
8054                                        str += '\
8055                                        <li class="collapsed mshoppingtab '+smHide+'" data-toggle="collapse" data-target=".mshopping_menu" aria-expanded="true">\
8056                                            <a type="button" class="collapsed hand">' + $.lang[LANG]['mobile.menu.title.shopping'] + '</a>\
8057                                        ';
8058                                        
8059                                        var admin_url = (data.is_uadmin == false) ? '' : '/_admin';
8060                                            
8061                                        str +=  '\
8062                                            <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>\
8063                                        </li>\
8064                                        <ul class="mshopping_menu collapse">\
8065                                            <li><a href="'+admin_url+'/shopping/product_search/order">'+$.lang[LANG]['mobile.menu.title.shopping.order']+'</a></li>\
8066                                            <li><a href="'+admin_url+'/shopping/product_search/cancel">'+$.lang[LANG]['mobile.menu.title.shopping.cancel']+'</a></li>\
8067                                            <li><a href="'+admin_url+'/shopping/product_search/return">'+$.lang[LANG]['mobile.menu.title.shopping.refund']+'</a></li>\
8068                                            <li><a href="'+admin_url+'/shopping/product_search/exchange">'+$.lang[LANG]['mobile.menu.title.shopping.change']+'</a></li>\
8069                                            <li><a href="'+admin_url+'/shopping/question_list/P">'+$.lang[LANG]['mobile.menu.title.shopping.qna']+'</a></li>\
8070                                            <li><a href="'+admin_url+'/shopping/product_search/all">'+$.lang[LANG]['mobile.menu.title.shopping.all']+'</a></li>\
8071                                            <li><a href="'+admin_url+'/shopping/statistics">'+$.lang[LANG]['mobile.menu.title.shopping.statistics']+'</a></li>\
8072                                            <li>
8072<a href="'+admin_url+'/shopping/point">'+$.lang[LANG]['mobile.menu.title.shopping.point']+'</a></li>\
8073                                            <li><a href="'+admin_url+'/shopping/coupon">'+$.lang[LANG]['mobile.menu.title.shopping.coupon']+'</a></li>\
8074                                            <li><a href="'+admin_url+'/shopping/setting/W">'+$.lang[LANG]['mobile.menu.title.shopping.setting']+'</a></li>\
8075                                        </ul>';
8076                                    }
8077
8078                                    var slog_li = '\
8079                                        <li><a href="'+admin_url+'/slog">'+$.lang[LANG]['mobile.menu.title.slog']+'</a></li>\
8080                                    ';
8081
8082                                    if(valid_plan) {
8083                                        
8084                                        var pageactive = (page == 'settings') ? 'active' : '',
8085                                            settingslink = (page == 'settings') ? '#' : settings_url,
8086                                            helpbox = (data.is_uadmin == false) ? '<li><a href="'+helplink+'">'+helptext+'</a></li>' : ((data.su_eadmin == false) ? '' : '<li><a href="'+helplink+'">'+helptext+'</a></li>'),
8087                                            settingHide = (data.is_uadmin == true && data.su_eadmin == false) ? 'hide' : '';
8088
8089                                        str += '<li class="m_marketing '+settingHide+'"><a href="'+marketinguadmin+'">'+$.lang[LANG]['mobile.menu.title.marketing']+'</a></li>';
8090                                             if(!checkGabia) str += '<li class=m_kakao " onClick="'+kakaositeNotice+'"><a href="'+kakaotalkuadmin+'">'+$.lang[LANG]['mobile.menu.title.kakao']+'</a></li>';
8091                                                str += '<li class="'+settingHide+'"><a href="'+settings_url+'">'+$.lang[LANG]['mobile.menu.title.settings']+'</a></li>\
8092                                        ';
8093                                        if(!checkGabia && data.is_uadmin == false) str += '<li class="m_plan '+settingHide+'"><a href="/plan">'+$.lang[LANG]['mobile.menu.title.plan.billing']+'</a></li>';
8094                                        if(valid_plan['type'] == 'SM' && LANG == 'ko') str += slog_li;
8095                                        if(!checkGabia &&  LANG == 'ko' && data.is_uadmin == false) {
8096                                            str += `
8097                                                <li><a href="/edu">${$.lang[LANG]['mobile.menu.logout.title.edu']}</a></li>
8098                                            `;
8099                                            // <li><a href="/production">${$.lang[LANG]['mobile.menu.logout.title.production']} <span class="newicon">New</span></a></li>
8100                                        }
8101
8102                                        if(data.is_uadmin == false) str +='<li><a href="'+supportlink+'">'+$.lang[LANG]['mobile.menu.title.supportcenter']+'</a></li>';
8103                                        if(!checkGabia && data.is_uadmin == false)str += '<li><a href="/notice">'+$.lang[LANG]['mobile.menu.title.notice']+'</a></li>';
8104                                        str += helpbox;
8105                                    }
8106
8107                            str +=  '</ul>\
8108                                </div>\
8109                        </div>'; 
8110                $('.m-header_user').empty().prepend(str);
8111        }
8112        return data;        
8113    }
8114
8115    $.mobileToggleMenu = {
8116        set : function() {
8117            var request_uri = location.pathname + location.search;
8118            var returnData = '';
8119
8120            $.ajax({
8121                type: 'POST',
8122                data: { type:'get', sid:(typeof SID!='undefined' && SID? SID : '') },
8123                dataType: 'json',
8124                url: '/template/getMobileMenu',   
8125                async:false,
8126                success : function(data) {
8127                    returnData = getMobileInfo(data);
8128                }
8129            }); 
8130
8131            $.mobileToggleMenu.clickEvnt();
8132
8133            return returnData;
8134            
8135        },
8136        setSignIn : function() {
8137            var langkor = (LANG=='ko') ? '':'hide',
8138                langen = (LANG=='en') ? '' : 'hide',
8139                str = '<div class="nav navbar-nav navbar-right signinwrap">\
8140                        <div class="mobile-menu">\
8141                                <div class="m-myinfo">\
8142                                    <div class="profile_left signinwrap_logo">\
8143                                        <div class="inner-box hand">\
8144                                            <a href="/">\
8145                                            <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
8145-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>\
8146                                            </a>\
8147                                        </div>\
8148                                    </div>\
8149                                    <div class="profile_right msignin">\
8150                                        <a href="/member/login" class="mlogin-text" id="m_login_btn_head">'+$.lang[LANG]['mobile.menu.signin']+'</button>\
8151                                    </div>\
8152                                </div>\
8153                                <ul class="dropdown-menu" role="menu">';   
8154                            str += '<li><a href="/upgrade/site" class="logoutmenu">'+$.lang[LANG]['mobile.menu.logout.title.plan']+'</a></li>\
8155                                    <li><a href="/template" class="logoutmenu">'+$.lang[LANG]['mobile.menu.logout.title.template']+'</a></li>\
8156                                    <li><a href="/bestlist" class="logoutmenu">'+$.lang[LANG]['mobile.menu.logout.title.bestsite']+'</a></li>';
8157                                   if(LANG == 'ko') str += '<li><a href="/mainfunction" class="logoutmenu">'+$.lang[LANG]['mobile.menu.logout.title.mainfunc']+'</a></li>';
8158                                   if(LANG == 'ko') str += '<li><a href="/edu" class="logoutmenu edu">'+$.lang[LANG]['mobile.menu.logout.title.edu']+'</a></li>';
8159                                   if(LANG == 'ko') str += '<li><a href="/production" class="logoutmenu production">'+$.lang[LANG]['mobile.menu.logout.title.production']+'</a></li>';
8160
8161                        // str += '</ul>\ 
8162                        //         <div class="mchange-lang">\
8163                        //             //<img src="https://storage.googleapis.com/i.addblock.net/lang_kor.png" class="lang-ch '+langkor+'" data-attach="true" alt="Creatorlink logo">\
8164                        //             //<img src="https://storage.googleapis.com/i.addblock.net/lang_eng.png" class="lang-ch '+langen+'" data-attach="true" alt="Creatorlink logo">\
8165                        //             <div class="lang-ch '+langkor+'">KR</div>\
8166                        //             <div class="lang-ch '+langen+'">EN</div>\
8167                        //         </div>\
8168                        //     </div>\
8169                        str += '</ul>\
8170                                <div class="mchange-lang">\
8171                                    <div class="hand lang-ch '+langkor+'">KR</div>\
8172                                    <div class="hand lang-ch '+langen+'">EN</div>\
8173                                </div>\
8174                            </div>\
8175                    </div>';    
8176
8177            $('.m-header_user').prepend(str);   
8178
8179            $.mobileToggleMenu.clickEvnt();
8180        },
8181        mobileResize : function(data) {
8182            getMobileInfo(data);
8183            $.mobileToggleMenu.clickEvnt();
8184        },
8185        clickEvnt : function() {
8186            $('.navbar-toggle').click(function() {
8187                $.mobileToggleMenu.open();
8188                $('.m-header_user').css('left','0');
8189                $('html').css({'overflow': 'hidden'});
8190            });
8191            $('.m-langselect,.lang-ch').on('click',function(){  
8192                $.mobileToggleMenu.langSelect(mrequest_uri);
8193            });
8194            /*$('.applySm').click(function(){
8195                $(this).showModalFlat('INFORMATION', '쇼핑 기능은 심플쇼핑 요금제로 이용이 가능합니다.<br>심플쇼핑 신청 페이지로 이동할까요?', true, true, function() {
8196                    location.href = '/shoppingevent';
8197                }, 'cancel', '이동','mUpgradeSmModal');
8198            });*/
8199            $('.mshopping_menu').on('show.bs.collapse',function(e){
8200                $('.mshoppingtab,.mshoppingtab > a').css('background-color','#eeeff3');
8201                $('.mshoppingtab svg').remove();
8202                $('.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>');
8203            });
8204            $('.mshopping_menu').on('hide.bs.collapse',function(e){
8205                $('.mshoppingtab,.mshoppingtab > a').css('background-color','inherit');
8206                $('.mshoppingtab svg').remove();
8207                $('.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>');
8208            });
8209
8210            $('#loginModal').on('show.bs.modal', function(e) {
8211                $.mobileToggleMenu.close();
8212            });
8213            $('#loginModal').on('shown.bs.modal', function(e) {
8214                $('html').css({'overflow': 'inherit'});
8215            });  
8216        },
8217        open : function (){
8218            var height = window.outerHeight;
8219
8220            $('#nav.default-nav .header .navbar-header a.navbar-toggle,#nav.default-nav .header .navbar_right').css('zIndex','99');
8221            $('.mobile-detail-popup.billhead,.mobile-detail-popup.helphead').css('height', '100%');
8222            $('.m-headermenu').remove();
8223            $('.m-headerClose').addClass('in');
8224            $('.m-headerClose').removeClass('hide');
8225            $.mobileToggleMenu.scrollheight();
8226
8227            $(window).resize(function (){
8228                $.mobileToggleMenu.scrollheight();
8229            });
8230            $('.m-headerClose').click(function(){
8231                $.mobileToggleMenu.close();
8232                $('html').css({'overflow': 'inherit'});
8233            });
8234        },
8235        close : function() {
8236            $('.m-headermenu').remove();
8237            $('.m-header_user').css('left','-100%');
8238            $('.m-headerClose').removeClass('in');
8239            $('.mobile-detail-popup.billhead,.mobile-detail-popup.helphead').css('height', 'auto');
8240            $('#nav.default-nav .header .navbar_right').css('zIndex','');
8241            $('#nav.default-nav .header .navbar-header a.navbar-toggle').css('zIndex','120');
8242        },
8243        langSelect : function(request_uri) {
8244            $('.m-headermenu').remove();
8245            $('.m-header_user.menu').css('left','-100%');
8246            $('.m-headerClose').addClass('hide');
8247            $('#nav.default-nav .header .navbar-header a.navbar-toggle').css('zIndex','120');
8248
8249            var dashlang = (LANG == 'ko') ? 'ko' : 'en',
8250                html = "<ul class='dashlang-wrap'>\
8251                            <li class='dashlang-select'>\
8252                                <a href='/lang/switchLanguage/korean"+request_uri+"'><p class='mdash-lang'>한국어 (KO)</p>\
8253                                <span class='cl-icon cl-check-lang "+(dashlang == 'ko' ? 'cl_icon_checked04' : 'cl_icon_unchecked04')+"' data-lang='ko'></span></a>\
8254                            </li>\
8255                            <li class='dashlang-select'>\
8256                                <a href='/lang/switchLanguage/english"+request_uri+"'><p class='mdash-lang'>English (EN)</p>\
8257                                <span class='cl-icon cl-check-lang "+(dashlang == 'en' ? 'cl_icon_checked04' : 'cl_icon_unchecked04')+"' data-lang='en'></span></a>\
8258                            </li>\
8259                        </ul>";
8260
8261            $('.m-dashboard').showModalFlat('',html,false,false,'','','','changelang');
8262            $('.modal-dialog.changelang').parents('.modal-default').attr('id','changelangModal');
8263
8264            $('#changelangModal').on('show.bs.modal', function(e) {
8265                $('.dashlang-select > a').click(function() {
8266                    var datalang = $('.dashlang-select .cl-check-lang').attr('data-lang');
8267
8268                    $('.cl-check-lang').each(function () {
8269                        $(this).addClass('cl_icon_checked04').removeClass('cl_icon_unchecked04');
8270                    });
8271                    $(this).addClass('cl_icon_unchecked04').removeClass('cl_icon_checked04');
8272                });
8273            });
8274
8275            $('#changelangModal').on('hide.bs.modal', function(e) {
8276                $('#nav.default-nav .header .navbar_right').css('zIndex','');
8277                $('#nav.default-nav .header .navbar-header a.navbar-toggle').css('zIndex','120');
8278            });
8279        },
8280        upgradePopup : function(){
8281            $(this).showModalFlat('INFORMATION', '쇼핑 기능은 쇼핑 요금제로 이용이 가능합니다.<br>쇼핑 요금제 신청 페이지로 이동할까요?', true, true, function() {
8282                location.href = '/shoppingevent';
8283            }, 'cancel', '이동','mUpgradeSmModal');
8284        },
8285        scrollheight : function() {
8286            var menuheight = $(window).height()-146;
8287            $('.m-header_user .mobile-menu .dropdown-menu').css('height',menuheight);
8288        }
8289    }
8290
8291    $.notSupported = {
8292        isPremiumBlock: function(type,type2,feature) {
8293            if(typeof type == 'undefined') type = '';
8294            if(typeof type2 == 'undefined') type2 = '';
8295            if(typeof feature == 'undefined') feature = '';
8296
8297            return ( type2 == 'premium'
8298                    || feature == 'premium'
8299                    || $.inArray(type, ['latest','form','sync','review']) > -1
8300                    || (type == 'forum' && $.inArray(type2, ['faq','qna']) > -1)
8301                ) ? true : false; 
8302        },
8303        check: function(type,type2,feature) {
8304            if(typeof type == 'undefined') type = '';
8305            if(typeof type2 == 'undefined') type2 = '';
8306            if(typeof feature == 'undefined') feature = '';
8307            if(typeof fn == 'undefined') fn = '';
8308
8309            if(!type && !type2 && !feature) return false;
8310
8311            var tmp_plan = (typeof property != 'undefined') ? property.VALIDPLAN : VALIDPLAN,
8312                tmp_plantype = (typeof property != 'undefined') ? property.VALIDTYPE : VALIDTYPE,
8313                checkFree = (!tmp_plan || tmp_plantype == 'PK') ? true : false,
8314                checkSM = (tmp_plan && tmp_plantype == 'SM') ? true : false,
8315                checkBN = (tmp_plan && tmp_plantype == 'BN') ? true : false,
8316                checkPremium = $.notSupported.isPremiumBlock(type,type2,feature);
8317            
8318            var ns_val = false;
8319            if(checkFree) {
8320                if(checkPremium) ns_val = true;
8321            } else {
8322                if(!checkSM && $.inArray(type, ['review']) > -1) ns_val = true;
8323                if(!checkBN && !checkSM && $.inArray(type2, ['franchise map', 'franchise bar', 'mwd']) > -1) ns_val = true;
8324            }
8325
8326            if(type == 'calendar') {
8327                if(!checkBN && !checkSM && $.inArray(type2, ['mwd']) > -1) ns_val = true;
8328            }
8329
8330            return ns_val;
8331        },
8332        set: function(sid, id, mode, upgrade) {
8333            
8334            if(typeof id == 'undefined' || !id || $('[data-id="' + id + '"]:is(.element, .reorderBlock)').length == 0) return false;
8335     
8336            var nsEl = $('[data-id="' + id + '"]:is(.element, .reorderBlock)'),
8337                checkSlim = (nsEl.height() < 351) ? true : false,
8338                n_service = (typeof PAGE_MODE != 'undefined' && PAGE_MODE=='c') ? SERVICE : property.SERVICE, 
8339                page_mode = (typeof PAGE_MODE != 'undefined' && PAGE_MODE=='c') ? 'config' : 'render', 
8340                is_gabia = (n_service.indexOf('gabia') > -1) ? '.gabia' : '',
8341                title_str = (mode=='video' && !upgrade) ? $.lang[LANG]['config.premium.not-supported.block.video.'+page_mode+'.gfycat'] : $.lang[LANG]['config.premium.not-supported.block'];
8342            var nsTitle = title_str;
8343            switch(mode) {
8344                case 'calendar':
8345                case 'contact':
8346                    nsTitle = $.lang[LANG]['config.premium.not-supported.block.BN' + is_gabia]
8347                    break;
8348                case 'review':
8349                    nsTitle = $.lang[LANG]['config.premium.not-supported.block.SM' + is_gabia]
8350                    break;
8351                default:
8352                    nsTitle = title_str
8353                    break;
8354            }
8355            var ns_html = `
8356                    <div class="cl-ns-wrap" data-blockmode="${mode}">
8357                        <div class="cl-ns-title">${nsTitle}</div>
8358                        <div class="cl-ns-bottom">
8359                            ${ (upgrade) ? `<a class="cl-ns-btn color-b" href="${ 
8360                                                (n_service.indexOf('gabia') > -1) ? 'https://www.gabia.com/mygabia/service' : `/upgrade/site/${sid}` 
8361                                            }" target="_blank">${ $.lang[LANG]['config.premium.not-supported.block.btn.upgrade'] }</a>` : '' 
8362                            }
8363                            <span class="cl-ns-btn color-w" onclick="elDelete(${id})">${$.lang[LANG]['config.premium.not-supported.block.btn.delete']}</span></div>
8364                        </div>
8365                    </div>
8366                `;
8367
8368            if(checkSlim) nsEl.addClass('cl-ns-slim');
8369            else nsEl.removeClass('cl-ns-slim');
8370
8371            nsEl.addClass('cl-not-supported');
8372            nsEl.each(function() {
8373                if($(this).find('.cl-ns-wrap').length > 0) $(this).find('.cl-ns-wrap').replaceWith(ns_html);
8374                else $(this).append(ns_html);
8375            });
8376        },
8377        unset: function(id) {
8378            if(typeof id == 'undefined' || !id || $('[data-id="' + id + '"]:is(.element, .reorderBlock)').length == 0) return false;
8379
8380            var nsEl = $('[data-id="' + id + '"]:is(.element, .reorderBlock)');
8381            nsEl.removeClass('cl-not-supported cl-ns-slim');
8382            nsEl.find('.cl-ns-wrap').remove();
8383        }
8384    }
8385
8386
8387    $.resource = {
8388        init : function() {
8389            var freeSearch = {'type' : '', 'page' : 1, 'text' : '', 'total' : 0},
8390                fileDrag = false,
8391                depfolderClick = false,
8392                isFEdit = false,
8393                mouseX, mouseY,
8394                dragTooltipModal = $();
8395
8396            var getResourceTooltip = function() {
8397                var $tooltip = $('#resource-tooltip-runtime');
8398                if($tooltip.length) return $tooltip;
8399
8400                var $sourceTooltip = $('.resource-tooltip').first();
8401                var tooltipHtml = '<div id="resource-tooltip-runtime" class="resource-tooltip"><img src="" alt="image move to folder"><span class="count">1</span></div>';
8402
8403                if($sourceTooltip.length) {
8404                    tooltipHtml = $('<div>').append($sourceTooltip.clone().attr('id', 'resource-tooltip-runtime').show()).html();
8405                }
8406
8407                $tooltip = $(tooltipHtml);
8408                $('body').append($tooltip);
8409
8410                return $tooltip;
8411            };
8412
8413            var hideResourceTooltip = function() {
8414                getResourceTooltip().stop(true, true).hide().removeClass('multiple');
8415            };
8416
8417            var moveResourceTooltip = function() {
8418                if(!fileDrag) return;
8419
8420                var $tooltip = getResourceTooltip();
8421                if(!$tooltip.length) return;
8422
8423                $tooltip.css({
8424                    'top': mouseY + 14,
8425                    'left': mouseX + 14
8426                });
8427            };
8428
8429            var updateResourceTooltip = function($item, forceShow) {
8430                if(!$item || !$item.length) return;
8431
8432                var $modal = $item.closest('.modal.in'),
8433                    $tab = $modal.find('.modal-resourcebox .tab-content > .tab-pane.active'),
8434                    $tooltip = getResourceTooltip(),
8435                    $selected = $tab.find('ul.files .fitem.ui-selected'),
8436                    $selectedBox = $tab.find('.resource-selected-ul'),
8437                    $sourceItem = ($selected.length > 0) ? $selected.first() : $item.closest('.fitem'),
8438                    str_count = $selectedBox.children('li').length || $selected.length || 1,
8439                    str_img = $sourceItem.find('.fitem-img').attr('src') || $item.find('.fitem-img').attr('src') || '';
8440
8441                if(!$modal.length || !$tooltip.length || !$sourceItem.length || !str_img) return;
8442
8443                dragTooltipModal = $modal;
8444
8445                $tooltip.toggleClass('multiple', str_count > 1)
8446                    .find('img').attr('src', str_img).end()
8447                    .find('.count').text(str_count);
8448
8449                moveResourceTooltip();
8450
8451                if(forceShow || !$tooltip.is(':visible')) {
8452                    $tooltip.stop(true, true).fadeIn(80);
8453                }
8454            };
8455
8456            $(document)
8457                .off('mousemove.resourceTooltip mouseup.resourceTooltip')
8458                .on('mousemove.resourceTooltip', function(e) {
8459                    mouseX = (typeof e.clientX != 'undefined') ? e.clientX : e.pageX;
8460                    mouseY = (typeof e.clientY != 'undefined') ? e.clientY : e.pageY;
8461
8462                    if(fileDrag) moveResourceTooltip();
8463                })
8464                .on('mouseup.resourceTooltip', function() {
8465                    if(!fileDrag) return;
8466                    hideResourceTooltip();
8467                    fileDrag = false;
8468                    dragTooltipModal = $();
8469                    $('#nestableFolder .fli').removeClass('drag-selected');
8470                });
8471
8472            $('.modal-resourcebox ul.files').on('scroll', function(e) {
8473                var thisResourceTab = $(this).parents('.modal').find('.modal-resourcebox .tab-content > .tab-pane.active'),
8474                    thisResourceFiles = thisResourceTab.find('ul.files'),
8475                    rmode = thisResourceTab.attr('id').replace(/storage$/gi,''),
8476                    fsort = thisResourceTab.find('.resource-ctrl-sort select').val(),
8477                    fsearch = thisResourceTab.find('.resource-search-stx').val(),
8478                    is_icon_hybrid_scroll = (rmode == 'icon' && typeof isIconStorageHybridMode == 'function' && isIconStorageHybridMode()),
8479                    scroll_load_offset = (is_icon_hybrid_scroll && typeof ICON_STORAGE_LOAD_TRIGGER_OFFSET != 'undefined') ? ICON_STORAGE_LOAD_TRIGGER_OFFSET : 100;
8480
8481                if((this.scrollTop + this.clientHeight) > (this.scrollHeight - scroll_load_offset)) {
8482                    var fitem_cnt = thisResourceFiles.find('.fitem').length;
8483                    if(rmode == 'my' || rmode == 'icon') {
8484                        if(is_icon_hybrid_scroll) {
8485                            if(typeof canLoadMoreIconStorageCategory != 'function' || !canLoadMoreIconStorageCategory()) return;
8486                            if(typeof appendIconStorageListProgress == 'function') appendIconStorageListProgress(thisResourceFiles);
8487                            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>');
8488                            loadNextIconStorageCategoryPage();
8489                            return;
8490                        }
8491                        if (fitem_cnt == cTotal) return;
8492                    } else if(rmode == 'free') {
8493                        if($.inArray(freeSearch.type, ['search','favor','used']) > -1 && freeSearch.total != 0) {
8494                            if(fitem_cnt == freeSearch.total) return false;
8495                        }
8496                    }
8497
8498                    if(thisResourceFiles.find('.listprogress').length == 0) {
8499                        thisResourceFiles.append('<li class="listprogress">
8499<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>');  
8500                        if(rmode == 'my' || rmode == 'icon') {
8501                            cPage = cPage + 1;
8502                            resourceGetPage(cPage,SFOLDER_ACTIVE,fsort,fsearch);
8503                        } else if(rmode == 'free') {
8504                            getFreeImage(freeSearch.page,freeSearch.type,freeSearch.text);
8505                        }
8506                        
8507                    }
8508                }
8509
8510                if($(this).parents('.modal').find('.modal-resourcebox ul.files').data('uiSelectableScroll') && $(this).parents('.modal').find('.modal-resourcebox ul.files').data('uiSelectableScroll').dragged)
8511                    $(this).parents('.modal').find('.modal-resourcebox ul.files').data('uiSelectableScroll')._updateUi({ doUpdateHelper: true });
8512            })
8513
8514            $(document)
8515                .on('click', '.resourcebox-frame .view-original', function(e) {
8516                    e.preventDefault();
8517                    e.stopPropagation();
8518                    // thisResourceZoomable.empty();
8519
8520                    var thisResourceFrame = $('.resourcebox-frame #rframe'),
8521                        thisResourceSlide = thisResourceFrame.find('.slide').eq(0);
8522                        thisResourceZoomable = thisResourceFrame.find('.zoomable');
8523                        thisResourceOrgBtn = $(this);
8524
8525                    thisResourceOrgBtn.toggleClass('fullscreen');
8526                    var ww = $(window).width() - 8,
8527                        cw = thisResourceSlide.find('.slide-content').width(),
8528                        scale = (thisResourceOrgBtn.hasClass('fullscreen')) ? (ww / cw).toFixed(15) : 1;
8529
8530                    setSlideIconTooltip('.resourcebox-frame #rframe');
8531                    if(thisResourceOrgBtn.hasClass('dblclick')) thisResourceOrgBtn.removeClass('dblclick');
8532                    else thisResourceOrgBtn.tooltip('show');
8533                    setSlideImgScale(thisResourceSlide, scale);
8534                })
8535                .on('dblclick', '.resourcebox-frame .slide-content', function(e) {
8536                    var thisResourceFrame = $('.resourcebox-frame #rframe'),
8537                        thisResourceOrgBtn = thisResourceFrame.find('.view-original');
8538                    
8539                    thisResourceOrgBtn.addClass('dblclick');
8540                    thisResourceOrgBtn.click();
8541                })
8542                .on('click', '.resourcebox-frame [class*="zoom-"]', function(e) {
8543                    var thisResourceFrame = $('.resourcebox-frame #rframe'),
8544                        thisResourceSlide = thisResourceFrame.find('.slide').eq(0),
8545                        thisResourceOrgBtn = thisResourceFrame.find('.view-original'),
8546                        scale = thisResourceFrame.find('.zoomable img').attr('data-scale');
8547                    if(scale === undefined) scale = 1;
8548
8549                    if($(this).hasClass('zoom-in')) {
8550                        thisResourceOrgBtn.removeClass('disabled').addClass('fullscreen');
8551                        scale = Number(scale) + 0.5;
8552                    } else {
8553                        if(scale > 1) scale = Number(scale) - 0.5;
8554                        if(scale < 1) scale = 1;
8555                        if(scale == 1) {
8556                            thisResourceOrgBtn.removeClass('fullscreen');
8557                        }
8558                    }
8559                    
8560                    setSlideIconTooltip('.resourcebox-frame #rframe');
8561                    setSlideImgScale(thisResourceSlide, scale);
8562                });
8563
8564            $('#el-fileupload, #el-iconstorage')
8565                .on('show.bs.modal', function(e) {
8566                    var parentDocument = $(window.parent.document),
8567                        $detail_modal = parentDocument.find('.product-detail-modal');
8568                    if($detail_modal.length) $detail_modal.addClass('overlap');                    
8569
8570                    var thisResourceTab = $(this).find('.modal-resourcebox .tab-content > .tab-pane.active'),
8571                        thisResourceFiles = thisResourceTab.find('ul.files'),
8572                        rmode = thisResourceTab.attr('id').replace(/storage$/gi,''),
8573                        fsort = thisResourceTab.find('.resource-ctrl-sort select').val(),
8574                        fsearch = thisResourceTab.find('.resource-search-stx').val(),
8575                        forceIconStorageInitialLoad = false;
8576
8577                    if($(this).attr('id') == 'el-iconstorage') {
8578                        if(typeof resetIconStorageDefaultState == 'function') resetIconStorageDefaultState();
8579                        thisResourceTab = $('#iconstorage');
8580                        thisResourceFiles = thisResourceTab.find('ul.files');
8581                        thisResourceFiles.empty().addClass('ready');
8582                        rmode = 'icon';
8583                        fsort = 'total';
8584                        fsearch = '';
8585                        forceIconStorageInitialLoad = true;
8586                    }
8587                
8588                    ADD = false;
8589                    UPLOAD = 0;
8590                    UPLOADED = 0;
8591                    PROGRESS = 0;
8592
8593                    var checkProperty = $(this).find('.modal-resourcebox .resource-useit').eq(0).attr('data-property');
8594                    if(rmode == 'my' && checkProperty == 'flink-change') {
8595                        rmode = 'file';
8596                        thisResourceTab = $('#filestorage');
8597                        thisResourceFiles = thisResourceTab.find('ul.files');
8598                    }
8599
8600                    var checkReady = forceIconStorageInitialLoad || thisResourceFiles.hasClass('ready');
8601                    if(checkReady) {
8602                        cPage = 1;
8603                        fsort = (rmode == 'icon') ? 'total' : 'date_desc';
8604                        fsearch = '';
8605                    }
8606                    $.resource.modalInit();
8607                    if(checkReady) resourceGetPage(1,SFOLDER_ACTIVE,fsort,fsearch);
8608
8609                    if(rmode == 'my') {
8610                        thisResourceTab.find('.selectpicker + .btn.dropdown-toggle').attr('title','');
8611                        if(thisResourceTab.find('.fli.active').length == 0) thisResourceTab.find('.fli[data-id="all"]').click();
8612                    }
8613
8614                    $(this).find('.modal-resourcebox .resource-useit').removeClass('clicked');
8615                })
8616                .on('hide.bs.modal', function(e) {
8617                    var parentDocument = $(window.parent.document),
8618                        $detail_modal = parentDocument.find('.product-detail-modal');
8619                    if($detail_modal.length) $detail_modal.removeClass('overlap');                    
8620                    $.resource.setMystorageFolder('nodrag',false);
8621                    if($('#nestableFolder .fli[data-id="clEmptyFolder"]').length > 0 ) {//new folder name_input open
8622                        $('#nestableFolder .fli[data-id="clEmptyFolder"]').remove();
8623                        isFEdit = false;
8624                    }
8625                    if($('#nestableFolder .fli .dd-fln').find('input').length > 0 ) { //edit folder name_input open
8626                        $('#nestableFolder .fli .dd-fln').find('input').val('').closest('li.fli').find('.fln-group').remove();
8627                        isFEdit = false;
8628                    }
8629                    if($('#nestableFolder .fli.active').length > 0) {
8630                        if($('#nestableFolder').scrollTop() > $('#nestableFolder .fli.active').position().top) {
8631                            $('#nestableFolder').scrollTop($('#nestableFolder .fli.active').position().top);
8632                        }
8633                    }
8634    
8635                    if($('#el-property [data-loop-type="matrix"] .attach-thumb[data-toggle="modal"]').length > 0 ) { //clear matrix loop item - modal toggle
8636                        var idx =  $('#el-property [data-loop-type="matrix"] .attach-thumb[data-toggle="modal"]').attr('idx');
8637                        $('#el-property [data-loop-type="matrix"] .attach-thumb[data-toggle="modal"]').removeAttr('data-toggle');
8638    
8639                        if(!$('#el-property [data-loop-type="matrix"] .ui-sortable').children().first().hasClass('active')) 
8640                            $('#el-property [data-loop-type="matrix"] .ui-sortable').children().first().click();
8641                    }
8642    
8643                    if(typeof selectEL != 'undefined' && selectEL && typeof $('.'+selectEL).attr('data-parallax') != "undefined" && $('.'+selectEL).attr('data-parallax')) {
8644                        $('#prop-method-background').attr('data-target','');
8645                    }
8646    
8647                    $('#mystorage .add-folder').attr('data-content','').popover('hide');
8648                    $(this).find('.resource-useit').show();
8649                    selectCount = 0;
8650                })
8651                .on('hidden.bs.modal', function(e) {
8652                    if(typeof isEDIT != 'undefined' && isEDIT === false) editEL = '';
8653                    $(this).find('.resource-useit').removeClass('clicked');
8654                    $.resource.modalOpenSET(false);
8655                })
8656                .on('mousemove', function(e) {
8657                    mouseX = (typeof e.clientX != 'undefined') ? e.clientX : e.pageX;
8658                    mouseY = (typeof e.clientY != 'undefined') ? e.clientY : e.pageY;
8659                    if(fileDrag && $(this).is(':not(.flink-fileupload)')) moveResourceTooltip();
8660                })
8661                .on('mouseup', '.resource-files-content', function(e) {
8662                    hideResourceTooltip();
8663                    fileDrag = false;
8664                    dragTooltipModal = $();
8665                });
8666
8667
8668            
8669            /* modal-resourcebox 00__common */
8670            $('.modal-resourcebox')
8671                .on('click', '#btn-resourcebox-fullwidth', function(e) {
8672                    $(this).closest('#el-fileupload').toggleClass('full-width');
8673                })
8674                .on('change', '.resource-ctrl-layout select', function(e) {
8675                    $(this).next('.btn.dropdown-toggle').attr('title','');
8676                    var thisResourceFiles = $(this).closest('.tab-pane.active').find('ul.files'),
8677                        layout = $(this).val();
8678    
8679                    thisResourceFiles.attr('data-layout', layout);
8680                })
8681                .on('change', '.resource-ctrl-sort select', function(e) {
8682                    $(this).next('.btn.dropdown-toggle').attr('title','');
8683                    var thisResourceTab = $(this).closest('.tab-pane.active');
8684                    if(thisResourceTab.find('ul.files').hasClass('empty') || thisResourceTab.find('ul.files .resource-empty-area').length > 0) return false;
8685                    else thisResourceTab.find('.resource-search-btn').click();
8686                })
8687                .on('keyup', '.resource-search-stx', function(e) {
8688                    var keyCode = e.keyCode;
8689                    if(keyCode == 13) $(this).closest('.resource-search-group').find('.resource-search-btn').click();
8690                })
8691                .on('focusin', '.resource-search-stx', function() {
8692                    var $input = $(this);
8693                    if($input.closest('#iconstorage').length > 0 && typeof setIconStorageSearchState == 'function') {
8694                        var hasSearch = $input.val().trim() !== '';
8695                        setIconStorageSearchState(hasSearch, hasSearch);
8696                    }
8697                })
8698                .on('focusout', '.resource-search-stx', function() {
8699                    var $input = $(this);
8700                    if($input.closest('#iconstorage').length > 0 && typeof setIconStorageSearchState == 'function') {
8701                        setTimeout(function() {
8702                            var hasSearch = $input.val().trim() !== '';
8703                            setIconStorageSearchState(hasSearch, hasSearch);
8704                        }, 0);
8705                    }
8706                })
8707                .on('click', '.resource-search-btn', function(e) {
8708                    var thisSearchBtn = $(this),
8709                        thisSearchInput = thisSearchBtn.closest('.resource-search-group').find('.resource-search-stx'),
8710                        rmode = thisSearchBtn.attr('id').replace(/\-resource\-search$/gi,''),
8711                        fsearch = thisSearchInput.val().trim(),
8712                        fsort = (rmode == 'my') ? thisSearchBtn.closest('.resource-row').find('.resource-ctrl-sort select').val() : '';
8713    
8714                    if(thisSearchBtn.hasClass('clicked')) return false;
8715                    thisSearchBtn.addClass('clicked');
8716                    thisSearchBtn.data('fsearch', fsearch);
8717    
8718                    if(rmode == 'my' || rmode == 'icon') {
8719                        thisSearchInput.val(fsearch);
8720                        UPLOAD = 0;
8721                        UPLOADED = 0;
8722                        PROGRESS = 0;
8723                        cPage = 1;
8724                        if(rmode == 'icon') {
8725                            var icon_type = (typeof getIconStorageType == 'function') ? getIconStorageType() : ($('#iconstorage .icon_type.active').attr('data-icontype') || 'default');
8726                            if(typeof normalizeIconStorageType == 'function') icon_type = normalizeIconStorageType(icon_type);
8727                            if(typeof setIconStorageSearchState == 'function') setIconStorageSearchState(fsearch !== '', fsearch !== '');
8728                            fsort = fsearch ? 'total' : $('#iconstorage .resource-category-group').find('.fitem-category.active').attr('data-category');
8729                            if(fsearch) {
8730                                var iconResourceFiles = $('#iconstorage ul.files');
8731                                if(typeof appendIconStorageListProgress == 'function') {
8732                                    iconResourceFiles.empty();
8733                                    appendIconStorageListProgress(iconResourceFiles);
8734                                } else if(iconResourceFiles.find('.listprogress').length == 0) {
8735                                    iconResourceFiles.empty().append('<li class="listprogress">
8735<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>');
8736                                }
8737                                setTimeout(function() {
8738                                    if(thisSearchInput.val().trim() != fsearch) {
8739                                        thisSearchBtn.removeClass('clicked');
8740                                        return;
8741                                    }
8742                                    resourceGetPage(1,SFOLDER_ACTIVE,fsort,fsearch);
8743                                }, 30);
8744                                return false;
8745                            }
8746                        }
8747                        resourceGetPage(1,SFOLDER_ACTIVE,fsort,fsearch);
8748                    } else if(rmode == 'free') {
8749                        if(fsearch == '') {
8750                            freeSearch.type = 'new';
8751                            freeSearch.page = 1;
8752                            freeSearch.text = '';
8753                            freeSearch.total = -1;
8754                            $.resource.modalContentInit('free');
8755                            $('#freestorage .resource-folderlist li[data-type="new"]').addClass('active').siblings().removeClass('active');
8756                            $('#freestorage ul.files').attr('data-type','new');
8757                            getFreeImage(freeSearch.page,freeSearch.type);
8758                            return false;
8759                        }
8760                        $('#freestorage .resource-useit').removeClass('active');
8761                        $('#freestorage ul.files, #freestorage .resource-selected-ul').empty();
8762                        $('#freestorage .resource-search-total').text('');
8763                        $('#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>');
8764                        $('#freestorage .resource-folderlist li').removeClass('active');
8765
8766                        freeSearch.type = 'search';
8767                        freeSearch.page = 1;
8768                        freeSearch.text = fsearch;
8769                        freeSearch.total = 0;
8770                        
8771                        $.getJSON('/template/translate/' + encodeURIComponent(fsearch), function(data) {
8772                            if($('#freestorage .resource-search-stx').val().trim() != fsearch) {
8773                                thisSearchBtn.removeClass('clicked');
8774                                if(freeSearch.text == fsearch) $('#freestorage ul.files .listprogress').remove();
8775                                return false;
8776                            }
8777                            var search = (data && data.data && data.data.translations && data.data.translations[0] && data.data.translations[0].translatedText) ? data.data.translations[0].translatedText : fsearch;
8778                            freeSearch.text = fsearch;
8779                            getFreeImage(freeSearch.page,freeSearch.type,search);
8780                        }).fail(function() {
8781                            if($('#freestorage .resource-search-stx').val().trim() != fsearch) {
8782                                thisSearchBtn.removeClass('clicked');
8783                                if(freeSearch.text == fsearch) $('#freestorage ul.files .listprogress').remove();
8784                                return false;
8785                            }
8786                            freeSearch.text = fsearch;
8787                            getFreeImage(freeSearch.page,freeSearch.type,fsearch);
8788                        });
8789                    }
8790                }).on('input', '.resource-search-stx', function() {
8791                    var $input = $(this);
8792                    var $searchBtn = $input.closest('.resource-search-group').find('.resource-search-btn');
8793                    if($input.closest('#iconstorage').length > 0 && typeof setIconStorageSearchState == 'function') {
8794                        var hasIconSearch = $input.val().trim() !== '';
8795                        setIconStorageSearchState(hasIconSearch, hasIconSearch);
8796                        if(hasIconSearch && $searchBtn.data('fsearch') != $input.val().trim()) {
8797                            var iconResourceFiles = $('#iconstorage ul.files');
8798                            if(typeof appendIconStorageListProgress == 'function') {
8799                                iconResourceFiles.empty();
8800                                appendIconStorageListProgress(iconResourceFiles);
8801                            } else if(iconResourceFiles.find('.listprogress').length == 0) {
8802                                iconResourceFiles.empty().append('<li class="listprogress">
8802<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>');
8803                            }
8804                        }
8805                    }
8806                    clearTimeout($input.data('searchTimer'));
8807                    if($searchBtn.data('fsearch') != $input.val().trim()) {
8808                        $searchBtn.removeClass('clicked');
8809                    }
8810
8811                    $input.data('searchTimer', setTimeout(function () {
8812                        $searchBtn.trigger('click');
8813                    }, 400));
8814                })
8815                .on('scroll', 'ul.files', function(e) {
8816                })
8817                .on('mousedown', 'ul.files', function(e) {
8818                    var thisResourceTab = $(this).closest('.tab-pane.active'),
8819                        thisResourceFiles = $(this),
8820                        thisResourceSelected = thisResourceTab.find('.resource-selected-ul'),
8821                        rmode = thisResourceTab.attr('id').replace(/storage$/gi,'');
8822
8823                    if(rmode == 'my' && isFEdit) thisResourceTab.find('#nestableFolder .fln-group .btn-fln-cancel').click();
8824
8825                    if(e.shiftKey) {
8826                        thisResourceSelected.children('li').each(function () {
8827                            var set_key = (rmode == 'free') ? 'id' : 'seq',
8828                                set_val = $(this).attr('data-'+set_key);
8829                            if(thisResourceFiles.find('.ui-selected .fitem-ctrl > ul[data-' + set_key + '="' + set_val + '"]').length == 0) {
8830                                thisResourceFiles.find('.fitem-ctrl > ul[data-' + set_key + '="' + set_val + '"]').closest('.fitem').addClass('ui-selected');
8831                            }
8832                        });
8833                    } else {
8834                        if(!e.ctrlKey && !$(e.target).hasClass('.ui-selected')) {
8835                            $(e.target).removeClass('ui-selected');
8836                        }
8837                    }
8838                })
8839                .on('click', '.fitem', function(e) {
8840                    var thisResourceTab = $(this).closest('.tab-pane.active'),
8841                        thisResourceSelected = thisResourceTab.find('.resource-selected-ul'),
8842                        rmode = thisResourceTab.attr('id').replace(/storage$/gi,'');
8843
8844                    if(e.ctrlKey || e.shiftKey) {
8845                        if($(this).hasClass('ui-selected')) {
8846                            $(this).removeClass('ui-selected');
8847                            var unset_key = (rmode == 'free') ? 'id' : 'seq',
8848                                unset_val = $(this).find('.fitem-ctrl > ul').attr('data-'+unset_key);
8849                            thisResourceSelected.children('li[data-' + unset_key + '="' + unset_val + '"]').remove();
8850                        }
8851
8852                        setResourceSelectedBox(rmode);
8853                    }
8854                })
8855                .on('click', '.fitem-ctrl-imgview', function(e) {
8856                    var thisResourceTab = $(this).closest('.tab-pane.active'),
8857                        thisResourceCtrlImgview = $(this);
8858
8859                    $('.modal-resourcebox .fitem-ctrl-imgview').removeAttr('href').removeAttr('data-gallery');
8860                    $('.resourcebox-frame').html('\
8861                            <div id="rframe" class="blueimp-gallery blueimp-gallery-controls" data-start-slideshow="false" data-slideshow-interval="5000">\
8862                                <div class="slides"></div>\
8863                                <div class="zoomable hide"></div>\
8864                                <h3 class="title"></h3>\
8865                                <ul class="ctrls">\
8866                                    <li>\
8867                                        <a class="view-original" data-toggle="tooltip" data-placement="bottom" data-html="true" data-original-title="' + $.lang[LANG]['gallery.slide.tooltip.view-fullscreen'] + '">\
8868                                            <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>\
8869                                            <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>\
8870                                        </a>\
8871                                    </li>\
8872                                    <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>\
8873                                    <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">
8873<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>\
8874                                    <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>\
8875                                </ul>\
8876                            </div>\
8877                    ');
8878                    thisResourceCtrlImgview.attr('href', $(this).attr('data-url')).attr('data-gallery','#rframe');
8879                })
8880                .on('mouseenter', '.resource-selected-ul > li', function(e) {
8881                    $(this).find('.selected-hover').show();
8882                })
8883                .on('mouseleave', '.resource-selected-ul > li', function(e) {
8884                    $(this).find('.selected-hover').hide();
8885                })
8886                .on('click', '.resource-selected-ul > li > .selected-hover', function(e) {
8887                    $(this).popover('destroy');
8888
8889                    var thisResourceTab = $(this).closest('.tab-pane.active'),
8890                        thisResourceFiles = thisResourceTab.find('ul.files'),
8891                        thisResourceSelected = thisResourceTab.find('.resource-selected-ul'),
8892                        rmode = thisResourceTab.attr('id').replace(/storage$/gi,'');
8893    
8894                    $(this).closest('li').fadeOut(300,function() {
8895                        var del_key = (rmode == 'free') ? 'id' : 'seq',
8896                            del_val = $(this).attr('data-'+del_key);
8897                        $(this).remove();
8898    
8899                        thisResourceFiles.find('.fitem.ui-selected .fitem-ctrl > ul[data-' + del_key + '="' + del_val + '"]').closest('.fitem').removeClass('ui-selected');
8900                        setResourceSelectedBox(rmode);
8901                    });
8902    
8903                    if(thisResourceSelected.children('li').length == 1) {
8904                        thisResourceTab.find('.resource-useit').removeClass('active');
8905                    }
8906                });
8907
8908            var folderSearchTimer = null;
8909            $('.modal-resourcebox')
8910            // Enter키로 즉시 필터
8911            .on('keyup', '.folder-search-stx', function(e){
8912                var keyCode = e.keyCode;
8913                if(keyCode == 13) $(this).closest('.folder-search-group').find('.folder-search-btn').trigger('click');
8914            })
8915
8916            // 타이핑 멈추면 자동 필터(0.3~0.5초 추천)
8917            .on('input', '.folder-search-stx', function(){
8918                var $input = $(this);
8919                clearTimeout(folderSearchTimer);
8920                folderSearchTimer = setTimeout(function(){
8921                    $input.closest('.folder-search-group').find('.folder-search-btn').trigger('click');
8922                }, 300);
8923            })
8924
8925            .on('click', '.folder-search-stx', function(){
8926                $('#nestableFolder .fli[data-id="clEmptyFolder"]').remove();
8927                $('#nestableFolder .btn-fln-cancel').trigger('click');
8928                isFEdit = false;
8929            })
8930
8931            // 버튼 클릭 시 필터링 실행
8932            .on('click', '.folder-search-btn', function(){
8933                var $group = $(this).closest('.folder-search-group');
8934                var q = $group.find('.folder-search-stx').val().trim().toLowerCase();
8935
8936                var $items = $('#nestableFolder .dd-list.fll > .fli');
8937
8938                // 비어있으면 전체 표시
8939                if(q === ''){
8940                    if(isFEdit) {
8941                        var $cancelBtn = $('#nestableFolder .fln-group .btn-fln-cancel');
8942                        if($cancelBtn.length > 0) $cancelBtn.trigger('click');
8943                    }
8944
8945                    $('#nestableFolder .fli[data-id="clEmptyFolder"]').remove();
8946                    isFEdit = false;
8947                    $.resource.setMystorageFolder('nodrag',false);
8948                    $items.show();
8949                    return;
8950                }
8951
8952                $items.each(function(){
8953                    var $li = $(this);
8954
8955                    if($li.hasClass('fli-first')) { $li.show(); return; }
8956                    // 폴더명 텍스트(번역 들어가는 span이라도 text()는 나옵니다)
8957                    var name = $li.find('.dd-fln').text().trim().toLowerCase();
8958
8959                    // "all" 같은 특수 항목은 항상 보이게 하고 싶으면 아래처럼 예외처리 가능
8960                    // if($li.hasClass('fli-first')) { $li.show(); return; }
8961
8962                    $li.toggle(name.indexOf(q) !== -1);
8963                });
8964            });
8965
8966            /* modal-resourcebox 01__mystorage */
8967            var mystorageFolderEdit = function(ddfl) {
8968                var myResourceFolderlist = $('#mystorage #nestableFolder'),
8969                    edit_fli = ddfl.closest('li.fli'),
8970                    fln_group_css = (myResourceFolderlist.find('.dd-list.fll').height() >= myResourceFolderlist.height() && $.browser.safari == undefined) ? 'style="max-width: 173px;"' : '',
8971                    fln_input_css = (myResourceFolderlist.find('.dd-list.fll').height() >= myResourceFolderlist.height() && $.browser.safari == undefined) ? 'style="max-width: 136px;"' : '',
8972                    checkAdd = (edit_fli.attr('data-id') == 'clEmptyFolder') ? true : false,
8973                    beforeFln = (checkAdd) ? '' : edit_fli.attr('data-id');
8974
8975                if(beforeFln.length > 0) beforeFln = beforeFln.replace(/-/g,' ');
8976
8977                var input_html = '\
8978                    <div class="fln-group input-group" ' + fln_group_css + '>\
8979                        <input class="fln-input form-control" type="text" value="' + beforeFln + '"  ' + fln_input_css + '/>\
8980                        <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>\
8981                        <div class="btn-fln-cancel"><i class="fa fa-times"></i></div>\
8982                    </div>\
8983                    ';
8984
8985                $(input_html).appendTo(edit_fli.find('.dd-fln'));
8986                if(edit_fli.find('.fln-input').is(':not(:focus)')) edit_fli.find('.fln-input').focus();
8987
8988                $.resource.setMystorageFolder('nodrag',true);
8989            }
8990
8991            var mystorageFolderUpdate = function(prevText,newText) {
8992                $.ajax({
8993                    type: 'POST',
8994                    url: '/template/resource/update-ffolder',
8995                    data: { sid: SID, prevffolder: prevText, newffolder: newText },
8996                    async: true,
8997                    success: function(data) {
8998                        checkError(data);
8999                    }
9000                });
9001            }
9002
9003            var getNextMystorageFolderId = function() {
9004                var maxId = 0;
9005
9006                if (SFOLDER && Array.isArray(SFOLDER) && SFOLDER.length) {
9007                    $.each(SFOLDER, function(_, folder) {
9008                        var id = parseInt(folder && folder.id, 10);
9009                        if (!isNaN(id) && id > maxId) maxId = id;
9010                    });
9011                }
9012
9013                $('#nestableFolder .fli').each(function() {
9014                    var id = parseInt($(this).attr('data-fid'), 10);
9015                    if (!isNaN(id) && id > maxId) maxId = id;
9016                });
9017
9018                return maxId + 1;
9019            }
9020
9021            var mystorageFileDelete = function(file,seq,callback) {
9022                if(CANCEL) return true;
9023                $.ajax({
9024                    type: 'POST',
9025                    url: '/template/resource/delete',
9026                    data: { s: file, sid: SID, seq: seq },
9027                    async: true,
9028                    success: function(data) {
9029                        checkError(data);
9030                        if(typeof callback == 'function') {
9031                            callback();
9032                        }
9033                    }
9034                });
9035            }
9036
9037            $('.modal-resourcebox')
9038                .on('click', 'a[href="#mystorage"]', function(e) {
9039                    setResourceSelectedBox('my');
9040                    if(isFEdit) $('#nestableFolder .fln-group .btn-fln-cancel').click();
9041                });
9042
9043            $('.modal-resourcebox #mystorage')
9044                .on('scroll touchmove mousewheel', '#nestableFolder', function(e) {
9045                    if(isFEdit || $(this).find('.fln-group.input-group').length > 0) {
9046                        e.preventDefault();
9047                        return false;
9048                    }
9049                    var myResourceTab = $(this).closest('.tab-pane.active'),
9050                        myResourceFolderlist = $(this);
9051
9052                    if(myResourceTab.find('.dd-header .popover.in').length > 0) {
9053                        var inputEL = myResourceFolderlist.find('.fln-input'),
9054                            checkScroll = (myResourceFolderlist.find('.dd-list.fll').height() >= myResourceFolderlist.height()) ? true : false,
9055                            offset = myResourceTab.find('.dd-header').outerHeight() + 3,
9056                            top = (checkScroll) ? inputEL.closest('li').position().top - myResourceFolderlist.scrollTop() : inputEL.offset().top - myResourceFolderlist.offset().top;
9057                        myResourceTab.find('.dd-header .popover.in').css('top', offset + top);
9058                    }
9059                })
9060                .on('mouseup', '#nestableFolder .fli', function(e) {
9061                    var fliFolder = $('#nestableFolder'),
9062                        fliResourceTab = $(this).closest('.tab-pane.active'),
9063                        fliResourceFiles = fliResourceTab.find('ul.files'),
9064                        fliResourceSelected = fliResourceTab.find('.resource-selected-ul'),
9065                        rmode = fliResourceTab.attr('id').replace(/storage$/gi,''),
9066                        fsort = fliResourceTab.find('.resource-ctrl-sort select').val(),
9067                        fsearch = fliResourceTab.find('.resource-search-stx').val();
9068
9069                    if(fileDrag) {
9070                        fliResourceFiles.find('.fitem .fitem-visual').removeClass('ui-selected');
9071                        fliFolder.find('.fli').removeClass('drag-selected');
9072    
9073                        // selected-files 파일을 $.post로 보내고 리스트 페이지 갱신
9074                        var prevffolder = [], fsizes = [], fseqs = [],
9075                            targetffolder = $(this).attr('data-id');
9076
9077                        fliResourceSelected.children('li').each(function() {
9078                            prevffolder.push($(this).attr('data-ffolder')); 
9079                            fsizes.push(parseInt($(this).find('p.selected-file-size .size').text()));
9080                            fseqs.push($(this).attr('data-seq'));
9081                        });
9082    
9083                        if(SID) {
9084                            var activeffolder = fliFolder.find('.fli.active').attr('data-id'),
9085                                r_pages = Number(fliResourceTab.find('.resource-paging .pagination').attr('data-pages')),
9086                                r_page = Number(fliResourceTab.find('.resource-paging .pagination li.active').text()),
9087                                r_file_cnt = fliResourceFiles.find('.fitem').length;
9088    
9089                            $.post('/template/resource/update-fmove', { sid: SID, fseqs: fseqs, targetffolder: targetffolder }, function (data) {
9090                                checkError(data);
9091                                $.each(fseqs, function(i,v) {
9092                                    if(prevffolder[i] != targetffolder) {
9093                                        if(prevffolder[i] != 'all') $.resource.setMystorageFolder('set_fli_state', {'count': -1, 'size': -fsizes[i], ffolder: prevffolder[i], state: 'move'});
9094                                        if(targetffolder != 'all') $.resource.setMystorageFolder('set_fli_state', {'count': 1, 'size': fsizes[i], ffolder: targetffolder, state: 'move'});
9095                                    }
9096                                });
9097                                updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9098    
9099                                r_page = ((r_file_cnt - fseqs.length) == 0 && r_pages<=r_page && SFOLDER_ACTIVE) ? r_page-1 : r_page;
9100                                r_page = 1;
9101                                cPage = 1;
9102                                resourceGetPage(r_page,SFOLDER_ACTIVE,fsort,fsearch);
9103                                
9104                                fliResourceFiles.find('.fitem .resource-image.ui-selected').removeClass('ui-selected');
9105                                fliResourceFiles.find('.fitem.ui-selected').removeClass('ui-selected');
9106                                fliResourceSelected.empty();
9107                                setResourceSelectedBox(rmode);
9108                            }, 'json');
9109                        }
9110                    }
9111                })
9112                .on('mouseenter', '#nestableFolder .fli', function(e) {
9113                    $('#nestableFolder .fli').removeClass('drag-selected');
9114                    if(fileDrag) {
9115                        $(this).addClass('drag-selected');
9116                    }
9117                })
9118                .on('mouseleave', '#nestableFolder .fli', function(e) {
9119                    $(this).removeClass('drag-selected').siblings().removeClass('drag-selected');
9120                })
9121                .on('click', '#nestableFolder .fli:not(.active)', function(e) {
9122                    if( isFEdit ||
9123                        $(e.target).is('.fln-input, .fli-hover, [class*="btn-fln-"]')
9124                    ) { return; }
9125
9126                    if($(this).parents('.fll').length == 2) depfolderClick = true;
9127                    if($(this).parents('.fll').length == 1 && depfolderClick) {
9128                        depfolderClick = false;
9129                        return;
9130                    } else {
9131                        $(this).addClass('active').siblings('.fli').removeClass('active');
9132                        SFOLDER_ACTIVE = ($(this).attr('data-id')!='all') ? $(this).attr('data-id') : '';
9133                        cPage = 1;
9134                        
9135                        var myResourceTab = $('#mystorage'),
9136                            fsort = myResourceTab.find('.resource-ctrl-sort select').val();
9137                        myResourceTab.find('.resource-search-stx').val('');
9138                        resourceGetPage(1,SFOLDER_ACTIVE,fsort,'');
9139                    }
9140                })
9141                .on('click', '#nestableFolder .fli .dd-fle', function(e) {
9142                    if(isFEdit) { return; }
9143                    if($(this).parent().closest('.fli').index() > 0) {
9144                        isFEdit = true;
9145                        mystorageFolderEdit($(this));
9146                    }
9147                })
9148                .on('click', '#nestableFolder .fli .dd-fln .btn-fln-cancel', function(e) {
9149                    $('#mystorage .add-folder').attr('data-content','').popover('hide');
9150                    if($(this).closest('li.fli').attr('data-id') == 'clEmptyFolder') $(this).closest('li.fli').remove();
9151                    else {
9152                        $(this).closest('.dd-fln').find('.fln-group').remove();
9153                        $(this).remove();
9154                    }
9155                    isFEdit = false;
9156                    $.resource.setMystorageFolder('nodrag',false);
9157                    if($('#nestableFolder .fll .fli.active').length == 0) $('#nestableFolder .fli').eq(0).click();
9158                })
9159                .on('click', '#nestableFolder .fli .dd-flf', function (e) {
9160                    e.preventDefault();
9161                    e.stopPropagation();
9162
9163                    var $item = $(this).closest('.dd-item');
9164                    var $fav = $(this);
9165
9166                    var fid = String($item.attr('data-fid') || '').trim();
9167                    
9168                    var raw = $('#nestableFolder-output').val();
9169                    if (!raw || raw.trim().length === 0 || raw === '[]') {
9170                        raw = (SFOLDER && Array.isArray(SFOLDER) && SFOLDER.length) ? JSON.stringify(SFOLDER) : '[]';
9171                        $('#nestableFolder-output').val(raw);
9172                    }
9173
9174                    var data = [];
9175                    var next = null;
9176                    if (SFOLDER && Array.isArray(SFOLDER) && SFOLDER.length) {
9177                        data = $.extend(true, [], SFOLDER);
9178                    } else {
9179                        try { data = JSON.parse(raw); } catch (err) { data = []; }
9180                    }
9181
9182                    if (!data.length || !fid) return false;
9183
9184                    $.each(data, function (i, folder) {
9185                        if (String(folder.id) !== fid) return true;
9186
9187                        var cur = String(folder.favorite || '0');
9188                        next = (cur === '1') ? '0' : '1';
9189                        folder.favorite = next;
9190                        return false;
9191                    });
9192
9193                    if (next === null) return false;
9194
9195                    $item.attr('data-favorite', next);
9196                    $fav.attr('data-fav', next).html((next === '1') ? clSVG('pin', 12, 12) : clSVG('pin_blank', 12, 12));
9197
9198                    // 3) output 갱신 + SFOLDER 갱신
9199                    SFOLDER = data;
9200                    $('#nestableFolder-output').val(JSON.stringify(data));
9201                    var nextVal = sortFolderFavoritesTop();
9202                    if (!nextVal || nextVal === '[]') {
9203                        nextVal = JSON.stringify(SFOLDER);
9204                        $('#nestableFolder-output').val(nextVal);
9205                    }
9206
9207                    // 4) 서버 저장
9208                    if (SID) {
9209                        $.ajaxSetup({ async: false });
9210                        $.post('/template/update/type/folder', { s: nextVal, id: SID }, function (res) {
9211                            checkError(res);
9212                        }, 'json');
9213                    }
9214
9215                    return false;
9216                })
9217                .on('click', '#nestableFolder .fli .dd-fln .btn-fln-save', function(e) {
9218                    var myResourceTab = $(this).closest('.tab-pane.active'),
9219                        myResourceFiles = myResourceTab.find('ul.files'),
9220                        myResourceFolderlist = myResourceTab.find('#nestableFolder'),
9221                        myResourceFolderItem = $(this).closest('li.fli'),
9222                        checkPageReload = myResourceFolderItem.hasClass('active'),
9223                        fsort = myResourceTab.find('.resource-ctrl-sort select').val(),
9224                        fsearch = myResourceTab.find('.resource-search-stx').val(),
9225                        inputEL = $(this).closest('.fln-group').find('.fln-input'),
9226                        regExp = /[\{\}\[\]\/!?.,;:|\)*~`^\-_+<>@\#$%&\\\=\(\'\"]/gi,
9227                        err_str = '',
9228                        checkAdd = (myResourceFolderItem.attr('data-id') == 'clEmptyFolder') ? true : false,
9229                        beforeFln = (checkAdd) ? '' : myResourceFolderItem.attr('data-id'),
9230                        afterFln = inputEL.val().trim();
9231
9232                    if(afterFln.length == 0) {
9233                        err_str = $.lang[LANG]['editor.resource.regExp.empty'];
9234                    } else if(afterFln == 'clEmptyFolder') {
9235                        err_str = $.lang[LANG]['editor.resource.regExp.clEmptyFolder'];
9236                    } else if(checkEmojis(afterFln)) {
9237                        err_str = $.lang[LANG]['config.unable.emoji'];
9238                    } else if(regExp.test(afterFln)) {
9239                        err_str = $.lang[LANG]['editor.resource.regExp.specialchar'];
9240                    } else if($('#nestableFolder .fli[data-id="'+afterFln.replace(/ /g,'-')+'"]').length > 0 && beforeFln != afterFln.replace(/ /g,'-')) {
9241                        err_str = $.lang[LANG]['editor.resource.regExp.overlap'];
9242                    } else if(afterFln.length > 20) {
9243                        err_str = $.lang[LANG]['editor.resource.regExp.maximum'];
9244                    } else { 
9245                        err_str = '';
9246                    }
9247
9248                    afterFln = afterFln.replace(/ /g,'-');
9249                    if(err_str!=''){
9250                        inputEL.focus();
9251                        myResourceTab.find('.add-folder').attr('data-content',err_str).popover('show');
9252
9253                        var checkScroll = (myResourceFolderlist.find('.dd-list.fll').height() >= myResourceFolderlist.height()) ? true : false,
9254                            offset = myResourceTab.find('.dd-header').outerHeight() + 3,
9255                            top = (checkScroll) ? inputEL.closest('li').position().top - myResourceFolderlist.scrollTop() : inputEL.offset().top - myResourceFolderlist.offset().top;
9256                        myResourceTab.find('.dd-header .popover.in').css('top', offset + top);
9257                    } else { 
9258                        myResourceTab.find('.add-folder').attr('data-content','').popover('hide');
9259
9260                        if(checkAdd) {
9261                            var newFid = parseInt(myResourceFolderItem.attr('data-fid'), 10);
9262                            if(isNaN(newFid) || newFid < 1) {
9263                                myResourceFolderItem.attr('data-fid', getNextMystorageFolderId());
9264                            }
9265                        }
9266
9267                        inputEL.closest('.fli').attr('data-id',afterFln).find('[attr-id]').attr('attr-id',afterFln);
9268                        inputEL.closest('.dd-fln').html(afterFln.replace(/-/g,' '));
9269                        updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9270                        mystorageFolderUpdate(beforeFln,afterFln);
9271
9272                        if(checkPageReload) {
9273                            SFOLDER_ACTIVE = afterFln;
9274                            resourceGetPage(1,SFOLDER_ACTIVE,fsort,fsearch);
9275                        } else {
9276                            myResourceFiles.find('.fitem .data-ffolder ul[data-ffolder="'+beforeFln+'"]').each(function() {
9277                                $(this).attr('data-ffolder',afterFln);
9278                            })
9279                        }
9280
9281                        isFEdit = false;
9282                        $.resource.setMystorageFolder('nodrag',false);
9283                    }
9284                })
9285                .on('keyup', '#nestableFolder .fli .dd-fln .fln-input', function(e) {
9286                    if(e.keyCode == 13) $(this).closest('.fln-group').find('.btn-fln-save').click();
9287                })
9288                .on('click', '#nestableFolder .fli .dd-fld', function(e) {
9289                    if(isFEdit) { return; }
9290                    if($('#nestableFolder .fll > .fli').length < 2) { return false; }
9291
9292                    isFEdit = true;
9293                    $.resource.setMystorageFolder('nodrag',true);
9294                    var myResourceTab = $('#mystorage'),
9295                        myResourceFiles = myResourceTab.find('ul.files'),
9296                        myResourceSelected = myResourceTab.find('.resource-selected-ul'),
9297                        myResourceFolderItem = $(this).closest('li.fli'),
9298                        checkPageReload = (myResourceFolderItem.hasClass('active') || $('#nestableFolder .fli[data-id="all"]').hasClass('active')) ? true : false,
9299                        fsort = myResourceTab.find('.resource-ctrl-sort select').val(),
9300                        fsearch = myResourceTab.find('.resource-search-stx').val();
9301
9302                    var fli_count = myResourceFolderItem.find('.dd-flc').attr('attr-count');
9303                    fli_count = (typeof fli_count != 'undefined' && /^[0-9]*$/.test(fli_count)) ? fli_count * 1 : 0;
9304                    if(fli_count > 0) {
9305                        var prevffolder = myResourceFolderItem.attr('data-id');
9306                        var modal_str = '\
9307                                <div class="popup-info edit-link-info">'+$.lang[LANG]['editor.resource.folder.delete.confirm']+'</div>\
9308                                <ul class="duplicate-gallery-content delete-folder">\
9309                                    <li class="link-type active">\
9310                                        <div class="delete">\
9311                                            ' + clSVG('checkbox_active',20,20,false) + '\
9312                                            <h5>'+$.lang[LANG]['editor.resource.folder.delete.folderOnly']+'</h5>\
9313                                        </div>\
9314                                    </li>\
9315                                    <li class="link-type">\
9316                                        <div class="delete-with-resource">\
9317                                            ' + clSVG('checkbox_active',20,20,false) + '\
9318                                            <h5>'+$.lang[LANG]['editor.resource.folder.delete.all']+'</h5>\
9319                                        </div>\
9320                                    </li>\
9321                                </ul>\
9322                        ';
9323
9324                        var modal = $(this).showModalFlat($.lang[LANG]['editor.resource.folder.delete'], modal_str, true, true, function() {
9325                            var checked = $('.link-type.active').find('div').attr('class');
9326
9327                            $.ajaxSetup({ async : true });
9328                            if(checked == 'delete-with-resource') {
9329                                checkPageReload = true;
9330                                $.post('/template/resource/get-folder-resource', { sid: SID, prevffolder: prevffolder }, function (data) {         
9331                                    checkError(data);
9332
9333                                    var files = data.files;
9334                                    var fileDeleteModal = $(this).showModalFlat($.lang[LANG]['config.common.resource.delete.title'],$.lang[LANG]['config.common.resource.delete'], true, true, function() {
9335                                        fileDeleteModal.modal('hide');
9336                                        $.progressON();
9337                                        var seqs = [], sizes = [], ffolders = [];
9338                                        $.each(files, function(idx, f){
9339                                            seqs.push(f.seq);
9340                                            sizes.push(f.file_size);
9341                                            ffolders.push(f.file_folder);
9342                                        });
9343                                        var total = files.length,
9344                                            deleting = '',
9345                                            progress = 0;
9346                                            loading = '<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i> ';
9347                                            done = 0; deleting = $('p.fitem-name[data-seq="' + seqs[0] + '"]').text();
9348                                        $('.progressModal .info1').html(loading + deleting);
9349
9350                                        $.each(files,function(i,f) {
9351                                            var t = setTimeout(function() {
9352                                                if(CANCEL) {
9353                                                    if(ABORT) {
9354                                                        resourceGetPage(1,SFOLDER_ACTIVE,fsort,fsearch);
9355                                                        updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9356                                                        ABORT = false;
9357                                                        $.progressOFF();
9358                                                    }
9359                                                    i=0; return false;
9360                                                }
9361                                                mystorageFileDelete(f.file_name, f.seq, function() {
9362                                                    done++;
9363                                                    progress = parseInt((done / total) * 100,10);
9364                                                    $('.file-upload-progress .progress-bar').css('width',progress + "%");
9365                                                    $('.progressModal .info2').text(done.toString() + ' / ' + total.toString());
9366                                                    
9367                                                    $.resource.setMystorageFolder('set_fli_state', {'count': -1, 'size': -sizes[i], ffolder: 'all', state: 'delete'});
9368                                                    if(ffolders[i] != '' && ffolders[i] != 'all') {
9369                                                        $.resource.setMystorageFolder('set_fli_state', {'count': -1, 'size': -sizes[i], ffolder: ffolders[i], state: 'delete'});
9370                                                    }                       
9371
9372                                                    if(total == done) {
9373                                                        myResourceFolderItem.addClass('deleted');
9374                                                        setTimeout(function() {
9375                                                            modal.modal('hide');
9376                                                        },500);
9377                                                    } else {
9378                                                        deleting = $('p.fitem-name[data-seq="' + seqs[i+1] + '"]').text();
9379                                                        $('.progressModal .info1').html(loading + deleting);
9380                                                    }
9381                                                });
9382                                            },500*i);
9383                                        });
9384                                    },'cancel','ok','modal-over-1 cl-cmmodal cl-s-btn cl-common-notice w560',false);
9385                                    
9386                                }, 'json');
9387                            } else { //폴더만 삭제
9388                                $.processON('delete folder...');
9389                                var deferred = $.Deferred();
9390                                $.post('/template/resource/delete-folder-only', { sid: SID, prevffolder: prevffolder }, function (data) {
9391                                    checkError(data);
9392                                    myResourceFolderItem.addClass('deleted');
9393                                    modal.modal('hide');
9394                                });
9395                            }
9396                            
9397                        }, '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() {
9398                            isFEdit = false;
9399                            $.resource.setMystorageFolder('nodrag',false);
9400
9401                            if($('.progressModal').length > 0) $.progressOFF();
9402                            if($('.processModal').length > 0) $.processOFF();
9403                            if(myResourceTab.find('#nestableFolder .fli.deleted').length > 0) {
9404                                myResourceTab.find('#nestableFolder .fli.deleted').remove();
9405                                updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9406
9407                                myResourceFiles.find('.fitem.ui-selected').removeClass('ui-selected');
9408                                myResourceSelected.children('li').remove();
9409                                if(checkPageReload) $('#nestableFolder .fll > .fli').first().removeClass('active').click();
9410                            }
9411                        });
9412                    } else {
9413                        var checkModal = $(this).showModalFlat($.lang[LANG]['editor.resource.folder.delete'], $.lang[LANG]['editor.resource.folder.delete.check'], true, true, function() {
9414                            myResourceFolderItem.remove();
9415                            updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9416                            checkModal.modal('hide');
9417                        }, 'cancel', 'ok', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 zindex1042', false, '', '', function() {
9418                            isFEdit = false;
9419                            $.resource.setMystorageFolder('nodrag',false);
9420
9421                            if(checkPageReload) $('#nestableFolder .fll > .fli').first().removeClass('active').click();
9422                            $.processOFF();
9423                        });
9424                    }
9425                })
9426                .on('click', '.add-folder', function(e) {
9427                    $('.add-folder').attr('data-content','').popover('hide');
9428                    var myResourceFolderlist = $('#mystorage #nestableFolder'),
9429                        myResourceFolderAdd = $(this);
9430
9431                    if(isFEdit || myResourceFolderlist.find('.fln-input').length > 0) {
9432                        if(myResourceFolderlist.find('.fln-input').length > 0) myResourceFolderlist.find('.fln-input').focus();
9433                        isFEdit = true;
9434                        $.resource.setMystorageFolder('nodrag',true);
9435                        return; 
9436                    }
9437                    var checkPlan = (typeof property == 'undefined') ? ((typeof VALIDPLAN == 'undefined') ? $.gallery.valid_plan : VALIDPLAN) : property.VALIDPLAN,
9438                        checkPlanType = (typeof property == 'undefined') ? ((typeof VALIDTYPE == 'undefined') ? $.gallery.valid_type : VALIDTYPE) : property.VALIDTYPE,
9439                        checkFREE = (!checkPlan || checkPlanType == 'PK') ? true : false;
9440                    var checkMaximum = (    (!checkFREE && myResourceFolderlist.find('.fli').length > 500) || 
9441                                            (checkFREE && myResourceFolderlist.find('.fli').length > 50)
9442                                        ) ? true : false;
9443                    if(checkMaximum) {
9444                        var max_msg = (!checkFREE) ? $.lang[LANG]['editor.resource.folder.maximum'] : $.lang[LANG]['editor.resource.folder.maximum.free'];
9445                        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() {
9446                            max_modal.closest('.flat-modal').next('.modal-backdrop').attr('style','z-index: 1041!important;');
9447                        });
9448                        return;
9449                    } else {
9450                        isFEdit = true;
9451
9452                        if(myResourceFolderlist.find('.fli[data-id="clEmptyFolder"]').length > 0) {
9453                            myResourceFolderlist.find('.fli[data-id="clEmptyFolder"]').find('.dd-fln').val('');
9454                        } else {
9455                            var add_folder = $.resource.getMystorageFolderHtml('clEmptyFolder', 0, 0, getNextMystorageFolderId());
9456                            myResourceFolderlist.find('.fll').append(add_folder);
9457                        }
9458
9459                        var input_html = '\
9460                            <div class="fln-group input-group">\
9461                                <input class="fln-input form-control" type="text"/>\
9462                                <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>\
9463                                <div class="btn-fln-cancel"><i class="fa fa-times"></i></div>\
9464                            </div>\
9465                            ';
9466
9467                        $(input_html).appendTo(myResourceFolderlist.find('.fli[data-id="clEmptyFolder"] .dd-fln')).find('.fln-input').focus();
9468                        if(myResourceFolderlist.find('.dd-list.fll').height() >= myResourceFolderlist.height() && $.browser.safari == undefined) {
9469                            myResourceFolderlist.find('.dd-fln').find('.fln-group').css('max-width','182px');
9470                            myResourceFolderlist.find('.dd-fln').find('.fln-input').css('max-width','155px');
9471                            myResourceFolderlist.scrollTop(2000);
9472                        }
9473                        $.resource.setMystorageFolder('nodrag',true);
9474                    }
9475                })
9476                .on('click', '#mystorageUploadBtn', function(e) {
9477                    var myResourceTab = $('#mystorage'),
9478                        fsort = myResourceTab.find('.resource-ctrl-sort select').val(),
9479                        fsearch = myResourceTab.find('.resource-search-stx').val(),
9480                        ffolder = (SFOLDER_ACTIVE) ? SFOLDER_ACTIVE : 'all';
9481
9482                    $.uploadON();
9483                    $(this).fileupload({
9484                        url: '/template/resource/upload/ffolder/'+ffolder,
9485                        dataType: 'json',
9486                        pasteZone: null,
9487                        dropZone: null,
9488                        async: true,
9489                        prependFiles: true,
9490                        sequentialUploads: true,
9491                        add: function(e,data) {
9492                            var r = $.upload_add(e,data,'image');
9493                            if(r.submit) {
9494                                var jqXHR = data.submit();
9495                                UPLOAD++;
9496                            } else {
9497                                data.context.find('.loading').html('<i class="fa fa-times error"></i>');
9498                                data.context.find('.ing').addClass('error').text(r.err);
9499                            }
9500
9501                            $('.uploadModal .upload-cancel .btn, .uploadModal .upload-close').off('click').on('click', function(e) {
9502                                if(jqXHR != undefined) jqXHR.abort();
9503                                data.context.fadeOut().remove();
9504                                $('.uploadModal #file-upload-progress').css('width','0%');
9505                                $.uploadOFF();
9506                                UPLOAD = 0;
9507                                UPLOADED = 0;
9508                                PROGRESS = 0;
9509
9510                                updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9511                                resourceGetPage(1,SFOLDER_ACTIVE,fsort,fsearch);
9512                            });
9513                        },
9514                        progress: function(e, data) {
9515                            $.upload_progress(e,data);
9516                        },                        
9517                        done: function (e, data) {
9518                            $.upload_done(e,data);
9519                            UPLOADED++;
9520
9521                            var isSuccess = (typeof data._response.result != 'undefined' && typeof data._response.result.error != 'undefined') ? false : true;
9522                            if(isSuccess) {
9523                                var add_fls = parseFloat(data.files[0].size / 1024).toFixed(2);
9524
9525                                $.resource.setMystorageFolder('set_fli_state', {'count': 1, 'size': add_fls, ffolder: 'all', state: 'upload'});
9526                                if(SFOLDER_ACTIVE != '') $.resource.setMystorageFolder('set_fli_state', {'count': 1, 'size': add_fls, ffolder: SFOLDER_ACTIVE, state: 'upload'});    
9527                            }
9528
9529                            if(UPLOADED && data.context.find('.error').length == 0) {
9530                                //$.uploadON(UPLOADED + " / " + UPLOAD + "<br>images creating...");
9531                                if(UPLOAD==UPLOADED) {
9532                                    setTimeout(function() {
9533                                        $.uploadOFF();
9534                                        UPLOAD = 0;
9535                                        UPLOADED = 0;
9536                                        PROGRESS = 0;
9537
9538                                        updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9539                                        resourceGetPage(1,SFOLDER_ACTIVE,'date_desc','');
9540                                    },1000);
9541                                }
9542                            }
9543                        },
9544                        progressall: function (e, data) {
9545                            $.upload_progressall(e,data);
9546                        },
9547                        start : function(e, data) {
9548                            $.upload_start(e,data);
9549                            progress1 = 0; progress2 = 0; PROGRESS = 0;
9550                        },
9551                        dragover : function(e, data) {
9552                            e.preventDefault();
9553                        }
9554                    }
9554).prop('disabled', !$.support.fileInput)
9555                        .parent().addClass($.support.fileInput ? undefined : 'disabled');
9556                })
9557                .on('mousedown', '.fitem', function(e) {
9558                    mouseX = (typeof e.clientX != 'undefined') ? e.clientX : e.pageX;
9559                    mouseY = (typeof e.clientY != 'undefined') ? e.clientY : e.pageY;
9560
9561                    if($(this).hasClass('ui-selected')) {
9562                        fileDrag = true;
9563                        updateResourceTooltip($(this), true);
9564                    } else {
9565                        fileDrag = false;
9566                        dragTooltipModal = $();
9567                        hideResourceTooltip();
9568                    }
9569                })
9570                .on('mouseup', '.fitem', function(e) {
9571                    if($(this).closest('.tab-pane.active').find('#nestableFolder').length > 0) $(this).closest('.tab-pane.active').find('#nestableFolder .fli').removeClass('drag-selected');
9572                    hideResourceTooltip();
9573                    fileDrag = false;
9574                    dragTooltipModal = $();
9575                })
9576                .on('mousemove', '.fitem', function(e) {
9577                    mouseX = (typeof e.clientX != 'undefined') ? e.clientX : e.pageX;
9578                    mouseY = (typeof e.clientY != 'undefined') ? e.clientY : e.pageY;
9579                    if(fileDrag) updateResourceTooltip($(this), false);
9580                })
9581                .on('click', '.fitem-ctrl-del', function(e) {
9582                    var delResourceTab = $(this).closest('.tab-pane.active'),
9583                        delResourceFiles = delResourceTab.find('ul.files'),
9584                        delResourceSelected = delResourceTab.find('.resource-selected-ul'),
9585                        fsort = delResourceTab.find('.resource-ctrl-sort select').val(),
9586                        fsearch = delResourceTab.find('.resource-search-stx').val(),
9587                        file    = $(this).closest('ul').attr('data-source'),
9588                        seq     = $(this).closest('ul').attr('data-seq'),
9589                        size    = $(this).closest('ul').attr('data-fsize'),
9590                        ffolder = $(this).closest('ul').attr('data-ffolder');
9591
9592                    var modal = $(this).showModalFlat($.lang[LANG]['config.common.resource.delete.title'],$.lang[LANG]['config.common.resource.delete'], true, true, function() {
9593                        $.processON('Deleting the image(s)...');
9594                        modal.modal('hide');
9595                        delResourceFiles.find('.fitem p.fitem-name[data-seq="' + seq + '"]').remove();
9596                        delResourceSelected.children('li[data-seq="' + seq + '"]').remove();
9597                        if(delResourceSelected.length == 0) delResourceTab.find('.resource-useit').removeClass('active');
9598
9599                        mystorageFileDelete(file,seq,function() {
9600                            $.resource.setMystorageFolder('set_fli_state', {'count': -1, 'size': -size, ffolder: 'all', state: 'delete'});
9601                            if(ffolder != '' && ffolder != 'all') {
9602                                $.resource.setMystorageFolder('set_fli_state', {'count': -1, 'size': -size, ffolder: ffolder, state: 'delete'});
9603                            }
9604                            updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9605
9606                            resourceGetPage(1,SFOLDER_ACTIVE,fsort,fsearch);
9607                            $.processOFF();
9608                        });
9609
9610                    },'cancel','ok','modal-over-1 cl-cmmodal cl-s-btn cl-common-notice w560',false);
9611                })
9612                .on('click', '.resource-ctrl-deletes', function(e) {
9613                    var myResourceTab = $('#mystorage'),
9614                        myResourceFiles = myResourceTab.find('ul.files'),
9615                        myResourceSelected = myResourceTab.find('.resource-selected-ul'),
9616                        fsort = myResourceTab.find('.resource-ctrl-sort select').val(),
9617                        fsearch = myResourceTab.find('.resource-search-stx').val();
9618    
9619                    if(myResourceSelected.children('li').length==0) return;
9620    
9621                    var r_pages = Number(myResourceTab.find('.resource-paging .pagination').attr('data-pages')),
9622                        r_page = Number($('.resource-paging .pagination li.active').text()),
9623                        r_file_cnt = myResourceFiles.find('.fitem').length;
9624                        
9625                    var modal = $(this).showModalFlat($.lang[LANG]['config.common.resource.delete.title'],$.lang[LANG]['config.common.resource.delete'], true, true, function() {
9626                        modal.modal('hide');
9627                        $.progressON();              
9628                        var files = [], seqs = [], sizes = [], ffolders = [];
9629                        myResourceSelected.children('li').each(function () {
9630                            files.push($(this).attr('data-source'));
9631                            seqs.push($(this).attr('data-seq'));
9632                            sizes.push($(this).find('.selected-file-size .size').text());
9633                            ffolders.push($(this).attr('data-ffolder'));
9634                        });
9635    
9636                        myResourceSelected.empty();
9637                        myResourceTab.find('.resource-useit').removeClass('active');
9638    
9639                        var total = files.length, deleting = '', progress = 0; loading = '<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i> ';
9640                            done = 0; deleting = myResourceFiles.find('p.fitem-name[data-seq="' + seqs[0] + '"]').text();
9641                        $('.progressModal .info1').html(loading + deleting);
9642    
9643                        $.each(files,function(i,v) {
9644                            var t = setTimeout(function() {
9645                                if(CANCEL) {
9646                                    if(ABORT) {
9647                                        updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9648                                        resourceGetPage(1,SFOLDER_ACTIVE,fsort,fsearch);
9649                                        ABORT = false;
9650                                        $.progressOFF();
9651                                    }
9652                                    i=0; return false;
9653                                }
9654    
9655                                mystorageFileDelete(v,seqs[i],function() {
9656                                    done++;
9657                                    progress = parseInt((done / total) * 100,10);
9658                                    $('.file-upload-progress .progress-bar').css('width',progress + "%");
9659                                    $('.progressModal .info2').text(done.toString() + ' / ' + total.toString());
9660
9661                                    $.resource.setMystorageFolder('set_fli_state', {'count': -1, 'size': -sizes[i], ffolder: 'all', state: 'delete'});
9662                                    if(ffolders[i] != '' && ffolders[i] != 'all') {
9663                                        $.resource.setMystorageFolder('set_fli_state', {'count': -1, 'size': -sizes[i], ffolder: ffolders[i], state: 'delete'});
9664                                    }
9665
9666                                    if(total == done) {
9667                                        r_page = ((r_file_cnt-files.length) == 0 && r_pages<=r_page) ? r_page-1 : r_page;
9668                                        r_page = 1;
9669                                        setTimeout(function() {
9670                                            updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9671                                            resourceGetPage(r_page,SFOLDER_ACTIVE,fsort,fsearch);
9672                                            $.progressOFF();
9673                                        },1000);
9674                                    } else {
9675                                        deleting = myResourceFiles.find('p.fitem-name[data-seq="' + seqs[i+1] + '"]').text();
9676                                        $('.progressModal .info1').html(loading + deleting);
9677                                    }
9678                                });
9679                            },500*i);
9680                        });
9681    
9682                    },'cancel','ok','modal-over-1 cl-cmmodal cl-s-btn cl-common-notice w560',false);
9683                })
9684                .on('click', '.resource-ctrl-downloads', function(e) {
9685                    var myResourceTab = $('#mystorage'),
9686                        myResourceFiles = myResourceTab.find('ul.files'),
9687                        myResourceSelected = myResourceTab.find('.resource-selected-ul');
9688
9689                    var files = [], seqs = [], sizes = [], ffolders = [], file_path = [], org_name = [];
9690
9691                    if(myResourceSelected.children('li').length == 0) {
9692                        return false;
9693                    } else if(myResourceSelected.children('li').length == 1) {
9694                        var seq = $(myResourceSelected.children('li')[0]).data('seq');
9695                        $('ul[data-seq="' + seq + '"] .fitem-ctrl-down').get(0).click();
9696                        return false;
9697                    }
9698
9699                    myResourceSelected.children('li').each(function () {
9700                        var src = getServeImage($(this).attr('data-source'), 0, 'https:' + RESOURCE + '/' + SID);
9701                        var file_name = $(this).find('.selected-file-title').text();
9702                        file_path.push(src);
9703                        org_name.push(file_name);
9704                    });
9705                    $.processON($.lang[LANG]['editor.resource.batchdownload']);
9706                    setTimeout(function() {
9707                        $.ajax({
9708                            url:'/template/resource/batch-download',
9709                            type:'post',
9710                            async: true,
9711                            data:{
9712                                'file_path': file_path,
9713                                'org_name': org_name
9714                            },
9715                            dataType:'json',
9716                            success:function(data) {
9717                                var filename = data.filename;
9718                                var base64Data = data.filedata;
9719                                if(!base64Data) return false;
9720
9721                                var binaryString = atob(base64Data);
9722                                var len = binaryString.length;
9723                                var bytes = new Uint8Array(len);
9724                                for (let i = 0; i < len; i++) {
9725                                    bytes[i] = binaryString.charCodeAt(i);
9726                                }
9727
9728                                // Blob 객체 생성
9729                                var blob = new Blob([bytes], { type: 'application/zip' });
9730
9731                                // Blob URL 생성
9732                                var url = URL.createObjectURL(blob);
9733
9734                                // 다운로드 링크 생성 및 클릭하여 파일 다운로드
9735                                var a = document.createElement('a');
9736                                a.href = url;
9737                                a.download = filename;
9738                                document.body.appendChild(a);
9739                                a.click();
9740
9741                                // 링크 제거
9742                                document.body.removeChild(a);
9743                                URL.revokeObjectURL(url);
9744                            }, 
9745                            complete:function() {
9746                                $.processOFF();
9747                            }
9748                        });
9749                    });
9750                });
9751
9752
9753            $('#mystorage #nestableFolder').nestable({
9754                    maxDepth: 1,
9755                    handleClass: 'dd-handle',
9756                    noDragClass: 'fl-nodrag',
9757                })
9758                .on('changing', function(e) {
9759                    if(isFEdit || $(this).find('.fln-group.input-group').length > 0) {
9760                        e.preventDefault();
9761                        return false;
9762                    }
9763
9764                    sortFolderFavoritesTop();
9765                    updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9766                });
9767
9768            $('#mystorage ul.files').selectableScroll({
9769                options:{
9770                    scrollSnapX: 120,
9771                    scrollSnapY: 120,
9772                    scrollAmount: 5
9773                },
9774                filter: '.fitem',
9775                cancel: 'i, .ui-selected, .fitem-ctrl',
9776                start: function(event, ui) {
9777                    $('#mystorage ul.files').addClass('__file_selecting');
9778                },
9779                selecting: function(event, ui) {
9780                },
9781                stop: function(event, ui) {
9782                    $('#mystorage ul.files').removeClass('__file_selecting');
9783                },
9784                selected: function(event, ui) {
9785                    if($(ui.selected).is('.fitem')) {
9786                        var myResourceTab = $('#mystorage'),
9787                            myResourceSelected = myResourceTab.find('.resource-selected-ul'),
9788                            file_seq = $(ui.selected).find('.fitem-ctrl > ul').attr('data-seq');
9789                        
9790                        if(typeof file_seq != 'undefined' && myResourceSelected.find('li[data-seq="'+file_seq+'"]').length == 0) {
9791                            var magic = $(ui.selected).find('p.fitem-name').attr('data-magic'),
9792                                file = $(ui.selected).find('p.fitem-name').attr('data-source'),
9793                                file_path = RPATH + '60/' + file,
9794                                full_path = (magic == '') ? file_path : magic+'=s60-c',
9795                                ffolder = $(ui.selected).find('.fitem-ctrl > ul').attr('data-ffolder'),
9796                                file_title = $(ui.selected).find('p.fitem-name').attr('data-original-title'),
9797                                file_size = $(ui.selected).find('p.fitem-size .size').attr('data-size'),
9798                                file_width = $(ui.selected).find('p.fitem-size .width').text(),
9799                                file_height = $(ui.selected).find('p.fitem-size .height').text(),
9800                                selected_file_name = (magic) ? magic : file;
9801                            
9802                            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>');
9803                        }
9804                    }
9805                    setResourceSelectedBox('my');
9806                },
9807                unselected: function(event, ui) {
9808                    if($(ui.unselected).is('.fitem')) {
9809                        if(!event.ctrlKey && !event.shiftKey) {
9810                            $('#mystorage .resource-selected-ul').empty();
9811                        }
9812                    }
9813                    setResourceSelectedBox('my');
9814                }
9815            });
9816
9817
9818            /* modal-resourcebox 02__freestorage */
9819            var freestorageFitemHtml = function(src,profile,name,link,color,full,raw,down,width,height,id,type,i) {
9820                
9821                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>' : '',
9822                    fitem_str = '\
9823                    <li class="fitem" data-idx="' + i + '">\
9824                        <div class="fitem-wrap">\
9825                            <div class="fitem-visual">\
9826                                <div class="fitem-thumb">\
9827                                    <div class="fitem-mold"><img src="https://storage.googleapis.com/i.addblock.net/sample/sns_cm_1.png"/></div>\
9828                                    <img class="fitem-img" src="' + src + '">\
9829                                </div>\
9830                                <div class="fitem-ctrl">\
9831                                    <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 + '">\
9832                                        <li><a class="fitem-ctrl-imgview" data-url="' + full + '" data-img-original="ON"><svg viewBox="0 0 13 13" width="13" height="13">
9832<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>\
9833                                        ' + fitem_ctrl_star + '\
9834                                    </ul>\
9835                                </div>\
9836                            </div>\
9837                            <div class="fitem-content visible-layout-grid">\
9838                                <p class="fitem-username">Photo by <a href="' + link + '?utm_source=creatorlink&utm_medium=referral&utm_campaign=api-credit" target="_blank">' + name + '</a></p>\
9839                                <p class="fitem-size"><span class="width">'+width+'</span><span class="height">'+height+'</span></p>\
9840                            </div>\
9841                        </div>\
9842                    </li>\
9843                ';
9844
9845                return fitem_str;
9846            }
9847
9848            var rePaintFavor = function() {
9849                var $org = $('#freestorage .fitem'),
9850                    $items = {};
9851
9852                for(var i=0; i<$org.length; i++) {
9853                    var $i = $('#freestorage .fitem[data-idx="' + i + '"]');
9854                    $items[i] = $i.clone();
9855                    $i.remove();
9856                }
9857
9858                $.each($items, function(i,v) {
9859                    $('#freestorage ul.files').append($(this));
9860                });
9861            }
9862
9863            var getFreeImage = function(page,type,stx,collection) {
9864                type = (typeof type == 'undefined') ? 'new' : type;
9865                stx = (typeof stx == 'undefined') ? '' : stx;
9866                page = (typeof page == 'undefined') ? 1 : page;
9867                collection = (typeof collection == 'undefined') ? '' : collection;
9868                if(type == 'new') {
9869                    dest = '/template/free/new/photos';
9870                } else if(type == 'favor') {
9871                    dest = '/template/favorite/list/type/F';
9872                } else if(type == 'search') {
9873                    dest = '/template/free/search/' + encodeURIComponent(stx);
9874                } else if(type == 'used') {
9875                    dest = '/template/favorite/list/type/U';
9876                }
9877
9878                if(page>1) dest = dest + '/page/' + page;
9879
9880                var freeResourceTab = $('#freestorage'),
9881                    freeResourceFiles = freeResourceTab.find('ul.files'),
9882                    freeResourceSelected = freeResourceTab.find('.resource-selected-ul');
9883
9884                $.ajax({
9885                    type: 'GET',
9886                    url: dest,
9887                    dataType: 'json',
9888                    async:true,
9889                    success : function(data) {
9890                        var photos;
9891                        if(freeSearch.type == 'new') {
9892                            if(data.photos != null) {
9893                                photos = data.photos;    
9894                            } else photos = [];
9895                        } else {
9896                            photos = (data.photos && data.photos.results) ? data.photos.results : [];
9897                        }
9898
9899                        if(photos) {
9900                            if(photos.length==0 || photos == null) {
9901                                $.resource.modalFilesEmpty(freeResourceFiles, 'No results found');
9902                            } else {
9903                                freeResourceFiles.find('.listprogress').remove();
9904                                $.each(photos, function(i,v) {
9905                                    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);
9906                                    freeResourceFiles.append(tpl);
9907                                });
9908
9909                                freeResourceFiles.selectable({ 
9910                                    filter: '.fitem',
9911                                    cancel: 'i, .ui-selected, .fitem-username, .fitem-ctrl',
9912                                    start: function(event, ui) {
9913                                        freeResourceFiles.addClass('__file_selecting');
9914                                    },
9915                                    selecting: function(event, ui) {
9916                                    },
9917                                    stop: function(event, ui) {
9918                                        freeResourceFiles.removeClass('__file_selecting');
9919                                    },
9920                                    selected: function(event, ui) {
9921                                        if($(ui.selected).is('.fitem')) {
9922                                            var freeResourceTab = $('#freestorage'),
9923                                                freeResourceSelected = freeResourceTab.find('.resource-selected-ul'),
9924                                                file_id = $(ui.selected).find('.fitem-ctrl > ul').attr('data-id');
9925
9926                                            if(typeof file_id != 'undefined' && freeResourceSelected.children('li[data-id="'+file_id+'"]').length == 0) {
9927                                                var file_small = $(ui.selected).find('.fitem-ctrl > ul').attr('data-small'),
9928                                                    urls = new getLocation(file_small),
9929                                                    file = (urls.pathname).replace('/',''),
9930                                                    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',
9931                                                    tmp_image = 'https://' + urls.host + urls.pathname + '?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb',
9932                                                    file_width = $(ui.selected).find('.fitem-ctrl > ul').attr('data-width'),
9933                                                    file_height = $(ui.selected).find('.fitem-ctrl > ul').attr('data-height');
9934
9935                                                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>');
9936                                            }
9937                                        }
9938                                        setResourceSelectedBox('free');
9939                                    },
9940                                    unselected: function(event, ui) {
9941                                        if($(ui.unselected).is('.fitem')) {
9942                                            if(!event.ctrlKey && !event.shiftKey) {
9943                                                freeResourceSelected.empty();
9944                                            }
9945                                        }
9946                                        setResourceSelectedBox('free');
9947                                    }
9948                                });
9949                                if((freeSearch.type == 'search' || freeSearch.type == 'favor' || freeSearch.type == 'used') && data.photos && typeof data.photos.total 
9949!= 'undefined') freeSearch.total = data.photos.total;
9950                                freeSearch.page = freeSearch.page + 1;
9951
9952                                freeResourceTab.find('.resource-search-total').text('');
9953                                if(data.photos && typeof data.photos.total != 'undefined' && freeSearch.type == 'search') {
9954                                    if(data.photos.total > 0) freeResourceTab.find('.resource-search-total').text(Number(data.photos.total).format());
9955                                }
9956
9957                            }                
9958                        } else {
9959                            $.resource.modalFilesEmpty(freeResourceFiles, 'Error get photo list');
9960                        }
9961                    },
9962                    error: function() {
9963                        $.resource.modalFilesEmpty(freeResourceFiles, 'Error get photo list');
9964                    },
9965                    complete: function() {
9966                        freeResourceTab.find('.resource-search-btn').removeClass('clicked');
9967                        freeResourceFiles.removeClass('ready');
9968                        freeResourceFiles.find('.listprogress').remove();
9969                    }
9970                });
9971
9972            }
9973                
9974            $('.modal-resourcebox')
9975                .on('click', 'a[href="#freestorage"]', function(e) {
9976                    $('#freestorage ul.files .listprogress').remove();
9977                    setResourceSelectedBox('free');
9978
9979                    var freeResourceTab = $('#freestorage'),
9980                        freeResourceFolderlist = freeResourceTab.find('.resource-folderlist'),
9981                        freeResourceFiles = freeResourceTab.find('ul.files'),
9982                        freeResourceSelected = freeResourceTab.find('.resource-selected-ul');
9983
9984                    if(freeResourceFiles.hasClass('ready')) {
9985                        if(freeResourceFolderlist.children('li.active').length == 0) {
9986                            freeResourceFolderlist.children('li').click(function(e) {
9987                                var flTab = $(this),
9988                                    fl_type = (typeof flTab.attr('data-type') != 'undefined') ? flTab.attr('data-type') : '',
9989                                    fb_type = (typeof freeResourceFiles.attr('data-type') != 'undefined') ? freeResourceFiles.attr('data-type') : '',
9990                                    checkReload = (fl_type == '' || fl_type != fb_type) ? true : false;
9991
9992                                flTab.addClass('active').siblings().removeClass('active');
9993                                if(checkReload) {
9994                                    freeSearch.type = fl_type;
9995                                    freeSearch.page = 1;
9996                                    freeSearch.total = -1;
9997                                    $.resource.modalContentInit('free');
9998                                    getFreeImage(freeSearch.page,freeSearch.type);
9999                                    freeResourceFiles.attr('data-type',fl_type);
10000                                }
10001
10002                                if(fl_type == 'favor') {
10003                                    var items = freeResourceFiles.find('.fitem').length;
10004                                    if(freeSearch.total == items) return;
10005                                }
10006
10007                                freeResourceSelected.empty();
10008                                setResourceSelectedBox('free');
10009                            });
10010
10011                            freeSearch.type = 'new';
10012                            freeSearch.page = 1;
10013                            freeSearch.total = -1;
10014                            $.resource.modalContentInit('free');
10015                            freeResourceFolderlist.children('li[data-type="new"]').addClass('active').siblings().removeClass('active');
10016                            getFreeImage(freeSearch.page,freeSearch.type);
10017                        }
10018                    }
10019                });
10020
10021            $('.modal-resourcebox #freestorage')
10022                .on('click', '.fitem-ctrl-star', function(e) {
10023                    var $i = $(this).closest('ul'),
10024                        $star = $(this),
10025                        image = {
10026                            'id' : $i.attr('data-id'),
10027                            'width' : $i.attr('data-width'),
10028                            'height' : $i.attr('data-height'),
10029                            'username' : $i.attr('data-username'),
10030                            'userlink' : $i.attr('data-userlink'),
10031                            'raw' : $i.attr('data-raw'),
10032                            'full' : $i.attr('data-full'),
10033                            'small' : $i.attr('data-small'),
10034                            'down' : $i.attr('data-down'),
10035                            'color' : $i.attr('data-color'),
10036                            'onoff': ($star.hasClass('active')) ? 'OFF' : 'ON',
10037                        },
10038                        $item = $star.closest('.fitem');
10039    
10040                    $.post('/template/favorite/image', { image : image },  function(data) {
10041                        if(data.type == 'insert') {
10042                            $star.addClass('active');
10043                        } else if(data.type == 'delete') {
10044                            $star.removeClass('active');
10045                            if(freeSearch.type == 'favor') {
10046                                var idx = $item.attr('data-idx');
10047                                $('#freestorage .fitem').each(function() {
10048                                    var cidx = $(this).attr('data-idx');
10049                                    if(cidx == idx) $(this).remove();
10050                                    if(idx < cidx) $(this).attr('data-idx',Number(cidx)-1);
10051                                });
10052                                freeSearch.total = freeSearch.total -1;
10053                                rePaintFavor();
10054                            }
10055                        }
10056                    },'json');
10057                });
10058
10059
10060            /* modal-resourcebox 03__filestorage */
10061            $('.modal-resourcebox #filestorage')
10062                .on('click', '#filestorageUploadBtn', function(e) {
10063                    if($('.flink-error-modal').length > 0) {
10064                        e.preventDefault();
10065                        return false;
10066                    }
10067                    var checkPlan = (typeof property == 'undefined') ? ((typeof VALIDPLAN == 'undefined') ? $.gallery.valid_plan : VALIDPLAN) : property.VALIDPLAN,
10068                        checkPType = (typeof property == 'undefined') ? ((typeof VALIDTYPE == 'undefined') ? $.gallery.valid_type : VALIDTYPE) : property.VALIDTYPE,
10069                        flink_cnt = $('#filestorage .flink-capacity .flink-cnt').text(),
10070                        flink_max = $('#filestorage .flink-capacity .flink-max').text(),
10071                        reg_max = /^[0-9]+$/,
10072                        error_str = '';
10073
10074                    if(!checkPlan || checkPType == 'PK') error_str = $.lang[LANG]['editor.link.file.upgrade'];
10075                    else if(reg_max.test(flink_cnt) && Number(flink_cnt) >= Number(flink_max)) {
10076                        error_str = $.lang[LANG]['editor.link.file.maximum'];
10077                        error_str = error_str.replace('@maximum', flink_max);
10078                    }
10079                    if(error_str) {
10080                        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');
10081                        errorModal.closest('.flat-modal').addClass('z-1044');
10082                        return false;
10083                    }
10084
10085                    $.uploadON();
10086                    $(this).fileupload({
10087                        url: '/down/flink/upload/sid/' + SID,
10088                        dataType: 'json',
10089                        pasteZone: null,
10090                        async: true,
10091                        cache: false,
10092                        prependFiles: true,
10093                        sequentialUploads: true,
10094                        add: function(e,data) {
10095                            var r = $.upload_add(e,data,'flink');
10096
10097                            if(r.submit) {
10098                                var jqXHR = data.submit();
10099                                UPLOAD++;
10100                            } else {
10101                                data.context.find('.loading').html('<i class="fa fa-times error"></i>');
10102                                data.context.find('.ing').addClass('error').text(r.err);
10103                            }
10104
10105                            $('.uploadModal .upload-cancel .btn, .uploadModal .upload-close').off('click').on('click', function(e) {
10106                                if(jqXHR != undefined) jqXHR.abort();
10107                                data.context.fadeOut().remove();
10108                                $('.uploadModal #file-upload-progress').css('width','0%');
10109                                $.uploadOFF();
10110                                UPLOAD = 0;
10111                                UPLOADED = 0;
10112                                PROGRESS = 0;
10113
10114                                resourceGetPage(1,SFOLDER_ACTIVE,'date_desc','');
10115                            });
10116                        },
10117                        progress: function(e, data) {
10118                            $.upload_progress(e,data);
10119                        },                        
10120                        done: function (e, data) {
10121                            if(typeof data.result.error != 'undefined' && data.result.error) {
10122                                $('.uploadModal .upload-header h1').html($.lang[LANG]['editor.upload.title.1']);
10123                                $('.uploadModal .upload-content .upload-cancel .btn-default').text($.lang[LANG]['config.close']);
10124                                $('.file-upload-progress .progress-bar').css('width','0%');
10125                                $('.uploadModal .info1, .uploadModal .info2').addClass('hide');
10126
10127                                data.context.find('.progress-bar').css('width','0%');
10128                                data.context.find('.loading').html('<i class="fa fa-times error"></i>');
10129                                data.context.find('.ing').addClass('error').text(data.result.error);
10130                                return false;
10131                            }
10132                            
10133                            $.upload_done(e,data);
10134                            UPLOADED++;
10135                            
10136                            if(UPLOADED) {
10137                                if(UPLOAD==UPLOADED) {
10138                                    setTimeout(function() {
10139                                        $.uploadOFF();
10140                                        UPLOAD = 0;
10141                                        UPLOADED = 0;
10142                                        PROGRESS = 0;
10143    
10144                                        resourceGetPage(1,SFOLDER_ACTIVE,'date_desc','');
10145                                    },1000);
10146                                }
10147                            }
10148                        },
10149                        progressall: function (e, data) {
10150                            $.upload_progressall(e,data);
10151                        },
10152                        start : function(e, data) {
10153                            $.upload_start(e,data);
10154                            progress1 = 0; progress2 = 0; PROGRESS = 0;
10155                        },
10156                        dragover : function(e) {
10157                            e.preventDefault();
10158                            e.stopPropagation();
10159                        },
10160                        drop : function(e) {
10161                            e.preventDefault();
10162                            e.stopPropagation();
10163                        },
10164                    }
10164).prop('disabled', !$.support.fileInput)
10165                        .parent().addClass($.support.fileInput ? undefined : 'disabled');
10166
10167                })
10168                .on('click', '.fitem', function(e) {
10169                    $(this).toggleClass('selected').siblings().removeClass('selected');
10170                    if($(this).hasClass('selected')) $('#filestorage .resource-useit').addClass('active');
10171                    else $('#filestorage .resource-useit').removeClass('active');
10172                })
10173                .on('click', '.fitem-ctrl-del', function(e) {
10174                    $(this).closest('.fitem').addClass('selected');
10175                    var selectedFlink = $('#filestorage ul.files .fitem.selected'),
10176                        file = selectedFlink.find('p.fitem-name').attr('data-source'),
10177                        id = selectedFlink.find('p.fitem-name').attr('data-seq');
10178                    if(typeof file == 'undefined' || typeof id == 'undefined') return false;
10179                    var modal = $(this).showModalFlat($.lang[LANG]['config.flink.resource.delete'],$.lang[LANG]['config.flink.resource.delete.str'], true, true, function() {
10180
10181                        selectedFlink.remove();
10182                        $.processON('Deleting the file(s)...');
10183                        modal.modal('hide');
10184                        $('.resource-useit').removeClass('active');
10185
10186                        $.ajax({
10187                            type: 'POST',
10188                            url: '/down/flink/delete',
10189                            data: { s: file, id: id },
10190                            dataType: 'json',
10191                            async: true,
10192                            success: function(data) {
10193                                if(typeof data.error != 'undefined' && data.error) {
10194                                    $(this).showModalFlat('ERROR',data.error,true,false,'','ok');
10195                                    return false;
10196                                }
10197                                resourceGetPage(1,SFOLDER_ACTIVE,'date_desc','');
10198                                $.processOFF();
10199                            }
10200                        });
10201
10202                    },'cancel','ok','modal-over-1 cl-cmmodal cl-s-btn cl-common-notice w560',false);
10203                    modal.closest('.modal-over-1').addClass('z-1044');
10204                });
10205
10206            $('.modal-resourcebox a[href="#iconstorage"]')
10207                .click(function(e) { 
10208                    var thisResourceTab = $('#iconstorage'),
10209                        icon_type = (typeof getIconStorageInitialType == 'function') ? getIconStorageInitialType() : 'google';
10210
10211                    if(typeof resetIconStorageDefaultState == 'function') {
10212                        resetIconStorageDefaultState();
10213                    } else {
10214                        thisResourceTab.find('.icon_type[data-icontype="' + icon_type + '"]').addClass('active').siblings('.icon_type').removeClass('active');
10215                        thisResourceTab.find('.resource-search-stx').val('');
10216                    }
10217                    $.processON();
10218                    if(typeof setIconStorageMaterialState == 'function') setIconStorageMaterialState(icon_type);
10219                    getIconImage('total', icon_type);
10220            });
10221        },
10222        modalOpenSET: function(open) {
10223            $('.modal-resourcebox .nav-tabs li').removeClass('disabled');
10224            var property = (open) ? $('.modal-resourcebox .resource-useit').eq(0).attr('data-property') : '';
10225            if(!open) $('.modal-resourcebox .resource-useit').removeAttr('data-property');
10226
10227            if(open) {
10228                switch(property) {
10229                    case 'flink-change':
10230                        $('#mystorage,#freestorage').removeClass('active').removeClass('in');
10231                        $('.modal#el-fileupload').css('z-index','1043');
10232                        $('#el-fileupload').addClass('flink-fileupload');
10233                        $('#el-fileupload').find('.modal-header h4').html($.lang[LANG]['editor.resource.file']);
10234                        $('#el-fileupload .nav-tabs li:nth-child(3) a').click();
10235                        $('#el-fileupload .nav-tabs li:not(:nth-child(3))').addClass('disabled');
10236                        break;
10237
10238                    case 'popup-change':
10239                        $('.modal#el-fileupload').css('z-index','1043');
10240                        $('#el-fileupload').addClass('popup-fileupload');
10241                        break;
10242
10243                    case 'upload-badge-image':
10244                        $('.modal#el-fileupload').css('z-index','1044');
10245                        break;
10246            
10247                    default:
10248                        $('#filestorage').removeClass('active').removeClass('in');
10249                        $('.modal#el-fileupload').css('z-index','1041');
10250                        $('#el-fileupload').removeClass('flink-fileupload');
10251                        $('#el-fileupload').removeClass('popup-fileupload');
10252                        $('#el-fileupload').find('.modal-header h4').html($.lang[LANG]['editor.resource.title']);
10253            
10254                        if($('#el-fileupload .nav-tabs li:nth-child(3)').hasClass('active')) $('#el-fileupload .nav-tabs li:nth-child(1) a').click();
10255                        $('#el-fileupload .nav-tabs li:nth-child(3)').addClass('disabled');
10256                        break;
10257                }
10258            } else {
10259                $('.modal#el-fileupload').css('z-index','1041');
10260                $('#el-fileupload').removeClass('flink-fileupload');
10261                $('#el-fileupload').removeClass('popup-fileupload');
10262                $('#el-fileupload').find('.modal-header h4').html($.lang[LANG]['editor.resource.title']);
10263        
10264                if($('#el-fileupload .nav-tabs li:nth-child(3)').hasClass('active')) $('#el-fileupload .nav-tabs li:nth-child(1) a').click();
10265                $('#el-fileupload .nav-tabs li:nth-child(3)').addClass('disabled');
10266                $('#filestorage').removeClass('active').removeClass('in');
10267            }
10268        },
10269        modalInit: function() {
10270            $('#progress .progress-bar').css({'width' : '0%', 'padding-right' : '0px'}).text('');
10271            $('.modal-resourcebox .resource-useit').removeClass('active');
10272            $('.modal-resourcebox .resource-selected-ul').empty();
10273            $('.modal-resourcebox .resource-ctrl-selectedinfo .count').text(0).closest('label').hide();
10274            $('.modal-resourcebox .resource-ctrl-btns').removeClass('active');
10275            $('.modal-resourcebox .fitem').removeClass('ui-selected');
10276            $.resource.modalOpenSET(true);
10277        },
10278        modalContentInit: function(mode) {
10279            if(typeof mode == 'undefined' || !mode) mode = 'my';
10280
10281            $('#'+mode+'storage .resource-useit').removeClass('active');
10282            $('#'+mode+'storage .resource-search-stx').val('');
10283            $('#'+mode+'storage ul.files, #'+mode+'storage .resource-selected-ul').empty();
10284
10285            if(mode == 'free') {
10286                $('#freestorage .resource-search-total').text('');
10287                if($('#freestorage ul.files .listprogress').length == 0) {
10288                    $('#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>');
10289                }
10290            }
10291        },
10292        modalFilesEmpty: function(ulFiles,empty_str) {
10293            if(ulFiles.length > 0) {
10294                empty_str = (typeof empty_str != 'undefined' && empty_str) ? empty_str : 'No results';
10295                ulFiles.addClass('empty').empty();
10296                ulFiles.append('\
10297                    <li class="resource-empty-area">\
10298                        <div class="resource-empty">\
10299                            <div class="img-wrap"><img src="//storage.googleapis.com/i.addblock.net/config/fa_resource_img_icon.png" alt="image storage" /></div>\
10300                            <p>' + empty_str + '</p>\
10301                        </div>\
10302                    </li>\
10303                ');
10304
10305                if(ulFiles.closest('.resource-container').find('.resource-search-btn').length > 0) ulFiles.closest('.resource-container').find('.resource-search-btn').removeClass('clicked');
10306                ulFiles.closest('.tab-pane.active').find('ul.files').removeClass('ready');
10307                ulFiles.closest('.tab-pane.active').find('.listprogress').remove();
10308            }
10309        },
10310        getMystorageFlc: function() {
10311            var check_ffolder = (SFOLDER_ACTIVE != '') ? SFOLDER_ACTIVE : 'all',
10312                ftotal = -1;
10313            
10314            $.each(SFOLDER, function(i, o) {
10315                if(o.name == check_ffolder) {
10316                    ftotal = o.fcount;
10317                    return false;
10318                }
10319            })
10320
10321            return ftotal;
10322        },
10323        getMystorageFolderHtml: function(flname, flcount, flsize, fid, flfavorite) {
10324            if(!flname) return '';
10325
10326            var checkAdd = (flname == 'clEmptyFolder') ? true : false,
10327                fln_val = flname.replace(/-/g,' '),
10328                fln_tooltip = (!checkAdd && flname.length > 6) ? ' data-toggle="tooltip" data-placement="top" data-original-title="' + flname + '"' : '',
10329                flc = (/^[0-9]*$/.test(flcount)) ? flcount * 1 : 0,
10330                fls = (/^[0-9.]*$/.test(flsize)) ? flsize * 1 : 0,
10331                fls_obj = formatFileSize(fls, 2, 'obj'),
10332                flf = (String(flfavorite) === '1') ? 1 : 0,
10333                favIcon = (flf === 1) ? clSVG('pin', 12, 12) : clSVG('pin_blank', 12, 12);
10334
10335            return '\
10336                <li class="dd-item fli" data-id="' +  flname + '" data-fid="'+ fid +'" data-favorite="'+ flf +'">\
10337                    <div class="fli-wrap dd-handle">\
10338                        ' + clSVG('move_handle', 20, 20, true, 'dd-icon cl-icon cl-handle') + '\
10339                        ' + clSVG('folder', 16, 12, true, 'dd-icon cl-icon cl-folder') + clSVG('folder_open', 16, 12, true, 'dd-icon cl-icon cl-folder-open') + '\
10340                        <span class="dd-fln fl-nodrag" ' + fln_tooltip + '>' + fln_val + '</span>\
10341                        <span class="dd-flc" attr-count="' + flc + '">' + flc + '</span>\
10342                        <span class="dd-fls fli-hidden" attr-size="' + fls + '" attr-size-unit="' + fls_obj['unit'] + '">' + fls_obj['val'] + '</span>\
10343                        <span class="dd-fle fli-hover fl-nodrag" attr-id="' + flname + '">' + clSVG('pencil', 12, 12) + '</span>\
10344                        <span class="dd-fld fli-hover fl-nodrag" attr-id="' + flname + '">' + clSVG('delete', 12, 12) + '</span>\
10345                        <span class="dd-flf fli-hover fl-nodrag" attr-id="' + flname + '" data-fav="'+ flf +'">' + favIcon + '</span>\
10346                    </div>\
10347                </li>\
10348            ';
10349        },
10350        setMystorageFolder: function(mode, val) {
10351            var myResourceTab = $('#mystorage'),
10352                myResourceFolderlist = myResourceTab.find('#nestableFolder');
10353
10354            switch(mode) {
10355                case 'set_fll':
10356                    myResourceFolderlist.removeClass('ready');
10357                    // myResourceFolderlist.nestable('init');
10358                    // if(typeof val != 'undefined' && val !== null && val.length > 0) SFOLDER = val;
10359                    $.each(SFOLDER, function (i, o) {
10360                        if(o['name'] == 'clEmptyFolder') return true;
10361    
10362                        if(i == 0) {
10363                            var flc = (/^[0-9]*$/.test(o['fcount'])) ? o['fcount'] * 1 : 0,
10364                                fls = (/^[0-9.]*$/.test(o['fsize'])) ? o['fsize'] * 1 : 0,
10365                                fls_obj = formatFileSize(fls, 2, 'obj');
10366    
10367                            myResourceFolderlist.find('.fli[data-id="all"] .dd-flc').attr('attr-count',flc).text(flc);
10368                            myResourceFolderlist.find('.fli[data-id="all"] .dd-fls').attr({'attr-size':fls, 'attr-size-unit':fls_obj['unit']}).text(fls_obj['val']);
10369                            return true;
10370                        }
10371    
10372                        if(myResourceFolderlist.find('.fli[data-id="' + o['name'] + '"]').length > 0) return true;
10373                        var add_folder = $.resource.getMystorageFolderHtml(o['name'], o['fcount'], o['fsize'], o['id'], o['favorite']);
10374                            myResourceFolderlist.find('.fll').append(add_folder);
10375                    });
10376
10377                    sortFolderFavoritesTop();
10378
10379                    // if(SFOLDER_ACTIVE != '' && SFOLDER_ACTIVE != myResourceFolderlist.find('.fll.active').attr('data-id')) myResourceFolderlist.find('.fli[data-id="' + SFOLDER_ACTIVE + '"]').addClass('active');
10380                    break;
10381
10382                case 'set_fli_state':
10383                    var is_change = (val.ffolder == 'all' && val.state == 'move') ? false : true;
10384
10385                    if(is_change) {
10386                        var flc = $('#nestableFolder .fli[data-id="'    + val.ffolder +'"]').find('.dd-flc').attr('attr-count'),
10387                            fls = $('#nestableFolder .fli[data-id="'+ val.ffolder +'"]').find('.dd-fls').attr('attr-size'),
10388                            new_flc = val.count * 1,
10389                            new_fls = val.size * 1;
10390
10391                        flc = (/^[0-9]*$/.test(flc)) ? flc * 1 : 0;
10392                        new_flc += flc;
10393                
10394                        fls = (/^[0-9.]*$/.test(fls)) ? fls * 1 : 0;
10395                        new_fls += fls;
10396
10397                        var fls_obj = (new_flc < 1) ? {'val': 0, 'unit': 'Bytes'} : formatFileSize(new_fls, 2, 'obj');
10398                        $('#nestableFolder .fli[data-id="'+ val.ffolder +'"]').find('.dd-flc').attr('attr-count',new_flc).text(new_flc);
10399                        $('#nestableFolder .fli[data-id="'+ val.ffolder +'"]').find('.dd-fls').attr({'attr-size':new_fls, 'attr-size-unit':fls_obj['unit']}).text(fls_obj['val']);
10400                    }
10401                    break;
10402
10403                case 'nodrag':
10404                    if(val) {
10405                        myResourceFolderlist.find('*').addClass('fl-nodrag');
10406                        myResourceFolderlist.find('.fli-wrap').removeClass('dd-handle');
10407                    } else {
10408                        myResourceFolderlist.find('.fl-nodrag:not(:is(.dd-fln, .fli-hover))').removeClass('fl-nodrag');
10409                        myResourceFolderlist.find('.fli:not(.fli-first) .fli-wrap').addClass('dd-handle');
10410                    }
10411                    break;
10412
10413                default:
10414                    break;
10415            }
10416        },
10417        open: function() {
10418            $('#el-fileupload').modal('show');
10419        },
10420        close: function() {
10421            $('#el-fileupload').modal('hide');
10422            $('.uploadModal').remove();
10423        },
10424        selected: function() {
10425            var selected = new Array(),
10426                rmode = (myStorageActive()) ? 'my' : 'free',
10427                thisResourceSelected = $('#'+rmode+'storage .resource-selected-ul');
10428
10429            thisResourceSelected.children('li').each(function() {
10430                selected.push($(this).find('p.selected-file-name').text());
10431            });
10432
10433            return selected;
10434        },
10435    }
10436
10437    $.category = {
10438        delete : [],
10439        moveHandle : function() {
10440            return clSVG('move_handle', 20, 20, true, 'cl-sort-handle');
10441        },
10442        deleteHandle : function() {
10443            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>';
10444        },
10445        init : function() {
10446            $(document).on('click', '#prod-category-text', function(e) { 
10447                e.stopPropagation();
10448                if($('.category-wrap').hasClass('open')) {
10449                    $('.category-lists').slideUp(200, function() {
10450                        $('.category-wrap').removeClass('open');    
10451                    }); 
10452                } else {
10453                    $('.category-wrap').toggleClass('open');
10454                    $('.category-lists').slideDown(200); 
10455                }
10456            });
10457            $(document).on('click','.form-ctrl-button.category, .gallery-ctrl-category', function(e) { 
10458                e.stopPropagation();
10459                var s = $(this).attr('data-category');
10460                $.category.open(s); 
10461            });
10462            $(document).on('click','.cl-category-modal-close',function(e) { $.category.close(); });
10463            $(document).on('mousedown', '.prod-option-move', function(){
10464               $(this).closest('.prod-option-list').css('overflow-y', 'auto');
10465            });
10466            $(document).on('mouseup', '.prod-option-move', function(){
10467               $(this).closest('.prod-option-list').css('overflow-y', '');
10468            });
10469            $(document).on('blur','.edit-option-title input', function(e) {
10470                // 중복값 체크
10471                checkDuplicateOptionName($(this));
10472            });
10473
10474            $(document).on('focus', '.edit-option-quantity .option-price-quantity', function() {
10475                $(this).attr('data-before_val', Number(removeCommas($(this).val())));
10476                // var cnt = Number(removeCommas($(this).val()));
10477                // if(cnt == 0)
10478                // if($(this).closest('.prod-option-edit').find('.edit-option-select .option-price-status-str').attr('data-val') == 'O') {
10479                //     $(this).closest('.prod-option-edit').find('.edit-option-select .option-price-status-select [data-val="S"]').click();
10480                // }
10481            }).on('input', '.edit-option-quantity .option-price-quantity', function() {
10482                var before_val = Number(removeCommas($(this).attr('data-before_val')));
10483                var cnt = Number(removeCommas($(this).val()));
10484                if(cnt > 9999) {
10485                    alert('최대 입력 수량은 9,999 입니다.');
10486                    cnt = 9999;
10487                    $(this).val(addCommas('9999'));
10488                }
10489                if(before_val == 0 && cnt > 0 && $(this).closest('.prod-option-edit').find('.edit-option-select .option-price-status-str').attr('data-val') == 'O') {
10490                    $(this).closest('.prod-option-edit').find('.edit-option-select .option-price-status-select [data-val="S"]').click();
10491                } else if(cnt == 0 && $(this).closest('.prod-option-edit').find('.edit-option-select .option-price-status-str').attr('data-val') == 'S') {
10492                    $(this).closest('.prod-option-edit').find('.edit-option-select .option-price-status-select [data-val="O"]').click();
10493                }
10494            }).on('keydown', '.edit-option-quantity .option-price-quantity', function(e) {
10495                var is_number_key = (e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 96 && e.keyCode <= 105);
10496                var value = String(removeCommas($(this).val()));
10497                var has_selection = this.selectionStart !== this.selectionEnd;
10498
10499                if(is_number_key && !e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey && value.length >= 4 && !has_selection) {
10500                    e.preventDefault();
10501                    alert('최대 입력 수량은 9,999 입니다.');
10502                    $(this).val(addCommas('9999')).trigger('input');
10503                }
10504            }).on('paste', '.edit-option-quantity .option-price-quantity', function(e) {
10505                var clipboard = e.originalEvent && e.originalEvent.clipboardData;
10506                var value = clipboard ? clipboard.getData('text').replace(/[^0-9]/g, '') 
10506: '';
10507                var current_value = String(removeCommas($(this).val()));
10508                var selected_value = $(this).val().substring(this.selectionStart, this.selectionEnd).replace(/[^0-9]/g, '');
10509                var result_length = current_value.length - selected_value.length + value.length;
10510
10511                if(value !== '' && result_length > 4) {
10512                    e.preventDefault();
10513                    alert('최대 입력 수량은 9,999 입니다.');
10514                    $(this).val(addCommas('9999')).trigger('input');
10515                }
10516            });
10517
10518            $(document).on('click','.prod-option-title, .prod-option-price, .prod-option-quantity, .prod-option-status, .prod-option-desc, .prod-option-require', function(e) {
10519                e.stopPropagation();
10520                var submit = true;
10521                var parent = $(this).closest('.prod-option');
10522                $('.prod-option-item').each(function () {
10523                    $(this).closest('li').removeClass('err');
10524                });
10525                
10526                if($('.prod-option-edit').length <= 2) {
10527                    $('.edit-option-delete').addClass('hide');
10528                } else {
10529                    $('.edit-option-delete').removeClass('hide');
10530                }
10531
10532                if($('.prod-option-list .prod-option-item.hide').length) {
10533                    $.each($('.prod-option-item.hide'), function(i,v) {
10534                        var opt_title = $(v).parent().find('.prod-option-edit .edit-option-title input').val(),
10535                            opt_desc = $(v).parent().find('.prod-option-edit .edit-option-desc input').val(),
10536                            opt_price = $(v).parent().find('.prod-option-edit .edit-option-price input').val(),
10537                            opt_quantity = $(v).parent().find('.prod-option-edit .edit-option-quantity input').val(),
10538                            opt_status = $(v).parent().find('.prod-option-edit .option-price-status-str').attr('data-val'),
10539                            opt_text_require = $(v).parent().find('.prod-option-edit .option-require-str').attr('data-val');
10540
10541                        $(v).closest('li').removeClass('err');
10542                        if(product_options.advanced == 'false') {
10543                            if(opt_title.length == 0) {
10544                                $(v).closest('li').addClass('err').find('.edit-option-title input');
10545                                submit = false;
10546                                return true;
10547                            }
10548                        }
10549                        switch(opt_status) {
10550                            case "S" : str = '판매'; break;
10551                            case "O" : str = '품절'; break;
10552                            case "H" : str = '숨김'; break;
10553                            default : str = '판매'; break;
10554                        }
10555                        var check;
10556                        // if(opt_text_require == 'TR') {
10557                        //     check = "\
10558                        //         <span>필수</span>\
10559                        //         <svg class='active' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16'>\
10560                        //         <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'/>\
10561                        //         </svg>";
10562                        // } else {
10563                        //     check = "\
10564                        //         <span>필수</span>\
10565                        //         <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16'>\
10566                        //         <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'/>\
10567                        //         </svg>";
10568                        // }
10569                        var soption = String(opt_price);
10570                        if(soption.replace('+','') == '' || soption.replace('-','') == '') opt_price = 0;
10571                        opt_price = removeCommas(opt_price);
10572                        opt_quantity = removeCommas(opt_quantity);
10573                        if (!opt_quantity) opt_quantity = 0;
10574                        if (!opt_price || isNaN(opt_price) === true) o
10574pt_price = 0;
10575
10576                        opt_quantity = (opt_quantity * 1);
10577                        opt_price = (opt_price * 1);
10578
10579                        var abs_price = Math.abs(opt_price),
10580                            str_price = addCommas(abs_price.toString()),
10581                            str_quantity = addCommas(opt_quantity.toString());
10582
10583                        $(v).find('.prod-option-title').text(opt_title);
10584                        $(v).find('.prod-option-desc').text(opt_desc);
10585                        $(v).find('.prod-option-price').text(str_price).attr('data-option-price',opt_price);
10586                        $(v).find('.prod-option-quantity').text(opt_quantity);
10587                        $(v).find('.prod-option-status').text(str).attr('data-val',opt_status);
10588                        $(v).find('.prod-option-require').html(check).attr('data-val',opt_status);
10589                        $(v).parent().find('.prod-option-edit').addClass('hide');
10590                        $(v).removeClass('hide');
10591
10592                        // 다른 옵션 input 선택시 기존 값 0됨
10593                        // if(opt_price < 0) {
10594                        //     $(this).find('.prod-option-price').text(str_price);
10595                        //     $(this).find('.prod-option-price').find('.prod-option-price').addClass('minus');
10596                        // } else {
10597                        //     $(this).find('.prod-option-price').text(str_quantity);
10598                        //     $(this).find('.prod-option-price').find('.prod-option-price').removeClass('minus');
10599                        // }
10600                    });
10601                }
10602
10603                var title = $(this).parent().find('.prod-option-title').text(),
10604                    title_html = $(this).parent().find('.prod-option-title').html(),
10605                    desc = $(this).parent().find('.prod-option-desc').text(),
10606                    price = $(this).parent().find('.prod-option-price').attr('data-option-price'),
10607                    quantity = $(this).parent().find('.prod-option-quantity').text(),
10608                    status = $(this).parent().find('.prod-option-status').attr('data-val'),
10609                    text_require = $(this).parent().find('.prod-option-require').attr('data-val'),
10610                    $title = $(this).parent().siblings('.prod-option-edit').find('.edit-option-title input'),
10611                    $title_html = $(this).parent().siblings('.prod-option-edit').find('.edit-option-title'),
10612                    $desc = $(this).parent().siblings('.prod-option-edit').find('.edit-option-desc input'),
10613                    $price = $(this).parent().siblings('.prod-option-edit').find('.edit-option-price input'),
10614                    $quantity = $(this).parent().siblings('.prod-option-edit').find('.edit-option-quantity input'),
10615                    $status = $(this).parent().siblings('.prod-option-edit').find('.option-price-status-str'),
10616                    $text_require = $(this).parent().siblings('.prod-option-edit').find('.option-require-str');
10617      
10618                if(price == 'NaN') price = 0;
10619                switch(status) {
10620                    case "S" : str = '판매'; break;
10621                    case "O" : str = '품절'; break;
10622                    case "H" : str = '숨김'; break;
10623                    default : str = '판매'; break;
10624                }
10625                price = removeCommas(price);
10626                quantity = removeCommas(quantity);
10627                if (!quantity) quantity = 0;
10628                if (!price || isNaN(price)) price = 0;
10629
10630                price = (price * 1);
10631                quantity = (quantity * 1);
10632
10633                if(product_options.advanced == 'true') {
10634                    $title_html.html(title_html);
10635                } else {
10636                    $title.val(title);
10637                }
10638                $desc.val(desc);
10639                $price.val(addCommas(price.toString()));
10640                $quantity.val(addCommas(quantity.toString()));
10641                $status.text(str).attr('data-val', status);
10642                // $text_require.html(check).attr('data-val', text_require);
10643
10644                $(this).parent().addClass('hide');
10645                $(this).parent().siblings('.prod-option-edit').removeClass('hide');
10646                if($(this).hasClass('prod-option-title')) $title.focus();
10647                if($(this).hasClass('prod-option-price')) $price.focus();
10648                if($(this).hasClass('prod-option-quantity')) $quantity.focus();
10649            });
10650
10651            $(document).on('keydown', '.edit-option-title input, .options-input', function(e) {
10652                var keyCode = e.keyCode,
10653                    shiftKey =  e.shiftKey;
10654                
10655                if(keyCode == 222) 
10656                    if(shiftKey) return false;
10657
10658                if(keyCode == 191 || keyCode == 111) {
10659                    if(shiftKey) return;
10660                    e.stopPropagation();
10661                    return false;
10662                }
10663
10664                if($(this).hasClass('options-input')) {
10665                    var value = $(this).val(),
10666                        last = value.split("").pop();
10667                    if(last == "," && keyCode == 188) {
10668                        alert('옵션 값을 알맞게 입력해주세요');
10669                        return false;
10670                    }
10671                }
10672            });
10673
10674            $(document).on('keyup keydown click','.edit-option-title input, .edit-option-desc input, .edit-option-price input, .edit-option-quantity input',function(e) {
10675                e.stopPropagation();
10676                var keyCode = e.keyCode || e.which,
10677                    eType = e.type,
10678                    target = e.target,
10679                    $title = $(this).parents('.form-wrap').find('.edit-option-title input'),
10680                    $desc = $(this).parents('.form-wrap').find('.edit-option-desc input'),
10681                    $price = $(this).parents('.form-wrap').find('.edit-option-price input'),
10682                    $quantity = $(this).parents('.form-wrap').find('.edit-option-quantity input'),
10683                    $status = $(this).parents('.form-wrap').find('.option-price-status-str'),
10684                    $text_require = $(this).parents('.form-wrap').find('.option-price-status-str');
10685
10686                if(eType == 'keydown' && keyCode == 13) e.preventDefault(); //enter submit 방지
10687
10688                var price = removeCommas($price.val())*1,
10689                    quantity = removeCommas($quantity.val())*1;
10690
10691                var $li = $(this).parents('li');
10692
10693                if(price < 0) {
10694                    $li.find('.prod-option-price').text(Math.abs(price));
10695                    $li.find('.prod-option-price').addClass('minus');
10696                } else {
10697                    $li.find('.prod-option-price').text(price);
10698                    $li.find('.prod-option-price').removeClass('minus');
10699                }
10700
10701                var abs_price = Math.abs(price),
10702                    str_price = addCommas(abs_price.toString()),
10703                    str_quantity = addCommas(quantity.toString());
10704
10705                $li.find('.prod-option-title').text($title.val());
10706                $li.find('.prod-option-desc').text($desc.val());
10707                $li.find('.prod-option-price').text(str_price);
10708                $li.find('.prod-option-price').attr('data-option-price', price);
10709                $li.find('.prod-option-quantity').text(str_quantity);
10710                $li.find('.prod-option-status').text($status.text());
10711
10712                var submit = false;
10713                var isDuplicate = true;
10714                if(eType == 'click' && !$(target).is('.prod-option-list') && !$(target).is('input')) { //다른 옵션 클릭 시 입력
10715                    isDuplicate = checkDuplicateOptionName($title);
10716                    submit = true;   
10717                }
10718
10719                if(eType == 'keyup') {
10720                    if(keyCode == 13) {
10721                        isDuplicate = checkDuplicateOptionName($title);
10722                        e.preventDefault();
10723                        submit = true;  
10724                    }
10725
10726                    if($('.switch-quantity').prop('checked') == true) { //재고관리 on
10727                        if(keyCode == 9 && !$('.option-price-number').is(':focus') && !$('.option-price-quantity').is(':focus')) { //tab
10728                            isDuplicate = checkDuplicateOptionName($title);
10729                            submit = true;
10730                        }
10731                    } else { //재고관리 off
10732                        if(keyCode == 9 && !$('.option-price-number').is(':focus')) { //tab
10733                            isDuplicate = checkDuplicateOptionName($title);
10734                            submit = true;
10735                        }
10736                    }  
10737                }
10738
10739                if(submit && isDuplicate == false) {
10740                    shoppingSetOption($('.prod-option-item.hide'));
10741                }          
10742            });
10743
10744            $(document).on('click', function(e) {
10745                if(!$(e.target).is('.prod-discount-unit-select') && $(e.target).closest('.prod-discount-unit-select').length == 0) {
10746                    $('.discount-unit-select').hide();
10747                }
10748                if(!$(e.target).is('.prod-option-list')) {
10749                    shoppingSetOption($('.prod-option-item.hide'));
10750                }
10751
10752                if($('.prod-modal').has(e.target).length) {
10753                    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) {
10754                        $('.delivery-template-list').slideUp(200);
10755                        $('#delivery_template_seq.open').removeClass('open');
10756                    }
10757
10758                    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) {
10759                        $('#prod-category-lists').slideUp(200);
10760                        $('.category-wrap.open').removeClass('open');
10761                    }
10762                }
10763            });
10764
10765            $(document).on('click', '#delivery_template_seq:not(.limit-disabled)', function() {
10766                $(this).toggleClass('open');
10767                if($(this).hasClass('open')) {
10768                    $('.delivery-template-list').slideDown(200);
10769                } else {
10770                    $('.delivery-template-list').slideUp(200);
10771                }
10772            });
10773
10774            $(document).on('input', '#product_weight', function(e) {
10775                var val = $(this).val().replace(/,/g, '');
10776                if(val.indexOf('.') > -1 && val.indexOf('.') < val.length-4) {
10777                    val = Number((Math.floor(Number(val) * 1000) / 1000).toFixed(3));
10778                }
10779
10780                if(Number(val) > 100) {
10781                    val = number_format(100);
10782                }
10783
10784                $(this).val(val);
10785            }).on('blur', '#product_weight', function() {
10786                var val = $(this).val().replace(/,/g, '');
10787                if(val.indexOf('.') > -1 && val.indexOf('.') == val.length-1) {
10788                    $(this).val(number_format(val.replace(/\./g, '')));
10789                }
10790            });
10791
10792            $(document).on('click', '.btn-delivery-template-setting', function() {
10793                var shopping_url = $(this).data('shopping_url');
10794                deliveryTemplateListModal(shopping_url, function() {
10795                    $.processON();
10796                    var site = (typeof SID == 'undefined') ? property.SID : SID,
10797                        // page = (typeof PAGE == 'undefined') ? ((typeof PROD_PAGE == 'undefined') ? property.PAGE : PROD_PAGE) : PAGE,
10798                        pid = (typeof selectID == 'undefined') ? null : selectID,
10799                        id = $('#prod-no').val();
10800                    setTimeout(function() {
10801                        $.ajax({
10802                            url: '/template/products/',
10803                            data: { type:'get', sid:site, id:id, pid:pid },
10804                            dataType: 'json',
10805                            type: 'POST',
10806                            async: false,
10807                            cache: false,
10808                            success: function (data) {
10809                                if(data.error != 'undefined' && data.error) {
10810                                    alert(data.error);
10811                                    return false;
10812                                }
10813                                var i = data.item,
10814                                    url = (typeof RESOURCE == 'undefined') ? property.RESOURCE : RESOURCE,
10815                                    folder = '', f = '';
10816
10817                                var delivery_template_str = '';
10818                                if(i.delivery_template) {
10819                                    $.each(i.delivery_template, function(k, v) {
10820                                        var template_desc = '';
10821                                        template_desc += '(';
10822                                        template_desc += $.lang[LANG]['shopping.delivery.template.mix_yn.' + v.mix_yn.toLowerCase()];
10823                                        var delivery_type_arr = v.delivery_type.split(',');
10824                                        var delivery_type_str = '';
10825                                        $.each(delivery_type_arr, function(idx, delivery_type) {
10826                                            if(delivery_type_str) delivery_type_str += ', ';
10827                                            delivery_type_str += $.lang[LANG]['shopping.delivery.template.delivery_type.' + delivery_type.toLowerCase()];
10828                                        });
10829                                        if(delivery_type_str) 
10830                                            template_desc += ' / ' + delivery_type_str;
10831                                        
10832                                        if(delivery_type_arr.indexOf('DELIVERY') > -1) {
10833                                            template_desc += ' / ' + $.lang[LANG]['shopping.delivery.' + v.delivery_company.toLowerCase()];
10834                                        }
10835
10836                                        template_desc += ' / ' + $.lang[LANG]['shopping.delivery.template.price_type.' + v.price_type.toLowerCase()];
10837
10838                                        if(v.price_type == 'FIX') {
10839                                            template_desc += '(' + number_format(v.delivery_fee) + '원)';
10840                                        } else if(v.price_type == 'QUANTITY' || v.price_type == 'WEIGHT') {
10841                                            var price_type_detail = v.price_type_detail ? JSON.parse(v.price_type_detail) : {};
10842                                            
10843                                            if(price_type_detail.method == 'DIFFERENTIAL') {
10844                                                var detail = '';
10845                                                if(price_type_detail.detail) {
10846                                                    $.each(price_type_detail.detail, function(i, j) {
10847                                                        var value = Object.keys(j);
10848                                                        var price = Object.values(j);
10849
10850                                                        if(v.price_type == 'QUANTITY') {
10851                                                            if(i < 2) {
10852                                                                if(detail) detail += ', ';
10853                                                                detail += value + '개 이상(' + number_format(price) + '원)';
10854                                                            }
10855                                                        } else if(v.price_type == 'WEIGHT') {
10856                                                            if(i < 2) {
10857                                                                if(detail) detail += ', ';
10858                                                                detail += value + 'Kg 이상(' + number_format(price) + '원)';
10859                                                            }
10860                                                        }
10861                                                    });
10862                                                }
10863                                                if(template_desc) {
10864                                                    detail = '(차등 / ' + detail + ')';
10865                                                    template_desc += detail;
10866                                                }
10867                                            } else if(price_type_detail.method == 'REPEAT') {
10868                                                var detail = '';
10869                                                var value = Object.keys(price_type_detail.detail);
10870                                                var price = Object.values(price_type_detail.detail);
10871
10872                                                if(v.price_type == 'QUANTITY') {
10873                                                    detail += value + '개 구매시마다 ' + number_format(price) + '원 반복 부과';
10874                                                } else if(v.price_type == 'WEIGHT') {
10875                                                    detail += value + 'Kg마다 ' + number_format(price) + '원 반복 부과';
10876                                                }
10877
10878                                                if(detail) {
10879                                                    detail = '(반복 / ' + detail + ')';
10880                                                    template_desc += detail;
10881                                                }
10882                                            }
10883                                        }
10884
10885                                        if(v.additional_yn == 'Y') {
10886                                            template_desc += ' / 도서산간 지역 추가 배송비 (제주 ' + number_format(v.additional_jeju_price) + '원, 제주 외 도서산간 ' + number_format(v.additional_land_price) + '원)';
10887                                        }
10888
10889                                        template_desc += ' / ' + $.lang[LANG]['shopping.delivery.template.pay_type.' + v.pay_type.toLowerCase()];
10890
10891                                        if(v.free_condition_yn == 'Y') {
10892                                            template_desc += ' / ' + number_format(v.free_condition) + '원 이상 무료 배송';
10893                                        }
10894
10895                                        if(v.make_to_order_yn == 'Y') {
10896                                            template_desc += ' / 주문 확인 후 ' + v.due_date + '일 후 배송 예정';
10897                                        }
10898                                        if(v.install_fee_yn == 'Y') {
10899                                            template_desc += ' / 별도 설치비 있음';
10900                                        }
10901                                        template_desc += ')';
10902
10903                                        delivery_template_str += '\
10904                                        <li data-val="' + v.seq + '" data-weight="' + (v.price_type == 'WEIGHT' ? 'true' : 'false') + '">\
10905                                            <input type="radio" id="delivery_template_seq_' + v.seq + '" name="delivery_template_seq" value="' + v.seq + '" />\
10906                                            <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>\
10907                                            <label for="delivery_template_seq_' + v.seq + '">\
10908                                                <span class="template-name">' + v.name + '</span>\
10909                                                <span class="template-desc">' + template_desc + '</span>\
10910                                            </label>\
10911                                        </li>';
10912                                    });
10913                                }
10914
10915                                $('.option-delivery-template-select').html(delivery_template_str);
10916
10917                                if(typeof i.delivery_template_seq != 'undefined' && i.delivery_template_seq) {
10918                                    $('.option-delivery-template-select input[name="delivery_template_seq"][value="' + i.delivery_template_seq + '"]').prop('checked', true);
10919
10920                                    $('.option-delivery-template-str').html($('.option-delivery-template-select li[data-val="' + i.delivery_template_seq + '"] label').html());
10921
10922                                    if($('.option-delivery-template-select li[data-val="' + i.delivery_template_seq + '"]').data('weight') == false) {
10923                                        $('.product-weight').hide();
10924                                        $('#product_weight').val('');
10925                                    } else {
10926                                        $('.product-weight').show();
10927                                        $('#product_weight').val(number_format(i.p.product_weight) + 'kg');
10928                                    }
10929                                } else {
10930                                    $('.option-delivery-template-select input[name="delivery_template_seq"]:first').prop('checked', true).change();
10931                                }
10932                            },
10933                            complete: function() {
10934                                $.processOFF();
10935                            }
10936                        });
10937                    });
10938                });
10939            });
10940
10941            // $(document).off('click','.prod-option-add');
10942            $(document).on('click','.prod-option-add', addProductOption);
10943
10944            $(document).on('click', '.cl_etc_state_check', function () {
10945                $('.cl_etc_state_check').each(function () {
10946                    $(this).removeClass('active');
10947                });
10948
10949                $(this).addClass('active');
10950                var val = $(this).attr('data-val');
10951                $('#etc-date-state').val(val);
10952
10953                switch(val) {
10954                    case 'Y':
10955                        $('.etc-setting').removeClass('hide');
10956                        $('.time-setting').addClass('hide');
10957                        break;
10958                    case 'T':
10959                        $('.etc-setting').removeClass('hide');
10960                        $('.time-setting').removeClass('hide');
10961                        break;
10962                    default:
10963                        $('.etc-setting').addClass('hide');
10964                        break;
10965                }
10966            });
10967        
10968            $(document).on('click', '.cl_etc_status_check', function () {
10969                $('.cl_etc_status_check').each(function () {
10970                    $(this).removeClass('active');
10971                });
10972
10973                $(this).addClass('active');
10974                var val = $(this).attr('data-val');
10975
10976                $('#etc-date-status').val(val);
10977            });
10978        
10979            // $(document).on('click', '.cl_etc_week_check', function () {
10980            //     $('.cl_etc_week_check').each(function () {
10981            //         $(this).removeClass('active');
10982            //     });
10983
10984            //     $(this).addClass('active');
10985            //     var val = $(this).attr('data-val');
10986            //     $('#etc-date-week').val(val);
10987            //     exceptPicker.disabledDays = null;
10988            //     if(val == 'W') {
10989            //         exceptPicker.disabledDays = [0, 6];
10990            //     } else if(val == 'K') {
10991            //         exceptPicker.disabledDays = [1, 2, 3, 4, 5];
10992            //     } else {
10993            //         exceptPicker.disabledDays = null;
10994            //     }
10995            //     //exceptPicker.generateDates(true);
10996            //     exceptPicker.setSelectedDates($('#etc-start-date-txt').val(), 'start');
10997            //     exceptPicker.setSelectedDates($('#etc-end-date-txt').val(), 'end');
10998            //     setExceptPicker();
10999            // });
11000        
11001            // $(document).on('click', '.cl_etc_date_time', function () {
11002            //     $('.cl_etc_date_time').each(function () {
11003            //         $(this).removeClass('active');
11004            //     });
11005
11006            //     $(this).addClass('active');
11007            //     var startDate = $(this).attr('data-start_date');
11008            //     var endDate = $(this).attr('data-end_date');
11009            //     $('#etc-start-date-txt').val(startDate);
11010            //     $('#etc-end-date-txt').val(endDate);
11011            //     //exceptPicker.generateDates(true);
11012            //     exceptPicker.setSelectedDates(startDate, 'start');
11013            //     exceptPicker.setSelectedDates(endDate, 'end');
11014            //     setExceptPicker();
11015            // });
11016
11017            $(document).on('click', '.cl_product_state_check', function (e) {
11018                var state = $(this).attr('for');
11019                var cnt = $('.prod-option[data-option_mode="normal"] .prod-option-list > li').length;
11020                var tax = $('#tax').attr('data-total-tax');
11021                var productNumber = $('#prod-no').val();
11022                var status = true;
11023
11024                var current = $('input[name="product_state"]:checked').val();
11025                if(current == "N" && product_options.advanced == 'true') {
11026                    if(e.originalEvent != 'undefined' && (state == 'download-product' || state == 'etc-product')) {
11027                        var str = (state == 'download-product') ? '다운로드' : '기타무형';
11028                        if(confirm(str + ' 상품은 고급설정을 지원하지 않아 등록된 옵션정보가 초기화 됩니다. 상품 유형을 변경하시겠습니까?') == false) return false;
11029                        else {
11030                            $('.options-config').hide();
11031                            resetOptions();
11032                        }
11033                    }
11034                }
11035                // console.log(state);
11036                if(state != 'normal-product') {
11037                    $('.delivery-template, .product-weight, .brand, .unit-pricing').hide();
11038                }
11039
11040                if (state == "download-product") { //다운로드상품 선택
11041                    //입력옵션 비활성화
11042                    $('.prod-option[data-option_mode="text"]').addClass('hide');
11043                    $('#text-option').prop('checked', false).closest('.newcheckbox').hide();
11044                    //추가옵션 비활성화
11045                    $('.prod-option[data-option_mode="additional"]').addClass('hide');
11046                    $('#additional-option').prop('checked', false).closest('.newcheckbox').hide();
11047
11048                    if($('.prod-option-tab .prod-option.hide').length == 3) { //탭 모두 비활성화일때
11049                        $('.prod-option-tab').addClass('hide');
11050                        if($('.switch-quantity').is(":checked") == true) {
11051                            $('.quantity-label').removeClass('on');
11052                        }
11053                    }
11054                    
11055                    $('#state-append').fadeIn(0);
11056                    $('#etc-calendar').hide();
11057                    if ($('#normal-option').is(':checked') === false) { //일반옵션 없음
11058                        if ($('.real-file-name').length < 1) {
11059                            $('.switch-product[value="off"]').prop('checked', true);
11060                            $('#status-append').fadeOut(0);
11061                            $('#sale-calendar').hide();
11062                        }
11063                        var html = '<div class="form-group" id="product-state">\
11064                                        <input type="file" id="upload-file" name="files">\
11065                                        <div class="product-state-box" id="add-upload-check">\
11066                                            <div class="product-upload">\
11067                                                <div class="title">파일 업로드</div>\
11068                                                <div class="download-contents">\
11069                                                    <span class="cl_icon_upload02" data-cnt="0">업로드</span>\
11070                                                    <div id="none-option-file">\
11071                                                    </div>\
11072                                                </div>\
11073                                            </div>\
11074                                            <div class="download-setting">\
11075                                                <div class="title">다운로드<br>한도설정';
11076                                                /*html += '<span class="cl-icon cl_icon_info01"></span>';*/
11077                                                html += '</div>\
11078                                                <div id="download-contents">\
11079                                                    <div class="input-box">\
11080                                                        <div class="title">기간 제한</div>\
11081                                                        <div class="textbox">\
11082                                                            <input type="text" numberOnly class="download-input" id="download-date" value="1" maxlength="90">\
11083                                                            <span>일</span>\
11084                                                        </div>\
11085                                                    </div>\
11086                                                    <div class="input-box">\
11087                                                        <div class="title">횟수 제한</div>\
11088                                                        <div class="textbox">\
11089                                                            <input type="text" numberOnly class="download-input" id="download-count" value="1" maxlength="10">\
11090                                                            <span>회</span>\
11091                                                        </div>\
11092                                                    </div>\
11093                                                </div>\
11094                                            </div>\
11095                                        </div>\
11096                                    </div>';
11097                        // console.log(html);            
11098                        $('#product-state').remove();
11099                        $('#state-append').append(html);
11100                        
11101                        $('.prod-option[data-option_mode="normal"] .prod-option-list > li').each(function () {
11102                            var $checkTag = $(this).children('.product-status');
11103                            if ($checkTag.hasClass('product-status') === false) {
11104                                var item = '<div class="form-group product-status">\
11105                                            <div class="product-state-box">\
11106                                                <div class="product-upload">\
11107                                                    <div class="title">파일 업로드</div>\
11108                                                    <div class="download-contents">\
11109                                                        <span class="cl_icon_upload02" data-cnt="0">업로드</span>\
11110                                                        <div class="file-box-list" id="file-box-0"></div>\
11111                                                    </div>\
11112                                                </div>\
11113                                            </div>\
11114                                        </div>';
11115                                fileUpdateCnt++;
11116
11117                                $(this).append(item);
11118                            } else {
11119                                var $loadTag = $('.prod-option[data-option_mode="normal"] .prod-option-list > li').eq(0).find('.download-contents div');
11120                                // console.log($loadTag.html());
11121                                $('#none-option-file').html($loadTag.html());
11122                            }
11123                        });
11124                    } else { //다운로드 외 다른상품
11125                        var html = '<div class="form-group" id="product-state">\
11126                                        <input type="file" id="upload-file" name="files" data-cnt="'+fileUpdateCnt+'">\
11127                                        <div class="product-state-box" id="add-upload-check">\
11128                                            <div class="download-setting">\
11129                                                <div class="title">다운로드<br>한도설정';
11130                                                /*html += '<span class="cl-icon cl_icon_info01"></span>';*/
11131                                                html += '</div>\
11132                                                <div class="download-contents">\
11133                                                    <div class="input-box">\
11134                                                        <div class="title">기간 제한</div>\
11135                                                        <div class="textbox">\
11136                                                            <input type="text" numberOnly class="download-input" id="download-date" value="1" maxlength="90">\
11137                                                            <span>일</span>\
11138                                                        </div>\
11139                                                    </div>\
11140                                                    <div class="input-box">\
11141                                                        <div class="title">횟수 제한</div>\
11142                                                        <div class="textbox">\
11143                                                            <input type="text" numberOnly class="download-input" id="download-count" value="1" maxlength="10">\
11144                                                            <span>회</span>\
11145                                                        </div>\
11146                                                    </div>\
11147                                                </div>\
11148                                            </div>\
11149                                        </div>\
11150                                    </div>';
11151
11152                        $('#product-state').remove();
11153                        $('#state-append').append(html);
11154
11155                        $('.prod-option[data-option_mode="normal"] .prod-option-list > li').each(function () {
11156                            var $checkTag = $(this).children('.product-status');
11157                            var option_mode = $(this).closest('.prod-option').attr('data-option_mode');
11158                            var name = $(this).find('.prod-option-title').text();
11159                           
11160                            if ($checkTag.hasClass('product-status') === false && option_mode == 'normal') {
11161                                var item = '<div class="form-group product-status">\
11162                                            <div class="product-state-box">\
11163                                                <div class="product-upload">\
11164                                                    <div class="title">파일 업로드</div>\
11165                                                    <div class="download-contents">\
11166                                                    <span class="cl_icon_upload02" data-cnt="'+fileUpdateCnt+'">업로드</span>';
11167                                                    if (name == 'noneOption') item += '<div class="file-box-list" id="file-box-0">';
11168                                                    else item += '<div class="file-box-list" id="file-box-'+fileUpdateCnt+'">';
11169                                                    item += '</div>\
11170                                                    </div>\
11171                                                </div>\
11172                                            </div>\
11173                                        </div>';
11174                                fileUpdateCnt++;
11175
11176                                $(this).find('.prod-option-status').text('품절').attr('data-val', 'O');
11177                                $(this).find('.option-price-status-str').text('품절').attr('data-val', 'O');
11178
11179                                $(this).append(item);
11180                            }
11181                        });
11182                    }
11183                    fileUpdateCnt++;
11184                } else {
11185                    if($('#product-state').length == 0) {
11186                        $('#text-option').closest('.newcheckbox').show();
11187                        $('#additional-option').closest('.newcheckbox').show();
11188                    }
11189                    
11190                    if (productNumber) {
11191                        var admin_url = (uadmin == 'um')? '/_admin':'';
11192                        $.ajax({
11193                            url: admin_url + '/shopping/download_list_check',
11194                            type: 'post',
11195                            dataType: 'json',
11196                            data: {'product_number': productNumber, 'option_seq': 0},
11197                            success: function (data) {
11198                                if (data.code == 'fail') {
11199                                    alert(data.message);
11200                                    status = false;
11201                                    return false;
11202                                }
11203                            }
11204                        });
11205                    }
11206
11207                    if (status == false) return false;
11208
11209                    if (cnt > 0) {
11210                        var checkFile = $('.file-name').length;
11211                        if (checkFile > 0) {
11212                            if (confirm('상품 유형을 변경할 경우 옵션에 등록된 파일이 삭제됩니다.\n계속하시겠습니까?') === true) {
11213                                $('#product-state').remove();
11214                                $('.product-status').remove();
11215                            } else return false;
11216                        } else {
11217                            $('#product-state').remove();
11218                            $('.product-status').remove();
11219                        }
11220                    } else {
11221                        $('#product-state').remove();
11222                        $('.product-status').remove();
11223                    }
11224                    
11225                    if (state=='normal-product' && taxUse != 'TG03' && $('#product-state').length == 0) {
11226                        $('.options-config').show();
11227                        $('#state-append').fadeOut(0);  
11228                    }
11229                    else {
11230                        $('#state-append').fadeIn(0);
11231                    }
11232
11233                    if (state == "etc-product") {
11234                        $('#etc-calendar').show();
11235                    } else {
11236                        $('#etc-calendar').hide();
11237                    }
11238
11239                    if (state == 'normal-product') {
11240                        if(!$('.delivery-template-list').find('[data-val]').find('input[name="delivery_template_seq"]:checked').length) {
11241                            $('.delivery-template-list').find('[data-val]:first').find('input[name="delivery_template_seq"]').prop('checked', true).change();
11242                        }
11243                        $('.delivery-template, .brand, .unit-pricing').show();
11244                    }
11245                }
11246
11247                if(state != 'normal-product') {
11248                    $('.options-config').hide();
11249                    $('.culture-benefit').hide();
11250                    $('#pccc-yn').hide();
11251                } else {
11252                    $('.options-config').show();
11253                    $('.culture-benefit').show();
11254                    $('#pccc-yn').show();
11255                }
11256
11257                if(state != 'download-product') {
11258                    if($('#product-state').length == 0) {
11259                        $('#text-option').closest('.newcheckbox').show();
11260                        $('#additional-option').closest('.newcheckbox').show();
11261                    }
11262                }
11263                
11264                $('.cl_product_state_check').each(function () {
11265                    $(this).children('.cl-icon').removeClass('cl_icon_check02_on').removeClass('cl_icon_check02_off').addClass('cl_icon_check02_off');
11266                    $(this).removeClass('active');
11267                });
11268
11269                $(this).children('.cl-icon').removeClass('cl_icon_check02_off').addClass('cl_icon_check02_on');
11270
11271                $(this).addClass('active');
11272
11273                if(typeof updateNpayButtonSettingState == 'function') updateNpayButtonSettingState(state);
11274            });
11275            
11276            /* product.add.html common tooltip  ******/
11277            $(document).on('mouseenter', '.cl-tooltip-info', function () {
11278                var info_type = ($(this).attr('data-infotype')) ? $(this).attr('data-infotype') : '';
11279                $('.cl-prod-info.'+info_type+'-info').fadeIn(100);
11280            }).on('mouseleave', '.cl-tooltip-info', function () {
11281                var info_type = ($(this).attr('data-infotype')) ? $(this).attr('data-infotype') : '';
11282                $('.cl-prod-info.'+info_type+'-info').fadeOut(100);
11283            });
11284
11285            $(document).on('mouseenter', '.cl-pccc-info', function () {
11286                $('.cl-prod-info.pccc-info').fadeIn(100);
11287            }).on('mouseleave', '.cl-pccc-info', function () {
11288                $('.cl-prod-info.pccc-info').fadeOut(100);
11289            });
11290
11291            $(document).on('mouseenter', '.cl-culture-benefit-info', function () {
11292                $('.cl-prod-info.culture-benefit-info').fadeIn(100);
11293            }).on('mouseleave', '.cl-culture-benefit-info', function () {
11294                $('.cl-prod-info.culture-benefit-info').fadeOut(100);
11295            });
11296
11297            $(document).on('mouseenter', '.cl-discount-info', function () {
11298                $('.cl-prod-info.discount-info').fadeIn(100);
11299            }).on('mouseleave', '.cl-discount-info', function () {
11300                $('.cl-prod-info.discount-info').fadeOut(100);
11301            });
11302
11303            $(document).on('mouseenter', '.cl-grade-info', function () {
11304                $('.cl-prod-info.grade-info').fadeIn(100);
11305            }).on('mouseleave', '.cl-grade-info', function () {
11306                $('.cl-prod-info.grade-info').fadeOut(100);
11307            });
11308
11309            $(document).on('mouseenter', '.cl-status-info', function () {
11310                $('.cl-prod-info.status-info').fadeIn(100);
11311            }).on('mouseleave', '.cl-status-info', function () {
11312                $('.cl-prod-info.status-info').fadeOut(100);
11313            });
11314
11315            $(document).on('mouseenter', '.cl-open-info', function () {
11316                $('.cl-prod-info.open-info').fadeIn(100);
11317            }).on('mouseleave', '.cl-open-info', function () {
11318                $('.cl-prod-info.open-info').fadeOut(100);
11319            });
11320
11321            $(document).on('mouseenter', '.cl-product-info', function () {
11322                $('.cl-prod-info.product-info').fadeIn(100);
11323            }).on('mouseleave', '.cl-product-info', function () {
11324                $('.cl-prod-info.product-info').fadeOut(100);
11325            });
11326
11327            $(document).on('mouseenter', '.cl-option-info', function () {
11328                $('.cl-prod-info.option-info').fadeIn(100);
11329            }).on('mouseleave', '.cl-option-info', function () {
11330                $('.cl-prod-info.option-info').fadeOut(100);
11331            });
11332
11333            $(document).on('mouseenter', '.cl-text-option-info', function () {
11334                $('.cl-prod-info.text-option-info').fadeIn(100);
11335            }).on('mouseleave', '.cl-text-option-info', function () {
11336                $('.cl-prod-info.text-option-info').fadeOut(100);
11337            });
11338
11339            $(document).on('mouseenter', '.cl-prod-info-notice', function () {
11340                $('.cl-prod-info.cl-prod-info-notice').fadeIn(100);
11341            }).on('mouseleave', '.cl-prod-info-notice', function () {
11342                $('.cl-prod-info.cl-prod-info-notice').fadeOut(100);
11343            });
11344
11345            $(document).on('click', '.cl_icon_close:not(.dashboard-visit-date)', function () {
11346                var checkCnt = $(this).attr('data-cnt');
11347                var productNumber = $(this).attr('data-pn');
11348                var seq = ($('#normal-option').is(':checked'))? $(this).attr('data-seq') : 0;
11349                var file = $(this).attr('data-file');
11350                var $parentFile = $(this).parent().parent();
11351                var $closeFile = $(this).parent();
11352                var $this = $(this);
11353                var admin_url = (uadmin == 'um')? '/_admin' : '';
11354
11355                if (productNumber!=='null' && productNumber!==undefined && seq!=='null' && seq!==undefined) {   
11356                    $.ajax({
11357                        url: admin_url + '/shopping/download_list_check',
11358                        type: 'post',
11359                        dataType: 'json',
11360                        data: {'product_number': productNumber, 'option_seq': seq},
11361                        success: function (data) {
11362                            if (data.code == 'fail') {
11363                                alert(data.message);
11364                                return false;
11365                            } else {
11366                                if (confirm(data.message) === true) {
11367                                    $.processON('Deleting File...');
11368                                    $.ajax({
11369                                        type: 'POST',
11370                                        url: admin_url + '/shopping/file_delete',
11371                                        data: { s: file, seq: seq},
11372                                        async: true,
11373                                        success: function(data) {
11374                                            checkError(data);
11375                                            if (checkCnt || checkCnt == 0) {
11376                                                $closeFile.remove();
11377                                                $('.file-name-'+checkCnt).remove();
11378                                                    $this.parent().parent().parent().parent().parent().parent().find('.prod-option-status').text('품절').attr('data-val', 'O');
11379                                                    $this.parent().parent().parent().parent().parent().parent().find('.option-price-status-str').text('품절').attr('data-val', 'O');
11380
11381                                            } else $closeFile.remove();
11382                                            
11383                                            var $fileCnt = $parentFile.find('.file-name');
11384                                            if ($fileCnt.length < 1) {
11385                                                if ($('#none-option-file').length > 0) {
11386                                                    $('.switch-product[value="off"]').prop('checked', true);
11387                                                    $('#status-append').fadeOut(0);
11388                                                    $('#sale-calendar').hide();
11389                                                }
11390                                                $.ajax({
11391                                                    url: admin_url + '/shopping/file_zero',
11392                                                    type: 'post',
11393                                                    data: {'product_number': productNumber}
11394                                                });
11395                                            }
11396
11397                                            $.processOFF();
11398                                        }
11399                                    });
11400                                }
11401                            }
11402                        }
11403                    });
11404                } else {
11405                    $.processON('Deleting File...');
11406                    $.ajax({
11407                        type: 'POST',
11408                        url: admin_url + '/shopping/file_delete',
11409                        data: {s: file},
11410                        async: true,
11411                        success: function(data) {
11412                            checkError(data);
11413                            if (checkCnt || checkCnt == 0) {
11414                                $closeFile.remove();
11415                                $('.file-name-'+checkCnt).remove();
11416                            } else $closeFile.remove();
11417                                            
11418                            var $fileCnt = $parentFile.find('.file-name');
11419                            if ($fileCnt.length < 1) {
11420                                $('.switch-product[value="off"]').prop('checked', true);
11421                                $('#status-append').fadeOut(0);
11422                                $('#sale-calendar').hide();
11423                            }
11424
11425                            $.processOFF();
11426                        }
11427                    });
11428                }
11429            });
11430
11431            $(document).on('click', '.cl_icon_upload02', function () {
11432                var cnt = $(this).attr('data-cnt'),
11433                    fileCnt = 0;
11434                $('#file-box-'+cnt).find('.real-file-name').each(function () {fileCnt++;});
11435                if ($('#none-option-file').find('.real-file-name').length > 0 || $('#none-option-file').find('.none-real-file-name').length > 0) fileCnt++;
11436
11437                if (fileCnt >= 1) {
11438                    // alert('파일은 1개만 업로드 가능합니다.\n여러 파일ì
11438„ 업로드할 경우 압축 파일을 이용해 주세요.');
11439                    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() {
11440                        $(document).on('keydown', function(e) {
11441                            if(e.keyCode == 27) modal.modal('hide');
11442                        });
11443                    });
11444                    return false;
11445                }
11446
11447                $thisUploadCheck = $(this);
11448                $('#product-state').find('input[type="file"]').attr('data-cnt', cnt).click();
11449            });
11450
11451            $(document).on('click', '#upload-file', function (data) {
11452                var sid = (typeof SID == 'undefined') ? property.SID : SID
11453                    uid = '',
11454                    cnt = $(this).attr('data-cnt');
11455                $.uploadON();
11456                var route = (CONFIG_URL) ? '/_admin' : '';
11457                $(this).fileupload({
11458                    url: route + '/shopping/image_upload/type/file/sid/'+sid+'/uid/'+uid,
11459                    dataType: 'json',
11460                    pasteZone: null,
11461                    async: true,
11462                    change: function(e, data) {
11463                        var ext = ['zip', 'txt', 'pdf', 'docx', 'xlsx', 'xls', 'csv', 'ppt', 'pptx', 'gif', 'jpg', 'jpeg', 'png', 'ico', 'webp', 'hwp', 'mp3', 'wav', 'wma', 'mp4'];
11464                        var extAry = data.fileInput[0]['files'][0]['name'].split(".");
11465                        if (ext.indexOf(extAry[extAry.length - 1]) == -1) {
11466                            alert('지원하지 않는 파일 형식이거나 파일이 손상되어 업로드할 수 없습니다. 확인 후 다시 시도해 주시기 바랍니다.');
11467                            return false;
11468                        }
11469
11470                        var maxSize  = 1024 * 1024 * 512;
11471                        var fileSize = data.fileInput[0]['files'][0]['size'];
11472                        if (fileSize > maxSize) {
11473                            alert($.lang[LANG]['editor.upload.max.500'] + $.lang[LANG]['editor.upload.max.2']);
11474                            return false;
11475                        }
11476                    },
11477                    add: function(e, data) {
11478                        $('.uploadModal').show();
11479                        var submit = true, err = '';                        
11480                        var ext = ['zip', 'txt', 'pdf', 'docx', 'xlsx', 'xls', 'csv', 'ppt', 'pptx', 'gif', 'jpg', 'jpeg', 'png', 'ico', 'webp', 'hwp', 'mp3', 'wav', 'wma', 'mp4'];
11481                        var extAry = data.fileInput[0]['files'][0]['name'].toLowerCase().split('.');
11482                        if (ext.indexOf(extAry[extAry.length - 1]) == -1) {
11483                            err = $.lang[LANG]['editor.upload.error.ext'];
11484                            submit = false;
11485                        }
11486
11487                        var maxSize  = 1024 * 1024 * 512;
11488                        var fileSize = data.fileInput[0]['files'][0]['size'];
11489                        if (fileSize > maxSize) {
11490                            err = $.lang[LANG]['editor.upload.max.500'] + $.lang[LANG]['editor.upload.max.2'];
11491                            submit = false;
11492                        }
11493                        $('#loading').css('left','-100%');
11494
11495                        var fileSize = (data.files[0].size/1024/1024).toFixed(1) + 'MB';
11496                        var tpl = '<div class="file">\
11497                            <div class="progress"><div class="progress-bar"></div></div>\
11498                            <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>\
11499                            <div class="preview"></div>\
11500                            </div>';
11501                        data.context = $(tpl).insertBefore($('.uploadModal .upload-content .upload-cancel'));
11502                        data.context.find('.preview').addClass('not_image');
11503                        if(submit) {
11504                            var jqXHR = data.submit();
11505                            UPLOAD++;
11506                        } else {
11507                            data.context.find('.loading').html('<i class="fa fa-times error"></i>');
11508                            data.context.find('.ing').addClass('error').text(err);
11509                        }
11510
11511                        $('.uploadModal .upload-cancel .btn, .uploadModal .upload-close').off('click').on('click', function(e) {
11512                            if(jqXHR != undefined) jqXHR.abort();
11513                            data.context.fadeOut().remove();
11514                            $('.uploadModal #file-upload-progress').css('width','0%');
11515                            $.uploadOFF();
11516                            UPLOAD = 0;
11517                            UPLOADED = 0;
11518                            PROGRESS = 0;
11519                        });
11520
11521                    },
11522                    progress: function(e, data) {
11523                        var rate = (data.bitrate/1024).toFixed(1) + ' kbps';
11524                        var progress = parseInt((data.loaded / data.total) * 100, 10);
11525                        if(typeof data.context != 'undefined') {
11526                            data.context.find('.res').text(data.bitrate);
11527                            data.context.find('.progress-bar').css('width',progress + "%");
11528                            data.context.find('.ing').text(progress + "%");
11529                            data.context.find('.rate').text(rate);
11530                            if(progress == 100) {
11531                                data.context.find('.ing').text($.lang[LANG]['editor.upload.response']);
11532                            }
11533                        }
11534                    },                        
11535                    done: function(e, data) {
11536                        if(typeof data.result.error != 'undefined' && data.result.error) {
11537                            alert(data.result.error);
11538                            $.uploadOFF();
11539                            UPLOAD = 0;
11540                            UPLOADED = 0;
11541                            PROGRESS = 0;
11542                            return;
11543                        }
11544                        var fileSize = data.result.file_size, unit = 'KB';
11545
11546                        if (fileSize >= 1000) {
11547                            fileSize = fileSize / 1000;
11548                            fileSize = fileSize.toFixed(2);
11549                            unit = 'MB';
11550                            if (fileSize >= 1000) {
11551                                fileSize = fileSize / 1000;
11552                                fileSize = fileSize.toFixed(2);
11553                                unit = 'GB';
11554                            }
11555                        }
11556
11557                        var fileName = data.result.client_name, totalByte = 0, strFileName = '';
11558                        if (!fileName) {
11559                            alert('업로드 도중 오류가 발생했습니다. 다시 시도해 주세요.\n지속적으로 문제가 발생한다면 관리자에게 문의해 주세요.');
11560                            $.uploadOFF();
11561                            UPLOAD = 0;
11562                            UPLOADED = 0;
11563                            PROGRESS = 0;
11564                            return false;
11565                        }
11566                        
11567                        var fn_lastIndex = fileName.lastIndexOf('.');
11568                        var file = [fileName.slice(0, fn_lastIndex), fileName.slice(fn_lastIndex + 1)];
11569                        var fileLen = file[0].length;
11570                        for (var i=0;i<fileLen;i++) {
11571                            oneChar = file[0].charAt(i);
11572                            if (escape(oneChar).length > 4) {
11573                                totalByte += 2;
11574                            } else {
11575                                totalByte++;
11576                            }
11577
11578                            if (totalByte > 10) {
11579                                strFileName += '..';
11580                                break;
11581                            }
11582
11583                            strFileName += oneChar;
11584                        }
11585                        strFileName = strFileName+"."+file[(file.length - 1)];
11586                        var splitUrl = data.result.full_path.split('/');
11587                        var fileCnt = $('.file-name').length;
11588
11589                        var file = '<div class="file-name file-name-'+fileCnt+'">\
11590                                        <span class="real-file-name">'+fileName+'</span>\
11591                                        <span class="file-name-detail" title="'+fileName+'">'+strFileName+'</span>\
11592                                        <span class="file-size">'+fileSize+unit+'</span>\
11593                                        <span class="cl-icon cl_icon_close" data-cnt="'+fileCnt+'" data-file="'+splitUrl[8]+'" data-pn="'+closeProductNumber+'"></span>\
11594                                        <span class="file-url">'+data.result.full_path+'</span>\
11595                                    </div>';
11596
11597                        // console.log(file);
11598                        var licnt = $('.prod-option-list > li').length;
11599                        if ($thisUploadCheck.parent().parent().find('#none-option-file').length <= 0) {
11600                            $thisUploadCheck.parent().parent().parent().parent().parent().find('.prod-option-status').text('판매').attr('data-val', 'S');
11601                            $thisUploadCheck.parent().parent().parent().parent().parent().find('.option-price-status-str').text('판매').attr('data-val', 'S');
11602                        }
11603                        if ($('#normal-option').is(':checked') === false) {
11604                            var noneFile = '<div class="none-file-name">\
11605                                            <span class="none-real-file-name">'+fileName+'</span>\
11606                                            <span class="none-file-name-detail" title="'+fileName+'">'+strFileName+'</span>\
11607                                            <span class="none-file-size">'+fileSize+unit+'</span>\
11608                                            <span class="cl-icon cl_icon_close" data-cnt="'+fileCnt+'" data-file="'+splitUrl[8]+'" data-pn="'+closeProductNumber+'"></span>\
11609                                            <span class="none-file-url">'+data.result.full_path+'</span>\
11610                                        </div>';
11611                            // console.log('file-box-cnt: '+cnt);
11612
11613                            $('[id^="file-box-"]:first').append(file);
11614                            $('#none-option-file').append(noneFile);
11615                        } else {
11616                            $('#file-box-'+cnt).append(file);
11617                        }
11618                        // console.log(noneFile);
11619                        progress1 = parseInt(UPLOADED / UPLOAD * 100,10);
11620                        PROGRESS = progress1 + progress2;
11621                        $('.file-upload-progress .progress-bar').css({
11622                            'width' : PROGRESS + '%',
11623                            'text-align' : 'right',
11624                            'padding-right' : '5px'
11625                        }).text(PROGRESS + '% ');
11626
11627                        UPLOADED++;
11628                        if(UPLOADED) {
11629                            //$.uploadON(UPLOADED + " / " + UPLOAD + "<br>images creating...");
11630                            if(UPLOAD==UPLOADED) {
11631                                UPLOAD = 0;
11632                                UPLOADED = 0;
11633                                PROGRESS = 0;
11634
11635                                $('.file-upload-progress .progress-bar').css({
11636                                    'width' :  PROGRESS + '%',
11637                                    'padding-right' : '0px'
11638                                }).text('');
11639                            }
11640                        }
11641
11642                        $.uploadOFF();
11643                    },
11644                    progressall: function(e, data) {
11645                        var total = (data.total/1024/1024).toFixed(1) + 'MB';
11646                        $('.uploadModal .info1').text($.lang[LANG]['editor.upload.size.total'] + total);
11647                        $('.uploadModal .info2').text((UPLOADED+1) + ' / ' + UPLOAD.toString());
11648                        var progress = parseInt((data.loaded / data.total) * 100, 10);
11649                        $('.file-upload-progress .progress-bar').css('width',progress + "%");
11650                    },
11651                    start : function(e, data) {
11652                        $('.uploadModal .upload-header h1').text($.lang[LANG]['editor.upload.title.2']);
11653                        $('.uploadModal .upload-content .upload-cancel .btn-default').text($.lang[LANG]['config.cancel']);
11654                        progress1 = 0; progress2 = 0; PROGRESS = 0;
11655                    },
11656                    dragover : function(e, data) {
11657                        e.preventDefault();
11658                    }
11659                }).prop('disabled', !$.support.fileInput)
11660                    .parent().addClass($.support.fileInput ? undefined : 'disabled');
11661            });
11662
11663            $(document).on('keyup', '#download-date', function () {
11664                var $this_val = strReplace($(this).val(), ',', '');
11665                if ($this_val != '') {
11666                    if ($this_val > 90) {
11667                        // alert('기간 제한은 최소 1일에서 최대 90일입니다.');
11668                        $(this).blur();
11669                        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() {
11670                            $(document).on('keydown', function(e) {
11671                                if(e.keyCode == 27) modal.modal('hide');
11672                            });
11673                        });
11674                        $(this).val(90);
11675                        return false;
11676                    }
11677
11678                    if ($this_val < 1) {
11679                        // alert('기간 제한은 최소 1일에서 최대 90일입니다.');
11680                        $(this).blur();
11681                        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() {
11682                            $(document).on('keydown', function(e) {
11683                                if(e.keyCode == 27) modal.modal('hide');
11684                            });
11685                        });
11686                        $(this).val(1);
11687                        return false;
11688                    }
11689                }
11690            });
11691
11692            $(document).on('focusout', '#download-date', function () {
11693                var $this_val = strReplace($(this).val(), ',', '');
11694                if ($this_val == '') {
11695                    // alert('기간 제한은 최소 1일에서 최대 90일입니다.');
11696                    $(this).blur();
11697                    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() {
11698                        $(document).on('keydown', function(e) {
11699                            if(e.keyCode == 27) modal.modal('hide');
11700                        });
11701                    });
11702                    $(this).val(1);
11703                    return false;
11704                }
11705            });
11706
11707            $(document).on('keyup', '#download-count', function () {
11708                var $this_val = strReplace($(this).val(), ',', '');
11709                if ($this_val != '') {
11710                    if ($this_val > 10) {
11711                        // alert('다운로드 횟수는 최소 1회에서 최대 10회입니다.');
11712                        $(this).blur();
11713                        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() {
11714                            $(document).on('keydown', function(e) {
11715                                if(e.keyCode == 27) modal.modal('hide');
11716                            });
11717                        });
11718                        $(this).val(10);
11719                        return false;
11720                    }
11721
11722                    if ($this_val < 1) {
11723                        // alert('다운로드 횟수는 최소 1회에서 최대 10회입니다.');
11724                        $(this).blur();
11725                        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() {
11726                            $(document).on('keydown', function(e) {
11727                                if(e.keyCode == 27) modal.modal('hide');
11728                            });
11729                        });
11730                        $(this).val(1);
11731                        return false;
11732                    }
11733                }
11734            });
11735
11736            $(document).on('focusout', '#download-count', function () {
11737                var $this_val = strReplace($(this).val(), ',', '');
11738                if ($this_val == '') {
11739                    // alert('다운로드 횟수는 최소 1회에서 최대 10회입니다.');
11740                    $(this).blur();
11741                    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() {
11742                        $(document).on('keydown', function(e) {
11743                            if(e.keyCode == 27) modal.modal('hide');
11744                        });
11745                    });
11746                    $(this).val(1);
11747                    return false;
11748                }
11749            });
11750
11751            $(document).on('click','.option-price-status-str', function(e) {
11752                e.stopPropagation();
11753                var check = $(this).attr('data-val');
11754                if($(this).hasClass('open')) {
11755                    $(this).next().slideUp(200, function() {
11756                        $('.option-price-status-str').removeClass('open');    
11757                    }); 
11758                } else {
11759                    $(this).addClass('open');
11760                    $(this).next().find('li').removeClass('active');
11761                    $(this).next().find('li[data-val="' + check + '"]').addClass('active');
11762                    $(this).next().slideDown(200); 
11763                }
11764
11765            });
11766
11767            // $(document).on('change', '.option-require-str input', function(){
11768            //     var $option_li = $(this).closest('li');
11769            //     if($(this).is(':checked')) {
11770            //         $option_li.find('.option-require-str').attr('data-val', 'TR');
11771            //         $option_li.find('.prod-option-require').attr('data-val', 'TR');
11772            //     } else {
11773            //         $option_li.find('.option-require-str').attr('data-val', 'T');
11774            //         $option_li.find('.prod-option-require').attr('data-val', 'T');
11775            //     }
11776            // });
11777
11778            $(document).on('click', '.option-price-status-select li', function(e) {
11779                e.stopPropagation();
11780                $('.option-price-status-select li').removeClass('active');
11781                $(this).addClass('active');
11782                var str = $(this).text(),
11783                    val = $(this).attr('data-val');
11784
11785                $(this).parents('.edit-option-select').find('.option-price-status-str').text(str).attr('data-val',val).removeClass('open');
11786                $(this).parents('li').find('.prod-option-status').text(str).attr('data-val',val);
11787
11788                $(this).parent().slideUp(200);
11789            });
11790
11791            $(document).on('change', '.option-delivery-template-select input[name="delivery_template_seq"]', function(e) {
11792                e.stopPropagation();
11793                var str = $(this).parent('li').find('label').html(),
11794                    val = $(this).val();
11795
11796                $('#delivery_template_seq').html(str);
11797
11798                if($(this).parent('li').data('weight') == true) {
11799                    $('.product-weight').show();
11800                } else {
11801                    $('.product-weight').hide();
11802                    $('#product_weight').val('');
11803                }
11804                $('.delivery-template-list').slideUp(200);
11805                $('#delivery_template_seq').removeClass('open');
11806                $('.prod-modal').scrollTop($('.prod-modal').scrollTop() + $('.form-wrap.delivery-template').offset().top - $('.prod-modal .prod-header').outerHeight())
11807            });
11808
11809            $(document).on('click','.edit-option-delete', function(e) { 
11810                var $option = $(this),
11811                    // seq = ($('#normal-option').is(':checked'))? $(this).attr('data-seq') : 0,
11812                    seq = $(this).attr('data-seq'),
11813                    sid = (typeof SID == 'undefined') ? property.SID : SID;
11814                    option_mode = $option.closest('.prod-option').attr('data-option_mode'),
11815                    fileName = $option.closest('li').find('.real-file-name').text();
11816                var status = true;
11817                var productNumber = $('#prod-no').val();
11818                var admin_url = (uadmin == 'um')? '/_admin' : '';
11819
11820                if (option_mode == "normal" && seq!==undefined && productNumber && fileName) {
11821                    $.ajax({
11822                        url: admin_url + '/shopping/download_list_check',
11823                        type: 'post',
11824                        dataType: 'json',
11825                        data: {'product_number': productNumber, 'option_seq': seq},
11826                        success: function (data) {
11827                            if (data.code == 'fail') {
11828                                alert(data.message);
11829                                status = false;
11830                                return false;
11831                            }
11832                        }
11833                    });
11834                }
11835                
11836                if (status == false) return false;
11837                var modal = $(this).showModalFlat($.lang[LANG]['config.information'], '선택한 옵션을 삭제하시겠습니까?', true, true, function() {
11838                    if(typeof seq != "undefined" || seq) {
11839                        var deleted = ($('#options-delete-list').val()) ? $('#options-delete-list').val().split(",") : [];
11840                            deleted.push(seq);
11841                        // var deleted_items = [...new Set(deleted)];
11842                        var deleted_items = deleted.filter(onlyUnique);
11843                        $('#options-delete-list').val(deleted_items.join(","));
11844                        $option.parents('li').remove(); 
11845
11846                        var liTotal = 0;
11847                        $('.prod-option-list > li').each(function () { liTotal++; });
11848                        if (liTotal < 2) $('.plus-price').addClass('hide');
11849                    } else {
11850                        var optionMode = $option.closest('.prod-option').attr('data-option_mode');
11851                        $option.parents('li').remove(); 
11852
11853                        var liTotal = 0;
11854                        $('.prod-option-list > li').each(function () { liTotal++; });
11855                        if (liTotal < 2) $('.prod-str-price').text('');
11856                    }
11857
11858                    if($('.switch-quantity').is(":checked") == true) {
11859                        if($('#normal-option').is(':checked') === true) {
11860                            // $('#prod-quantity').attr('readonly','true').removeClass('hide').attr('placeholder','옵션에서 재고 관리');
11861                            $('.quantity-label').addClass('on');
11862                            $('.plus-quantity').removeClass('hide');
11863                        } else if($('#normal-option').is(':checked') === false && $('#additional-option').is(':checked') === true) {
11864                            $('.quantity-label').removeClass('on');
11865                            $('#prod-quantity').removeAttr('readonly').removeClass('hide');
11866                            $('.plus-quantity').removeClass('hide');
11867                        } else {
11868                            $('.quantity-label').removeClass('on');
11869                            $('#prod-quantity').removeAttr('readonly').removeClass('hide');
11870                            $('.plus-quantity').addClass('hide');
11871                        }
11872                    } else {
11873                        $('.quantity-label').removeClass('on');
11874                        $('.switch-quantity').parents('.form-wrap').addClass('disabled');
11875                        $('#prod-quantity').addClass('hide');
11876                        $('.prod-option-quantity, .prod-plus-quantity, .edit-option-quantity').hide();
11877                        $('.plus-quantity').addClass('hide');
11878                    }
11879
11880                    // var normalCnt = $('.prod-option[data-option_mode="normal"] .prod-option-list > li').length;
11881                    if ($('#normal-option').is(':checked') === false) {
11882                        var html = '\
11883                        <div class="product-upload">\
11884                            <div class="title">파일 업로드</div>\
11885                            <div class="download-contents">\
11886                                <span class="cl_icon_upload02" data-cnt="'+fileUpdateCnt+'">업로드</span>\
11887                                <div id="none-option-file"></div>\
11888                            </div>\
11889                        </div>\
11890                        ';
11891
11892                        fileUpdateCnt++;
11893
11894                        $('#add-upload-check').prepend(html);
11895                        if ($('#none-option-file').length > 0) {
11896                            $('.switch-product[value="off"]').prop('checked', true);
11897                            $('#status-append').fadeOut(0);
11898                            $('#sale-calendar').hide();
11899                        }
11900                    }
11901
11902                    if(LUX && (productNumber < 0 || !productNumber || productNumber >= 1000000000) && option_mode == 'normal' && $('.prod-option[data-option_mode="'+option_mode+'"] .prod-option-list > li').length == 1) {
11903                        addProductOption('normal');    
11904                    }
11905
11906                    var cnt = $('.prod-option[data-option_mode="'+option_mode+'"] .prod-option-list > li').length;
11907                    if(option_mode == 'normal') {
11908                        if(cnt == 1) {
11909                            $('.prod-option[data-option_mode="normal"]').addClass('hide');
11910                            $('#normal-option').prop('checked', false);
11911                        }
11912                    } else {
11913                        if(cnt == 0) {
11914                            $('.prod-option[data-option_mode="'+option_mode+'"]').addClass('hide');
11915                            $('#'+option_mode+'-option').prop('checked', false);
11916                        }
11917                        if(option_mode == 'text' && cnt < 7) {
11918                            $('.prod-option[data-option_mode="text"] > .prod-option-add').removeClass('disabled');
11919                        }
11920                    }
11921
11922                    if($('.prod-option-tab .prod-option.hide').length == 3) {
11923                        $('.prod-option-tab').addClass('hide');
11924                    }
11925                    if($('.prod-option-edit').length <= 2) {
11926                        $('.edit-option-delete').addClass('hide');
11927                    } else {
11928                        $('.edit-option-delete').removeClass('hide');
11929                    }
11930
11931                    modal.modal('hide');
11932                },'cancel', 'ok', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0');            
11933            });
11934            $(document).on('click','.category-lists li', function(e) { 
11935                e.stopPropagation();
11936                $(this).toggleClass('active'); 
11937                var selected = $('.category-lists li.active').map(function() {
11938                    return $(this).text();
11939                }).get().join(', ');
11940                selected = (selected.length==0) ? '카테고리를 선택하세요' : selected;
11941                $('#prod-category-text').text(selected);
11942            });
11943            $(document).on('click','.category-wrap', function(e) { 
11944                var txt = $(this).find('.category-text').text(),
11945                    selected = $.map(txt.split(","), $.trim);
11946                
11947                $.each($('.category-lists li'), function(i,v) {
11948                    var s = $.trim($(this).text());
11949                    if(selected.indexOf(s) > -1) {
11950                        $(this).addClass('active');
11951                    }
11952                });
11953                // $('.category-lists').slideToggle(); 
11954            });
11955            /*--------- move -------------*/
11956            $(document).on('click','.category-title', function() {
11957                var submit = true;
11958                if($('.category-move.delete').length) {
11959                    $.each($('.category-move.delete'), function(i,v) {
11960                        $(this).removeClass('delete').html($.category.moveHandle());
11961                        var txt = $(this).parents('li').find('.category-input').val();
11962                        if(txt.length == 0) {
11963                            submit = false;
11964                            return true;
11965                        }
11966                        $(this).parents('li').find('.category-title').text(txt).removeClass('hide');
11967                    });
11968                }
11969
11970                if(submit) {
11971                    var v = $(this).text();
11972                    if(!$(this).hasClass('hide')) {
11973                        $(this).addClass('hide');
11974                        $(this).siblings('.form-wrap').find('.category-input').val(v).focus();
11975                    }
11976                    $(this).parents('li').find('.category-move').addClass('delete').html($.category.deleteHandle());
11977                }
11978            });
11979            $(document).on('focus', '.category-input', function(e) {
11980                var submit = true;
11981                if($('.category-move.delete').length) {
11982                    $.each($('.category-move.delete'), function(i,v) {
11983                        $(this).removeClass('delete').html($.category.moveHandle());
11984                        var txt = $(this).parents('li').find('.category-input').val();
11985                        if(txt.length == 0) {
11986                            submit = false;
11987                            return true;
11988                        }
11989                        $(this).parents('li').find('.category-title').text(txt).removeClass('hide');
11990                    });
11991                }
11992
11993                $(this).parents('li').find('.category-move').addClass('delete').html($.category.deleteHandle());
11994            });
11995            $(document).on('keyup', '.category-input', function(e) {
11996                var keyCode = e.keyCode,
11997                    search = $(this).val().trim(),
11998                    v = $(this).val().trim();
11999
12000                $(this).parents('.form-wrap').siblings('.category-title').text(v);
12001                if(checkEmojis(v)) {
12002                    e.preventDefault();
12003                    errorEmojisModal('10002');
12004                    return false;
12005                }
12006                if(v.length==0) return false;
12007                if(keyCode == 13) {
12008                    if($.category.check()) {
12009                        // alert('카테고리명 중복입니다');
12010                        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() {
12011                            $(document).on('keydown', function(e) {
12012                                if(e.keyCode == 27) modal.modal('hide');
12013                            });
12014                        });
12015                        return false;
12016                    }
12017                    $(this).parents('.form-wrap').siblings('.category-title').removeClass('hide');
12018                    $(this).parents('.form-wrap').siblings('.category-move').removeClass('delete').html($.category.moveHandle());
12019                }
12020            });
12021            $(document).on('blur', '.category-input', function(e) {
12022                if(checkEmojis($(this).val().trim())) {
12023                    e.preventDefault();
12024                    var focus_input = $(this);
12025                    errorEmojisModal('10002');
12026                }
12027            });
12028
12029            $(document).on('click','.item-add', function() {
12030                if($(this).closest('.category-edit').find('li:not(.item-add) .category-title.hide').length > 0) {
12031                    $(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();
12032                    return false;
12033                }
12034
12035                $('.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>'));
12036                $('.category-input:last-child').focus();
12037            });
12038            $(document).on('click','.category-move.delete', function(e) {
12039                if($(this).closest('.category-edit').children('li:not(.item-add)').length <= 1) {
12040                    $(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() {
12041                        $('.modal-dialog.category-error').closest('.flat-modal').next('.modal-backdrop').attr('style','z-index: 10001!important;');
12042                        $('.modal-dialog.category-error').closest('.modal').attr('style','display: block; z-index: 10002;'); 
12043                    });
12044                    return false;
12045                }
12046
12047                ($.category.delete).push($(this).next().text());
12048                $(this).parents('li').find('.category-input').val('');
12049                $(this).parents('li').remove();
12050            });
12051            $(document).on('click','.prod-button .modal-close', function(e) { $.products.close(); });
12052            $(document).on('click','.category-modal .cl-category-modal-ok', function(e) {
12053                var change = [];
12054                var del = $.category.delete;
12055                var categoryRegexp =  /[\[\]|,'"<>{}\/\\:;%&@$!*?\^]/;
12056                var checkRegexp = false;
12057                var checkMin = false;
12058                var checkMax = false;
12059
12060                var category_lists = $('.category-edit .category-title').map(function(){
12061                    var org = $(this).attr('data-org'),
12062                        val = $(this).text().trim();
12063
12064                    if(val.length < 1) checkMin = true;
12065                    if(val.length > 20) checkMax = true;
12066
12067                    if(org != val) change.push(org + '|' + val);
12068                    if(val != '') { 
12069                        if(categoryRegexp.test(val)) checkRegexp = true;
12070                        
12071                        return val;
12072                    }
12073                }).get();
12074
12075                var error_str = '';
12076                if(checkMin)            error_str = $.lang[LANG]['board.enter-min-chars.1'];
12077                else if(checkMax)       error_str = $.lang[LANG]['board.enter-max-chars'];
12078                else if(checkRegexp)    error_str = $.lang[LANG]['board.allowed-chars'];
12079
12080                if(error_str.length > 0) {
12081                    $(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() {
12082                        $('.modal-dialog.category-error').closest('.flat-modal').next('.modal-backdrop').attr('style','z-index: 10001!important;');
12083                        $('.modal-dialog.category-error').closest('.modal').attr('style','display: block; z-index: 10002;'); 
12084                    });
12085                    return false;
12086                }
12087
12088                if(checkEmojis(category_lists.toString())) {
12089                    e.preventDefault();
12090                    errorEmojisModal('10002');
12091                    return false;
12092                }
12093
12094                if($.category.check()) {
12095                    // alert('카테고리명 중복입니다');
12096                    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() {
12097                        $(document).on('keydown', function(e) {
12098                            if(e.keyCode == 27) modal.modal('hide');
12099                        });
12100                    });
12101                    return false;
12102                }
12103
12104                var $category = $('#prod-category-text');
12105                var cate = ($category.text().trim()) ? $category.text().trim().split(', ') : [];
12106
12107                if(cate.length && del.length) {
12108                    $.each(del, function(i,v) {
12109                        var idx = cate.indexOf(v);
12110                        if(idx > -1) cate.splice(idx, 1)
12111                    });
12112                    $category.text(cate.join(', '));
12113                }
12114
12115                if(cate.length && change.length) {
12116                    $.each(change, function(i,v) {
12117                        var s = v.split('|');
12118                        var idx = cate.indexOf(s[0]);
12119                        if(idx > -1) cate[idx] = s[1];
12120                    });
12121                    $category.text(cate.join(', '));
12122                }
12123                if($category.text() == '') $category.text('카테고리를 선택하세요');
12124                
12125                var pid = ($('.prod-modal').length) ? $('#prod-pid').val() : $('.gallery-ctrl-category').attr('data-pid'),
12126                    gid = $('#prod-no').val();
12127
12128                $.post('/template/gallery/category', { sid : SID, s : category_lists, mode : 'block', seq : pid, gid : gid, change : change, del : del }, function(r) {
12129                    if(typeof r.error !='undefined' && r.error) {
12130                        alert(r.error);
12131                        return false;
12132                    }
12133
12134                    $('#prod-category-lists ul, .toolbar-category .item-submenu').empty();
12135                    $('.gallery-category li.category-text').remove();
12136                    var s = '';
12137                    $.each(category_lists, function(i,v) {
12138                        var li_str = '<li>' + v + '</li>',
12139                            li_str2 = '<li class="category-text">' + v + '</li>';
12140                        s = s + li_str;
12141                        $('#prod-category-lists ul').append(li_str);
12142                        $('.toolbar-category .item-submenu').append(li_str);
12143                        $('.gallery-category .gallery-category-onoff').before(li_str2);
12144                    });
12145                    $.gallery.cates = s;
12146                    $('#prod-category, .gallery-ctrl-category, .gallery-modal').attr('data-category',category_lists.toString());
12147
12148
12149                    $category = $('#prod-category-text');
12150                    var cate = ($category.text().trim()) ? $category.text().trim().split(', ') : [];
12151                    $.each($('.category-lists li'), function(i,v) {
12152                        // IE ERROR_includes__H.20210603
12153                        // if(cate.includes($(this).text())) $(this).addClass('active');
12154                        if($.inArray($(this).text(),cate) > -1) $(this).addClass('active');
12155                    });
12156                    $.category.close();
12157                    if($('.gallery-modal').hasClass('shopping') && $('.prod-modal.cl-p-modal').length == 0) $.gallery.show($.gallery.block_id,1,$.gallery.category);
12158                    $.gallery.update = true;
12159
12160                }, 'json');
12161            });
12162        },
12163        open : function(s) {
12164            if($('.cl-category-modal-backdrop').length >0) $('.cl-category-modal-backdrop').remove();
12165            var text = (typeof s != 'string') ? [] : s.split(',');
12166            var $backdrop = $('<div class="cl-category-modal-backdrop"></div>'),
12167                $title = $('<h1 class="category-modal-title">' + $.lang[LANG]['editor.block.gallery.category.edit.title'] + '</h1>'),
12168                $modal = $('<div class="cl-category-modal cl-p-modal category-modal"></div>'),
12169                $lists = $('<ul class="category-edit"></ul>'),
12170                $item_add = $('<li class="item-add"></li>');
12171                $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>');
12172
12173            $.each(text, function(i,v) {
12174                var item = "\
12175                    <li>\
12176                        <div class='form-wrap'>\
12177                            <div class='form-group'>\
12178                                <input type='text' class='category-input' required='required' value='" + v + "'>\
12179                                <label for='input' class='control-label'>"+ $.lang[LANG]['editor.block.gallery.category.edit.name'] +"</label><i class='bar'></i>\
12180                            </div>\
12181                        </div>\
12182                        <div class='category-move'>" + $.category.moveHandle() + "</div>\
12183                        <div class='category-title' data-org='" + v + "'>" + v + "</div>\
12184                    </li>\
12185                ";
12186                $lists.append($(item));
12187            });
12188
12189            // $('.category-edit').append($(item));
12190
12191            $lists.append($item_add);
12192            $modal.append($title).append($lists).append($modal_footer);
12193            $backdrop.append($modal);
12194            $('body').append($backdrop);
12195            $backdrop.fadeIn(500);
12196            $('.category-edit').sortable({
12197                handle : ".category-move .cl-sort-handle"
12198            });
12199        },
12200        close : function() {
12201            $('.cl-category-modal-backdrop').fadeOut(500, function() { $(this).remove(); });
12202        },
12203        check : function() {
12204            var category = $.category.list(),
12205                // set_category = new Set(category);
12206                set_category = category.filter(onlyUnique);
12207
12208            // IE ERROR (filter)
12209            // check = category.filter((s => v => s.has(v) || !s.add(v))(new Set)); 
12210
12211            // 변경 없이 저장시 중복 체크 이슈 생김
12212            // return (category.length !== set_category.size) ? true : false;
12213            return (category.toString() !== set_category.toString()) ? true : false;
12214        },
12215        list : function() {
12216            var category_lists = $('.category-edit .category-title').map(function(){
12217                var org = $(this).attr('data-org'),
12218                    val = $(this).text().trim();
12219                if($(this).text().trim()) {
12220                    return $(this).text().trim();
12221                }
12222            }).get();
12223            return category_lists;            
12224        }
12225    }
12226
12227
12228    $.shoppingmall = {        
12229        orderStatusDetailsModal: function(sid, pnum, onum, ognum, kind) {
12230            if(typeof sid == "undefined" || typeof pnum == "undefined" || typeof onum == "undefined" || typeof kind == "undefined") {
12231                alert('정보가 올바르지 않습니다');
12232                return false;
12233            }
12234
12235            $.post('/_check_order', { sid:sid, pnum:pnum, onum:onum, ognum:ognum,mode:'kind/'+kind }, function(data) {
12236
12237                if(typeof data.error != "undefined" && data.error) {
12238                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'close');
12239                    return false;
12240                }
12241                var c_data = data.r,
12242                    status = c_data.odata.reason_d_status,
12243                    kind_str = c_data.odata.kind_str,
12244                    product_status_str = c_data.odata.product_status_str,
12245                    payClass = c_data.odata.class;
12246                   
12247                    option_name = (typeof c_data.pdata.option != "undefined" && c_data.pdata.option) ? c_data.pdata.option : '',
12248                    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>' : '',
12249
12250                    // option_str = (option_name) ? '<br><span class="osd-gray">옵션: '+option_name+'</span>' : '',
12251                    now_status_html = '',
12252                    delivery_info = c_data.pay_info.delivery,
12253                    option_title = (c_data.pdata.option_type == 'A') ? '추가옵션: ' + (c_data.pdata.option_group ? c_data.pdata.option_group + ': ' : '') : '옵션: ';
12254                if(option_name) {
12255                    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>';
12256                } else {
12257                    option_str = (c_data.pdata.option_text_str)? '<br><span class="osd-gray">' + option_title + c_data.pdata.option_text_str + '</span>' : '';
12258                }
12259                if(etc_str) option_str += etc_str;
12260                
12261                if(status.length > 1) {
12262                    var now_title = c_data.odata.product_status_str.replace(/ /g,'').replace('거부재발송','거부'),
12263                        now_msg = (status.indexOf('W') > -1) ? c_data.odata.h_msg : 
12264
12265                        c_data.odata.adm_msg,
12266                        now_msg_html = (jQuery.inArray(status, ['CY','EY','RY']) > -1) ? '' : '\
12267                                <tr>\
12268                                    <td class="label">' + now_title + '사유</td>\
12269                                    <td>' + now_msg + '</td>\
12270                                </tr>\
12271                        ',
12272                        now_msg_date = (jQuery.inArray(status, ['EW','RW']) > -1) ? c_data.odata.h_date : c_data.odata.adm_date;
12273
12274                    now_status_html = '\
12275                        <h6 class="osd-title">' + now_title + '정보</h6>\
12276                        <table class="osd-table">\
12277                            <tbody>\
12278                                <tr>\
12279                                    <td class="label">' + now_title + '일자</td>\
12280                                    <td>' + now_msg_date + '</td>\
12281                                </tr>\
12282                    ';
12283                    if(status != 'CY' && status != 'RY') {
12284                        $.each(delivery_info, function(i, v){
12285                            delivery_info[i] = (v===null)? '':v;
12286                        });
12287                        if(status == 'RD' || status == 'ED' || status == 'EY'|| status == 'ES') {
12288                            if(delivery_info.new_postcode !== '') {
12289                                now_status_html+= '<tr>\
12290                                            <td class="label">배송지1</td>\
12291                                            <td>' + delivery_info.new_postcode + ' ' + delivery_info.new_addr + ' ' + delivery_info.new_addr2 + '</td>\
12292                                        </tr>\
12293                                ';
12294                            }
12295
12296                            if(delivery_info.new_delivery_type) {
12297                                now_status_html += '\
12298                                    <tr>\
12299                                        <td class="label">배송수단</td>\
12300                                        <td>' + $.lang[LANG]['shopping.delivery.template.delivery_type.' + delivery_info.new_delivery_type.toLowerCase()] + '</td>\
12301                                    </tr>\
12302                                '
12303                            }
12304
12305                            if(delivery_info.new_delivery_company) {
12306                                now_status_html+= '\
12307                                        <tr>\
12308                                            <td class="label">배송회사</td>\
12309                                            <td>' + delivery_info.new_delivery_str + '</td>\
12310                                        </tr>';
12311                            }
12312                            if(delivery_info.new_delivery_str != '자가배송' && delivery_info.new_delivery_number != '') {
12313                                now_status_html+= '<tr>\
12314                                            <td class="label">송장번호</td>\
12315                                            <td>' + delivery_info.new_delivery_number + '</td>\
12316                                        </tr>';
12317                            }
12318                        }
12319                        
12320                        now_status_html += now_msg_html;
12321                    }
12322                    now_status_html+= '\
12323                            </tbody>\
12324                        </table>\
12325                    ';
12326                }
12327
12328                var r_requests = (c_data.odata.requests != '')? c_data.odata.requests : '-';
12329                var modal_str = '\
12330                    <div class="osd-body">\
12331                        \
12332                        <h6 class="osd-title">기본정보</h6>\
12333                        <table class="osd-table">\
12334                            <tbody>\
12335                                <tr>\
12336                                    <td class="label">
12336주문번호</td>\
12337                                    <td>' + ognum + '</td>\
12338                                </tr>\
12339                                <tr>\
12340                                    <td class="label">상품명</td>\
12341                                    <td>' + c_data.pdata.name + option_str + '</td>\
12342                                </tr>\
12343                                <tr>\
12344                                    <td class="label">주문수량</td>\
12345                                    <td>' + c_data.odata.quantity + '개</td>\
12346                                </tr>';
12347                                modal_str += '<tr>\
12348                                        <td class="label">'+kind_str+'상태</td>\
12349                                        <td>' + product_status_str + '</td>\
12350                                    </tr>';
12351                                if ((status.indexOf('R') !== -1 || (c_data.odata.p_status != 'W' && status.indexOf('C') !== -1)) && (payClass == '무통장 입금' || payClass == '가상계좌')) {
12352                                    modal_str += '<tr>\
12353                                        <td class="label">환불계좌</td>\
12354                                        <td>' + c_data.odata.return_bank + ' ' + c_data.odata.return_bank_number + '<br>' + c_data.odata.return_bank_name + '</td>\
12355                                    </tr>';
12356                                }
12357                            modal_str += '</tbody>\
12358                        </table>\
12359                        \
12360                        ' + now_status_html +'\
12361                        \
12362                        <h6 class="osd-title">' + kind_str + '요청정보</h6>\
12363                        <table class="osd-table">\
12364                            <tbody>\
12365                                <tr>\
12366                                    <td class="label">' + kind_str + '요청일자</td>\
12367                                    <td>' + c_data.odata.date + '</td>\
12368                                </tr>\
12369                                <tr>\
12370                                    <td class="label">' + kind_str + '요청사유</td>\
12371                                    <td>' + c_data.odata.reason + '</td>\
12372                                </tr>\
12373                                <tr>\
12374                                    <td class="label">상세사유</td>\
12375                                    <td>' + r_requests + '</td>\
12376                                </tr>\
12377                            </tbody>\
12378                        </table>\
12379                        \
12380                    </div>\
12381                    \
12382                    ';
12383
12384                /*
12385                var c_data = data.r,
12386                    status = c_data.odata.d_status,
12387                    kind_str = c_data.odata.kind_str,
12388                    product_status_str = c_data.odata.product_status_str,
12389                    option_name = (typeof c_data.pdata.option != "undefined" && c_data.pdata.option) ? c_data.pdata.option : '',
12390                    option_str = (option_name) ? '<br><span>옵션: '+option_name+'</span>' : '',
12391                    status_str = '',
12392                    response_str = '',
12393                    request_str = '\
12394                        <table class="osd-table">\
12395                            <tbody>\
12396                                <tr>\
12397                                    <td class="label">' + kind_str + '요청사유</td>\
12398                                    <td>' + c_data.odata.reason + '</td>\
12399                                </tr>\
12400                                <tr>\
12401                                    <td class="label">상세사유</td>\
12402                                    <td>' + c_data.odata.requests + '</td>\
12403                                </tr>\
12404                            </tbody>\
12405                        </table>\
12406                    ';
12407
12408                if(jQuery.inArray(status, ['CN','CY','EN','EW','RN','RW']) > -1) {
12409                    var status_str = (status.indexOf('W') > -1) ? c_data.odata.h_msg : c_data.odata.adm_msg,
12410                        status_msg = (jQuery.inArray(status, ['CY']) > -1) ? '' : '\
12411                                <tr>\
12412                                    <td class="label">' + c_data.odata.product_status_str.replace(/ /g,'') + '사유</td>\
12413                                    <td>' + status_str + '</td>\
12414                                </tr>\
12415                    ',
12416                        status_date = (jQuery.inArray(status, ['EW','RW']) > -1) ? c_data.odata.h_date : c_data.odata.adm_date;
12417
12418                    status_str = '\
12419                        <h6 class="osd-title">' + c_data.odata.product_status_str.replace(/ /g,'') + '정보</h6>\
12420                        <table class="osd-table">\
12421                            <tbody>\
12422                                <tr>\
12423                                    <td class="label">' + c_data.odata.product_status_str.replace(/ /g,'') + '일자</td>\
12424                                    <td>' + status_date + '</td>\
12425                                </tr>\
12426                                ' + status_msg + '\
12427                            </tbody>\
12428                        </table>\
12429                    ';
12430                }
12431
12432                if(jQuery.inArray(status, ['EN', 'EW', 'RN', 'RW']) > -1) {
12433                    response_str = '\
12434                                <tr>\
12435                                    <td class="label">' + kind_str + ' ' + c_data.odata.h_kind_str + '사유</td>\
12436                                    <td>' + c_data.odata.h_reason + '</td>\
12437                                </tr>\
12438                                <tr>\
12439                                    <td class="label">상세사유</td>\
12440                                    <td>' + c_data.odata.h_msg + '</td>\
12441                                </tr>\
12442                    ';
12443                }
12444
12445                var modal_str = '\
12446                    <div class="osd-body">\
12447                        \
12448                        <h6 class="osd-title">기본정보</h6>\
12449                        <table class="osd-table">\
12450                            <tbody>\
12451                                <tr>\
12452                                    <td class="label">
12452주문번호</td>\
12453                                    <td>' + onum + '</td>\
12454                                </tr>\
12455                                <tr>\
12456                                    <td class="label">상품명</td>\
12457                                    <td>' + c_data.pdata.name + option_str + '</td>\
12458                                </tr>\
12459                                <tr>\
12460                                    <td class="label">주문수량</td>\
12461                                    <td>' + c_data.odata.quantity + '개</td>\
12462                                </tr>\
12463                                <tr>\
12464                                    <td class="label">' + kind_str + '요청일자</td>\
12465                                    <td>' + c_data.odata.date + '</td>\
12466                                </tr>\
12467                                <tr>\
12468                                    <td class="label">진행상태</td>\
12469                                    <td>' + product_status_str + '</td>\
12470                                </tr>\
12471                                ' + response_str + '\
12472                            </tbody>\
12473                        </table>\
12474                        \
12475                        ' + status_str +'\
12476                        \
12477                        <h6 class="osd-title">' + kind_str + '요청정보</h6>\
12478                        ' + request_str +'\
12479                        \
12480                    </div>\
12481                    \
12482                    ';
12483
12484                */
12485                var osdModal = $(this).showModalFlat(kind_str + ' 상세정보', modal_str, true, false, '', 'ok', '', 'cl-s-order-status-details cl-modal cl-s-btn cover', false);
12486
12487            },'json');
12488
12489        },
12490        shopGradeBenefitModal: function(sid, uid) {
12491            
12492            if(typeof sid == "undefined") {
12493                alert('정보가 올바르지 않습니다');
12494                return false;
12495            }
12496            $.post('_shopgradeMypage', { sid:sid, uid:uid }, function(data) {
12497
12498                if(typeof data.error != "undefined" && data.error) {
12499                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'close');
12500                    return false;
12501                }
12502
12503                var d       = (data && data.data) ? data.data : {};
12504                var grades  = Array.isArray(d.grades) ? d.grades :[];
12505                var current = d.member_grade_id;
12506
12507                // --- 1. 쿠폰 처리를 위해 필요한 변수들 선언 ---
12508                var pol        = (d && Array.isArray(d.policies) && d.policies.length) ? d.policies[0] : null;
12509                var cycleType  = pol ? String(pol.cycle_type) : '2'; // 1=주간, 2=월간
12510                var accMonths  = pol && pol.accumulate_month ? parseInt(pol.accumulate_month, 10) : 6;
12511                var coupons    = (d && Array.isArray(d.coupons)) ? d.coupons :[]; // 서버에서 넘겨받은 쿠폰 리스트
12512
12513                function esc(s){
12514                    s = (s == null) ? '' : String(s);
12515                    return s.replace(/[&<>"']/g, function(m){ return ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[m]); });
12516                }
12517                function num(n){
12518                    if (n == null || n === '') return '';
12519                    var v = parseFloat(String(n).replace(/[^0-9.-]/g,''));
12520                    if (!isFinite(v)) return '';
12521                    try { return v.toLocaleString('ko-KR'); }
12522                    catch(e){ return String(v).replace(/\B(?=(\d{3})+(?!\d))/g,','); }
12523                }
12524
12525                // 등급 기준
12526                function renderCriteria(g){
12527                    var lines =[];
12528                    if (String(g.grade_seq) === '0') {
12529                        g = $.extend({}, g, { use_auto: '0' });
12530                    }
12531
12532                    if (String(g.use_auto) === '1') {
12533                        var min = g.use_auto_amount_min;
12534                        var max = g.use_auto_amount_max;
12535                        var cnt = g.use_auto_count;
12536
12537                        if (min && max && String(min) !== String(max)) {
12538                            lines.push('구매금액 </br>' + num(min) + '원 이상 ~</br>' + num(max) + '원 미만');
12539                        } else if (min) {
12540                            lines.push('구매금액 ' + num(min) + '원 이상');
12541                        }
12542                        if (cnt && String(cnt) !== '0') {
12543                            lines.push('구매횟수 ' + num(cnt) + '회 이상');
12544                        }
12545                    } else if (String(g.grade_seq) === '0') {
12546                        // 자동 산정 아님 + 최초 등급(가입 시 부여)
12547                        lines.push('회원가입 시 모두 적용');
12548                    }
12549
12550                    return lines.length ? lines.join('<br>') : '-';
12551                }
12552
12553                // 추가 적립
12554                function renderPoint(g){
12555                    if (String(g.reserve_use) !== '1') return '-';
12556
12557                    var t    = String(g.reserve_type || '0'); // 0=%, 1=원
12558                    var val  = g.reserve_value;
12559                    var cap  = g.reserve_max;
12560                    var cond = g.reserve_amount;
12561
12562                    var s = '';
12563                    if (cond) s += num(cond) + '원 이상 결제시 </br>';
12564                    if (t === '0') {
12565                        var p = parseFloat(val);
12566                        s += (isFinite(p) ? p + '%' : '') + ' 적립';
12567                    } else {
12568                        s += (val ? num(val) + '원' : '') + ' 적립';
12569                    }
12570                    if (cap)  s += '</br>(최대 ' + num(cap) + '원)';
12571                    
12572
12573                    return s || '-';
12574                }
12575
12576                // 추가 할인
12577                function renderDiscount(g){
12578                    if (String(g.discount_use) !== '1') return '-';
12579
12580                    var t    = String(g.discount_type || '0'); // 0=%, 1=원
12581                    var val  = g.discount_value;
12582                    var cap  = g.discount_max;
12583                    var cond = g.discount_amount;
12584
12585                    var s = '';
12586                    if (cond) s += num(cond) + '원 이상 결제시 </br>';
12587                    if (t === '0') {
12588                        var base = parseFloat(val);
12589                        var off  = isFinite(base) ? base : null;
12590                        s += (off != null ? off + '%' : '') + ' 할인';
12591                    } else {
12592                        s += (val ? num(val) + '원' : '') + ' 할인';
12593                    }
12594                    if (cap)  s += '</br>(최대 ' + num(cap) + '원)';
12595                    
12596
12597                    return s || '-';
12598                }
12599
12600                function renderDeliveryBenefit(g){
12601                    return String(g.delivery_benefit || '0') === '1' ? '배송비 무료' : '-';
12602                }
12603
12604                // --- 2. 새로 추가된 쿠폰 노출 함수 ---
12605                function renderCoupon(g){
12606                    if (!coupons.length) return '-';
12607
12608                    var gSeq = String(g.seq); // 현재 반복중인 등급의 고유번호
12609                    var matchedCoupons =[];
12610
12611                    // 1) 전체 쿠폰 중 현재 등급(gSeq)이 포함된 쿠폰만 찾기
12612                    for (var i = 0; i < coupons.length; i++) {
12613                        var cp = coupons[i];
12614                        // shopping_grade_seq 에 "80,9" 형태로 들어있으므로 콤마(,)로 분리
12615                        var gradeArr = String(cp.shopping_grade_seq || '').split(',');
12616                        
12617                        if (gradeArr.indexOf(gSeq) !== -1) {
12618                            matchedCoupons.push(cp);
12619                        }
12620                    }
12621
12622                    if (matchedCoupons.length === 0) return '-';
12623
12624                    // 2) 화면에 노출할 텍스트 만들기
12625                    var cycleText = (cycleType === '1') ? '매주' : '매월'; // 지급 주기
12626                    var lines =[];
12627
12628                    for (var j = 0; j < matchedCoupons.length; j++) {
12629                        var c = matchedCoupons[j];
12630                        var val = num(c.sale_value); // 금액(할인수치) 콤마 처리
12631                        var unit = (c.sale_unit === 'A') ? '원' : '%'; 
12632                        var count = c.grade_member_coupon_count;     // 지급 장수
12633
12634                        // 쿠폰 종류에 따른 문구 처리 (배송비 쿠폰 등)
12635                        var benefitName = '할인쿠폰';
12636                        if (c.benefit === 'DELIVERY') {
12637                            benefitName = '배송비무료쿠폰';
12638                            val = ''; // 배송비무료쿠폰은 금액 노출 안 함
12639                            unit = '';
12640                        }
12641
12642                        // 예: "매월 10% 할인쿠폰 2장", "매주 5,000원 할인쿠폰 1장"
12643                        lines.push(cycleText + ' ' + val + unit + ' ' + benefitName + ' ' + count + '장');
12644                    }
12645
12646                    return lines.join('<br>');
12647                }
12648
12649                var rows = '';
12650                for (var i=0; i<grades.length; i++) {
12651                    var g = grades[i] || {};
12652                    var seq = g.seq != null ? parseInt(g.seq, 10) : null;
12653                    var isCur = (current != null && seq != null && current === seq);
12654
12655                    rows += ''
12656                        + '<div class="sgb-row' + (isCur ? ' is-current' : '') + '">'
12657                        + '<div class="sgb-cell sgb-col-name">'
12658                            + esc(g.grade_name || ('등급#' + (seq == null ? '' : seq)))
12659                            + (isCur ? '<span class="sgb-badge">현재 등급</span>' : '')
12660                        + '</div>'
12661                        + '<div class="sgb-cell">' + renderCriteria(g)  + '</div>'
12662                        + '<div class="sgb-cell">' + renderPoint(g)     + '</div>'
12663                        + '<div class="sgb-cell">' + renderDiscount(g)  + '</div>'
12664                        + '<div class="sgb-cell">' + renderDeliveryBenefit(g) + '</div>'
12665                        + '<div class="sgb-cell">' + renderCoupon(g)    + '</div>'
12666                        + '</div>';
12667                }
12668
12669                // 정책 기반 안내문
12670                var benefitNotes = [];
12671                var couponNotes  = [];
12672
12673                if (cycleType === '1') { // 주간
12674                benefitNotes.push('최근 1주일간의 구매 금액을 반영하여 회원 등급이 결정되며 매주 월요일 반영됩니다.');
12675                couponNotes.push('할인쿠폰은 매주 월요일에 지급되며 마이페이지 > 쿠폰에서 확인하실 수 있습니다.');
12676                } else { // 월간(기본)
12677                benefitNotes.push('최근 ' + (accMonths || 6) + '개월 간의 구매 금액을 반영하여 회원 등급이 결정되며 매월 1일 반영됩니다.');
12678                couponNotes.push('할인쿠폰은 매월 1일에 지급되며 마이페이지 > 쿠폰에서 확인하실 수 있습니다.');
12679                }
12680
12681                // 공통 안내(원하면 유지/삭제)
12682                benefitNotes.push('구매 금액은 실결제 금액에 한하여 회원 등급 산정에 반영됩니다.');
12683                benefitNotes.push('실결제 금액은 배송비, 쿠폰, 적립금, 등급 할인가를 제외한 금액입니다.');
12684
12685                // 최종 모달 HTML (헤더는 상단 고정, 하단에 반복 행) — div 기반 테이블
12686                modal_str = '\
12687                <div class="osd-body">\
12688                    <style>\
12689                    .shopgrade-benefit-modal{width:1100px !important;max-width:1100px !important;min-width:1100px !important;}\
12690                    .shopgrade-benefit-modal .modal-content{width:1100px !important;padding:0 !important;box-sizing:border-box;}\
12691                    .shopgrade-benefit-modal .modal-content *:not(.modal-title):not(.sgb-badge):not(svg):not(path){font-size:14px !important;font-weight:normal;}\
12692                    .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;}\
12693                    .shopgrade-benefit-modal .modal-content > button.close svg{width:16px !important;height:16px !important;}\
12694                    .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;
12694font-weight:normal !important;line-height:36px !important;text-align:center !important;white-space:nowrap;}\
12695                    .shopgrade-benefit-modal .modal-body{width:900px !important;max-width:900px !important;margin:0 auto !important;padding:0 !important;}\
12696                    .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;}\
12697                    .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;}\
12698                    .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;}\
12699                    .shopgrade-benefit-modal .sgb-header{height:50px;min-height:50px;color:#222428;border-bottom:solid 1px var(--color-line-primary);}\
12700                    .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;}\
12701                    .shopgrade-benefit-modal .sgb-row:not(.sgb-header){min-height:60px;}\
12702                    .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;}\
12703                    .shopgrade-benefit-modal .sgb-row.is-current{background:#f0f7ff;}\
12704                    .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;}\
12705                    .shopgrade-benefit-modal .sgb-notes{width:900px;margin:25px auto 0;padding:0;color:#696c71;box-sizing:border-box;}\
12706                    .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;}\
12707                    .shopgrade-benefit-modal .sgb-notes h4 + ul + h4{margin-top:25px;}\
12708                    .shopgrade-benefit-modal .sgb-notes ul{margin:0;padding-left:0;list-style:none !important;}\
12709                    .shopgrade-benefit-modal .sgb-notes li{position:relative;margin:0;padding-left:12px;display:block;line-height:20px;color:#696c71;}\
12710                    .shopgrade-benefit-modal .sgb-notes li + li{margin-top:5px;}\
12711                    .shopgrade-benefit-modal .sgb-notes li:before{content:\"\";position:absolute;left:2px;top:9px;width:3px;height:3px;border-radius:50%;background:#696c71;}\
12712                    .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;}\
12713                    .shopgrade-benefit-modal .modal-footer:before,.shopgrade-benefit-modal .modal-footer:after{display:none !important;content:none !important;}\
12714                    .shopgrade-benefit-modal .modal-footer .btn{width:240px !important;height:50px !important;margin:0 !important;padding:0 !important;line-height:50px !important;}\
12715                    @media only screen and (min-width:768px) and (max-width:991px){\
12716                    .shopgrade-benefit-modal,.shopgrade-benefit-modal .modal-content{width:100% !important;min-width:0 !important;max-width:100% !important;}\
12717                    .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;}\
12718                    .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;}\
12719                    .shopgrade-benefit-modal .sgb-scroller{overflow-x:visible !important;}\
12720                    .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;}\
12721                    }\
12722                    @media only screen and (max-width:767px){\
12723                    .shopgrade-benefit-modal,.shopgrade-benefit-modal .modal-content{width:100% !important;min-width:0 !important;max-width:100% !important;}\
12724                    .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;}\
12725                    .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;}\
12726                    .shopgrade-benefit-modal .sgb-scroller{overflow-x:auto !important;overflow-y:hidden !important;-webkit-overflow-scrolling:touch;scrollbar-width:thin;}\
12727                    .shopgrade-benefit-modal .sgb-scroller::-webkit-scrollbar{width:10px;height:10px;}\
12728                    .shopgrade-benefit-modal .sgb-table,.shopgrade-benefit-modal .sgb-row{width:900px !important;min-width:900px !important;max-width:none !important;}\
12729                    .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;}\
12730                    }\
12731                    </style>\
12732                    <div class="sgb-wrap">\
12733                    <div class="sgb-scroller">\
12734                        <div class="sgb-table">\
12735                        <div class="sgb-row sgb-header">\
12736                            <div class="sgb-cell">등급명</div>\
12737                            <div class="sgb-cell">등급 기준</div>\
12738                            <div class="sgb-cell">추가 적립</div>\
12739                            <div class="sgb-cell">추가 할인</div>\
12740                            <div class="sgb-cell">배송 혜택</div>\
12741                            <div class="sgb-cell">쿠폰</div>\
12742                        </div>\
12743                        '+ rows +'\
12744                        </div>\
12745                    </div>\
12746                    <div class="sgb-notes">\
12747                        <h4>등급 혜택 안내</h4>\
12748                        <ul>'+ benefitNotes.map(function(t){return "<li>"+esc(t)+"</li>";}).join('') +'</ul>\
12749                        <h4>쿠폰 안내</h4>\
12750                        <ul>'+ couponNotes.map(function(t){return "<li>"+esc(t)+"</li>";}).join('') +'</ul>\
12751                    </div>\
12752                    </div>\
12753                </div>';
12754                var osdModal = $(this).showModalFlat('회원 등급별 혜택', modal_str, true, false, '', 'ok', '', 'modal-default modal-dialog cl-cmmodal w1100 cover shopgrade-benefit-modal', true);
12755
12756            },'json');
12757
12758        },
12759        orderCancelModal: function(sid, pnum, onum, ognum, status, dStatus, pclass) {
12760            if(typeof sid == "undefined" || typeof pnum == "undefined" || typeof onum == "undefined") {
12761                alert('정보가 올바르지 않습니다');
12762                return false;
12763            }
12764            var escrow = status;
12765            $.post('/_check_order', { sid:sid, pnum:pnum, onum:onum, mode:'cancel', ognum: ognum }, function(data) {
12766                var LUX = false;
12767                if(data.lux) LUX = data.lux;
12768                if(typeof data.error != "undefined" && data.error) {
12769                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'close');
12770                    return false;
12771                }
12772
12773
12774                var c_data = data.r, checkboxNone = '', noneAll = '', noneChecked = '', checkNoneAll = '', checkEscrowFooter = '', checkEscrowClass = '', checkDepositCancel = '';
12775                var checkEscrow = '';
12776                var dtl = c_data.delivery_template_list;
12777                var used_code_coupon = false;
12778                
12779                if (escrow == 'Y') {
12780                    checkboxNone = 'checked';
12781                    noneAll = ' noneAll';
12782                    checkNoneAll = 'fule';
12783                    checkEscrow = '<div class="escrow-warring top-escrow">\
12784                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="15" height="15">\
12785                                        <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"/>\
12786                                        <rect fill="#4789e7" x="6" y="3" width="1" height="5"/>\
12787                                        <rect fill="#4789e7" x="6" y="9" width="1" height="1"/>\
12788                                    </svg>\
12789                                    에스크로 결제 상품은 취소/반품 요청 시 전체선택만 가능합니다.\
12790                                </div>';
12791
12792                    checkEscrowFooter = '<div class="escrow-warring bottom-escrow">\
12793                                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="15" height="15">\
12794                                                <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"/>\
12795                                                <rect fill="#4789e7" x="6" y="3" width="1" height="5"/>\
12796                                                <rect fill="#4789e7" x="6" y="9" width="1" height="1"/>\
12797                                            </svg>\
12798                                            에스크로 환불 안내\
12799                                            <div class="escrow-return-info">- 취소처리 시 구매자의 환불정산액에서 취소 수수료(330원)가 차감됩니다.</div>\
12800                                            <div class="escrow-return-info">- 환불정산액은 취소처리 후 1~3영업일 후에 지급됩니다.</div>\
12801                                        </div>';
12802                    checkEscrowClass = 'cl-s-escrow-info';
12803                } else {
12804                    if(c_data.order_status == 'W') {
12805                        checkboxNone = 'checked';
12806                        noneAll = ' noneAll';
12807                        checkNoneAll = 'fule';
12808                        checkDepositCancel = '<div class="modal-comment deposit-cancel-desc">\
12809                                    <div class="desc-box">\
12810                                        <div class="desc-title">입금대기 주문취소 안내</div>\
12811                                        <div class="section">- 입금대기 주문 건은 <span class="cl-red">전체 취소</span>만 가능하며 <span class="cl-red">취소완료</span>로 처리됩니다.</div>\
12812                                        <div class="section">- 전체취소 후 구매를 원하는 상품은 다시 주문해주세요.</div>\
12813                                        <div class="section">- 혹시나 입금을 하신 경우 별도로 문의 주시기 바랍니다.</div>\
12814                                    </div>\
12815                                </div>\
12816                            ';
12817                    }
12818                }
12819
12820                if(c_data.pay_info.coupon_list && c_data.pay_info.coupon_list.length) {
12821                    $.each(c_data.pay_info.coupon_list, function(k, v) {
12822                        if(v.kind == 'C') {
12823                            used_code_coupon = true;
12824                        }
12825                    })
12826                }
12827
12828                if(c_data.order_status != 'W' && used_code_coupon) {
12829                    checkboxNone = 'checked';
12830                    noneAll = ' noneAll';
12831                    checkNoneAll = 'fule';
12832                    checkDepositCancel = '<div class="modal-comment deposit-cancel-desc">\
12833                                <div class="desc-box">\
12834                                    <div class="desc-title">코드쿠폰 사용 주문취소 안내</div>\
12835                                    <div class="section">- 코드쿠폰 사용 주문 건은 <span class="cl-red">전체 취소</span>만 가능합니다.</div>\
12836                                    <div class="section">- 전체취소 후 구매를 원하는 상품은 다시 주문해주세요.</div>\
12837                                </div>\
12838                            </div>\
12839                        ';
12840                }
12841                
12842                var modal_str = '\
12843                    <form name="cancel_form" method="post" action="/_return">\
12844                        <input type="hidden" name="sid" value="' + sid + '">\
12845                        <input type="hidden" name="order_group" id="cancel-order-group" value="' + ognum + '">\
12846                        <input type="hidden" name="order_number" id="cancel-order-number" value="' + onum + '">\
12847                        <input type="hidden" name="extra_charge" id="extra_charge" value="' + data.r.pay_info.extra_charge + '">\
12848                        '+checkEscrow+'\
12849                        <div class="cancel-product-title">\
12850                            <div class="newcheckbox hand">\
12851                                <label>\
12852                                    <input type="checkbox" class="'+noneAll+'" id="product-check" '+checkboxNone+'>\
12853                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
12854                                        <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"/>\
12855                                    </svg>\
12856                                    <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
12857                                        <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"/>\
12858                                    </svg>\
12859                                </label>\
12860                            </div>\
12861                            취소요청 상품\
12862                        </div>';
12863                        var my_point = Number(data.r.my_point);
12864                        var gradeDeliveryBenefit = c_data.pay_info && c_data.pay_info.grade_delivery_benefit ? c_data.pay_info.grade_delivery_benefit : {};
12865                        var gradeDeliveryBenefitUsed = String(gradeDeliveryBenefit.used || '').toUpperCase() == 'Y';
12866                        var gradeDeliveryBenefitDiscount = gradeDeliveryBenefitUsed ? Number(gradeDeliveryBenefit.discount_price || 0) : 0;
12867                        var getPointCalcDeliveryPrice = function(deliveryPrice) {
12868                            deliveryPrice = Number(deliveryPrice || 0);
12869                            if(!gradeDeliveryBenefitUsed || gradeDeliveryBenefitDiscount <= 0) return deliveryPrice;
12870
12871                            return Math.max(deliveryPrice - gradeDeliveryBenefitDiscount, 0);
12872                        };
12873
12874                        var weight_template_product = {};
12875                        for (var i=0;i<data.r.odata.length;i++) {
12876                            if(c_data.odata[i].state != 'normal') continue;
12877                            var dts = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_template_seq : '';
12878                            if(c_data.odata[i].state == 'normal' && c_data.odata[i].mix_yn != 'Y') dts += '-' + c_data.odata[i].product_number;
12879                            var dt = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_type : '';
12880
12881                            if(dtl[dts]['price_type'] == 'WEIGHT') {
12882                                if(!weight_template_product.hasOwnProperty(dts)) weight_template_product[dts] = {};
12883                                if(!weight_template_product[dts].hasOwnProperty(dt)) weight_template_product[dts][dt] = {};
12884                                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];
12885                            }
12886                            var tooltip = '';
12887                            if(dtl[dts]['price_type'] == 'WEIGHT' || dtl[dts]['price_type'] == 'QUANTITY') {
12888                                if(dtl[dts]['price_type_detail']['method'] == 'DIFFERENTIAL') {
12889                                    if(dtl[dts]['price_type'] == 'QUANTITY') {
12890                                        tooltip += '<li class=\'title\'>수량별 배송비</li>';
12891                                        $(dtl[dts]['price_type_detail']['detail']).each(function(k, detail) {
12892                                            var d_v = Object.keys(detail)[0];
12893                                            var d_p = detail[d_v];
12894                                            tooltip += '<li class=\'item\'>' + d_v + '개 이상 ' + number_format(d_p) + '원</li>';
12895                                        });
12896                                    } else if(dtl[dts]['price_type'] == 'WEIGHT') {
12897                                        tooltip += '<li class=\'title\'>무게별 배송비</li>';
12898                                        $(dtl[dts]['price_type_detail']['detail']).each(function(k, detail) {
12899                                            var d_v = Object.keys(detail)[0];
12900                                            var d_p = detail[d_v];
12901                                            tooltip += '<li class=\'item\'>' + d_v + 'Kg 이상 ' + number_format(d_p) + '원</li>';
12902                                        });
12903                                    }
12904                                } else if(dtl[dts]['price_type_detail']['method'] == 'REPEAT') {
12905                                    if(dtl[dts]['price_type'] == 'QUANTITY') {
12906                                        tooltip += '<li class=\'title\'>수량별 배송비</li>';
12907                                        tooltip += '<li class=\'item\'>' + number_format(dtl[dts]['repeat_value']) + '개 구매시마다 ' + number_format(dtl[dts]['repeat_price']) + '원 반복 부과</li>';
12908                                    } else if(dtl[dts]['price_type'] == 'WEIGHT') {
12909                                        tooltip += '<li class=\'title\'>무게별 배송비</li>';
12910                                        tooltip += '<li class=\'item\'>' + number_format(dtl[dts]['repeat_value']) + 'Kg마다 ' + number_format(dtl[dts]['repeat_price']) + '원 반복 부과</li>';
12911                                    }
12912                                }
12913                                if(tooltip && (dt == 'DELIVERY' || dt == 'DIRECT'))  {
12914                                    if(!LUX) tooltip += '<li class=\'desc\'>추가 상품은 배송비 조건에 반영되지 않습니다.</li>';
12915
12916                                    if(dtl[dts]['price_type'] == 'WEIGHT' && weight_template_product[dts][dt]) {
12917                                        tooltip += '<li class=\'title product-weight\'>상품별 무게</li>';
12918                                        $.each(weight_template_product[dts][dt], function(k, v) {
12919                                            tooltip += '<li class=\'item\'>' + v.product_name + ' : ' + number_format(v.product_weight) + 'kg</li>';
12920                                        });
12921                                    }
12922
12923                                    tooltip = '<ul class=\'delivery-tooltip\'>' + tooltip + '</ul>';
12924                                    dtl[dts]['tooltip'] = tooltip;
12925                                }
12926                            }
12927                        }
12928
12929                        modal_str += '<table class="table product-table">';
12930                        for (var i=0;i<data.r.odata.length;i++) {
12931                            if (c_data.odata[i].d_status == '' || c_data.odata[i].d_status == 'CN') {
12932                                noneChecked = '';
12933                                if (!checkNoneAll) noneAll = '';
12934                            } else {
12935                                if (!checkNoneAll) noneAll = 'noneAll';
12936                                noneChecked = 'noneChecked';
12937                            }
12938                            if (c_data.odata[i].p_status == 'W') {
12939                                if (!checkNoneAll) noneAll = 'noneAll';
12940                                noneChecked = 'noneChecked';
12941                                checkboxNone = 'checked';
12942                            }
12943                            var curr_point = 0;
12944                            var usable_point = 0;
12945                            var refund_point = 0;
12946                            var expired_point = 0;
12947
12948                            if(c_data.odata[i].used_point) {
12949                                curr_point = Math.abs(c_data.odata[i].used_point.point);
12950                                usable_point = Math.abs(c_data.odata[i].used_point.usable_point);
12951                            }
12952
12953                            // if(c_data.odata[i].refund_point) {
12954                            //     refund_point = c_data.odata
12955                            // }
12956
12957                            if(c_data.odata[i].expired_point) {
12958                                expired_point = Math.abs(c_data.odata[i].expired_point.point);
12959                            }
12960
12961
12962                            var dts = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_template_seq : '';
12963                            if(c_data.odata[i].state == 'normal' && c_data.odata[i].mix_yn != 'Y') dts += '-' + c_data.odata[i].product_number;
12964                            var dt = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_type : '';
12965
12966                            modal_str += '\
12967                            <tr class="cl-s-product-jumbotron clearfix">\
12968                                <td ' + (c_data.odata[i].state != 'normal' ? 'colspan="2"' : '') + '>\
12969                                <div class="newcheckbox hand">\
12970                                    <label>\
12971                                        <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
12971+'" 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) + '">\
12972                                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
12973                                        <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"/>\
12974                                        </svg>\
12975                                        <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
12976                                        <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"/>\
12977                                        </svg>\
12978                                    </label>\
12979                                </div>\
12980                                <div class="cl-s-product-thumb">\
12981                                    <img src="' + c_data.pdata[i].img + '" alt="' + c_data.pdata[i].name + '" class="' + c_data.pdata[i].img_align + '" />\
12982                                </div>\
12983                                <div class="cl-s-product-info">\
12984                                    <h5 class="cl-s-product-title">' + c_data.pdata[i].name + '</h5>\
12985                            ';
12986
12987                            console.log(c_data.odata[i]);
12988
12989                            var price = (Number(c_data.odata[i].sale_price) > 0) ? c_data.odata[i].sale_price : c_data.odata[i].price,
12990                                quantity = Number(c_data.odata[i].quantity),
12991                                optionPrice = c_data.odata[i].price * quantity,
12992                                sum_price = quantity * price,
12993                                option_name = (typeof c_data.pdata[i].option != "undefined" && c_data.pdata[i].option) ? c_data.pdata[i].option : '',
12994                                option_str = '',
12995                                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>' : '',
12996                                option_title = (c_data.pdata[i].option_type == 'A') ? '추가옵션: ' + (c_data.pdata[i].option_group ? c_data.pdata[i].option_group + ': ' : '') : '옵션: ';
12997                            if(option_name) {
12998                                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>';
12999                            } else {
13000                                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>' : '';
13001                            }
13002                            modal_str += '\
13003                                    <div class="option-str option-check" data-optionPrice="'+optionPrice+'">' + option_str + etc_str + '<span>' + quantity + '개</span><div class="price"><span>
13003' + number_format(optionPrice) + '</span> 원</div></div>\
13004                                </div>\
13005                                </td>\
13006                            ';
13007
13008                            if(c_data.odata[i].state == 'normal') {
13009                                var delivery_cnt = dtl[dts]['dtype'][dt].delivery_cnt;
13010                                if(!dtl[dts]['dtype'][dt].hasOwnProperty('counter')) {
13011                                    dtl[dts]['dtype'][dt]['counter'] = 0;
13012                                }
13013
13014                                dtl[dts]['dtype'][dt]['counter']++;
13015
13016                                if(dtl[dts]['dtype'][dt]['counter'] == 1) {                            
13017                                    modal_str +='\
13018                                        <td rowspan="' + delivery_cnt + '" class="delivery-price"><div>배송비</div><div class="price"><span>';
13019                                    if(dt == 'DELIVERY' || dt == 'DIRECT') {
13020                                        if(dtl[dts]['price_type'] == 'ETC') {
13021                                            modal_str += '별도안내</span>';
13022                                        } else {
13023                                            modal_str += number_format(dtl[dts]['dtype'][dt]['price']) + '</span> 원';    
13024                                        }
13025                                        if(dtl[dts]['pay_type'] == 'DELIVERED') modal_str += '(착불)';
13026
13027                                        if(dtl[dts]['price_type'] == 'FREE_CONDITION') {
13028                                            modal_str += '<div class="price-desc">' + number_format(dtl[dts]['free_condition']) + '원 이상<br>배송비 무료</div>';
13029                                        }
13030                                    } else {
13031                                        modal_str += $.lang[LANG]['shopping.delivery.template.delivery_type.' + dt.toLowerCase()] + '</span>';
13032                                        if(dt == 'QUICK') modal_str += '(착불)';
13033                                    }
13034                                    if(dtl[dts]['tooltip'] && (dt == 'DELIVERY' || dt == 'DIRECT')) {
13035                                        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>';
13036                                    }
13037                                    modal_str +='</div></td>\
13038                                    ';
13039                                }
13040
13041                                modal_str += '\
13042                                </tr>';
13043
13044                                if(dtl[dts]['dtype'][dt]['counter'] == dtl[dts]['dtype'][dt]['delivery_cnt']) {
13045                                    modal_str += '\
13046                                        <tr class="cl-s-product-jumbotron clearfix delivery-price delivery-price-mobile">\
13047                                            <td><div class="delivery-title">묶음 배송비</div><div class="delivey-price"><span>';
13048
13049                                    if(dtl[dts]['tooltip'] && (dt == 'DELIVERY' || dt == 'DIRECT')) {
13050                                        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.
1305066 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>';
13051                                    }
13052                                    
13053                                    if(dt == 'DELIVERY' || dt == 'DIRECT') {
13054                                        modal_str += number_format(dtl[dts]['dtype'][dt]['price']) + '</span> 원';
13055                                        if(dtl[dts]['pay_type'] == 'DELIVERED') modal_str += '(착불)';
13056                                        if(dtl[dts]['price_type'] == 'FREE_CONDITION') {
13057                                            modal_str += '<div class="price-desc">' + number_format(dtl[dts]['free_condition']) + '원 이상 배송비 무료</div>';
13058                                        }
13059                                    } else {
13060                                        modal_str += $.lang[LANG]['shopping.delivery.template.delivery_type.' + dt.toLowerCase()] + '</span>';
13061                                        if(dt == 'QUICK') modal_str += '(착불)';
13062                                    }
13063
13064                                    modal_str += '</div></td>\
13065                                        </tr>\
13066                                    ';
13067                                }
13068                            }
13069                        }
13070                        modal_str += '</table>';
13071
13072                        modal_str += '<div class="order-cancel-content">\
13073                            <div class="cl-s-form-selector">\
13074                                <select class="selectpicker dropdown" id="cancel-reason" name="reason">\
13075                                    <option value="구매의사 취소">구매의사 취소</option>\
13076                                    <option value="다른 상품 잘못 주문">다른 상품 잘못 주문</option>\
13077                                    <option value="기타">기타</option>\
13078                                </select>\
13079                                <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>\
13080                            </div>\
13081                            <div class="cl-s-form-wrap">\
13082                                <div class="cl-s-form-group input-label-hide">\
13083                                    <textarea class="cl-s-form-control control-textarea" id="cancel-requests" name="requests" maxlength="500" required="required"></textarea>\
13084                                    <label for="input" class="cl-s-control-label">자세한 내용을 적어주세요. (500자 이내)</label>\
13085                                </div>\
13086                            </div>\
13087                        </div>';
13088
13089                        modal_str += '<div class="order-cancel-content">\
13090                            <div class="cancel-info-box">\
13091                                <div class="cancel-info"><span class="cancel-info-title">취소상품 합계</span><span class="cancel-info-price" id="cancel-price">0원</span></div>\
13092                                <div class="cancel-info"><span class="cancel-info-title">취소 배송비 합계</span><span class="cancel-info-price" id="cancel-delivery-price">0원</span></div>\
13093                                <div class="cancel-info"><span class="cancel-info-title">적립금</span><span class="cancel-info-price" id="cancel-point-price">0원</span></div>\
13094                                <div class="cancel-info"><span class="cancel-info-title">쿠폰</span><span class="cancel-info-price" id="cancel-coupon-price">0원</span></div>\
13095                                <div class="cancel-info"><span class="cancel-info-title">등급할인</span><span class="cancel-info-price" id="cancel-grade-discount-price">0원</span></div>\
13096                                <div class="cancel-info"><span class="cancel-info-title cancel-coupon-title"></span><span class="cancel-info-price" id="cancel-coupon-detail"></span></div>\
13097                                <div class="cancel-info-line"></div>\
13098                                <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>\
13099                            </div>'+checkEscrowFooter+'\
13100                        </div>';
13101                        modal_str += checkDepositCancel;
13102
13103                    var status = [];
13104                    for (var i=0;i<c_data.pdata.length;i++) {
13105                        status.push(c_data.pdata[i].p_status);
13106                    }
13107
13108                    if (pclass == '무통장 입금' || pclass == '가상계좌') {
13109                        var returnClass = '';
13110                        if (c_data.return_bank.length > 1 && c_data.return_bank.indexOf('')===-1) returnClass = 'returnDisabled';
13111                        modal_str += '\
13112                            <div class="modal-sub-title">환불 계좌</div>\
13113                            <ul class="qna-writer clearfix">\
13114                                <li class="">\
13115                                    <div class="cl-s-form-wrap '+returnClass+'">\
13116                                        <div class="cl-s-form-group">';
13117                                        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]+'">';
13118                                        else modal_str += '<input type="text" class="cl-s-form-control" id="no-bank" name="no_bank" required="required" value="">';
13119                                        modal_str += '<label for="input" class="cl-s-control-label">은행명</label>\
13120                                        </div>\
13121                                    </div>\
13122                                </li>\
13123                                <li>\
13124                                    <div class="cl-s-form-wrap '+returnClass+'">\
13125                                        <div class="cl-s-form-group">';
13126                                        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]+'">';
13127                                        else modal_str += '<input type="text" class="cl-s-form-control" id="no-bank-name" name="no_bank_name" required="required">';
13128                                        modal_str += '<label for="input" class="cl-s-control-label">예금주</label>\
13129                                        </div>\
13130                                    </div>\
13131                                </li>\
13132                                <li>\
13133                                    <div class="cl-s-form-wrap '+returnClass+'">\
13134                                        <div class="cl-s-form-group">';
13135                                        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]+'">';
13136                                        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="">';
13137                                        modal_str += '<label for="input" class="cl-s-control-label">계좌번호</label>\
13138                                        </div>\
13139                                    </div>\
13140                                </li>\
13141                            </ul>';
13142                        if(status.indexOf('W')===-1) modal_str += '\
13143                            <div class="modal-comment">동일 주문 내 여러 상품을 환불 요청하시는 경우, ì
13143µœì´ˆ 입력한 환불계좌로 일괄 환불처리됩니다.</div>\
13144                        ';
13145                    }
13146
13147                    modal_str += '\
13148                            <div class="modal-comment point-used-desc hide">\
13149                                <div class="desc-box">\
13150                                    <div class="desc-title">적립금 환불 안내</div>\
13151                                    <div class="section">상품(들)을 구매하여 적립된 적립금 <span id="disp_used_point_total" class="point-color"></span>원이 이미 사용되거나 유효기간이 만료되었습니다.</div>\
13152                                    <div class="section">현재 보유 적립금이 <span class="point-color">' + addCommas(my_point) + '</span>원 으로 구매 적립된 적립금 <span id="disp_cancel_after_point" class="point-color"></span>원을 취소 처리할 수 없습니다.</div>\
13153                                    <div class="section">미 취소된 적립금에 대한 처리는 판매자와 협의해주세요.</div>\
13154                                </div>\
13155                                <div class="newcheckbox hand">\
13156                                    <label style="margin-left: 25px;">\
13157                                        <input type="checkbox" class="cancel-agree" />\
13158                                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
13159                                            <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>\
13160                                        </svg>\
13161                                        <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
13162                                            <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>\
13163                                        </svg>\
13164                                    위 내용을 확인하였습니다.</label>\
13165                                </div>\
13166                                <div class="point-used-cancel-agree-desc">\
13167                                    <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>\
13168                                    적립금 환불 안내에 동의해주세요.\
13169                                </div>\
13170                            </div>\
13171                            ';
13172
13173                    modal_str += '</form>\
13174                ';
13175
13176                var ocModal = $(this).showModalFlat('취소 요청', modal_str,true,true,function () {
13177
13178                    var f = document.cancel_form;
13179                    if(ocModal.find('#cancel-reason').prop('value') == '') {
13180                        // $('#cancel-reason').selectpicker('toggle');
13181                        // return false;
13182                        $('#cancel-reason').closest('.cl-s-form-selector').addClass('empty');
13183                    }
13184
13185                    ocModal.find('.cl-s-form-wrap').each(function() {
13186                        var check_input = $(this).find('.cl-s-form-control'),
13187                            val = check_input.val().trim();
13188
13189                        if(val.length == 0) {
13190                            $(this).removeClass('error').addClass('empty');
13191                            $(this).find('.cl-s-control-label.error').remove();
13192                        } else {
13193                            if($(this).hasClass('error')) {
13194                                check_input.focus();
13195                            }
13196                        }
13197                    });
13198                    var checkCnt = 0;
13199
13200                    $(".status-checkbox").each(function (i, index) {
13201                        if ($(this).is(":checked") === true) {
13202                            checkCnt++;
13203                        }
13204                    });
13205
13206                    if (checkCnt < 1) {
13207                        alert('상품을 1개 이상 선택해 주세요');
13208                        return false;
13209                    }
13210
13211                    if(ocModal.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').length > 0) {
13212                        // ocModal.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').eq(0).find('.cl-s-form-control').focus();
13213                        return false;
13214                    }
13215
13216                    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) {
13217                        $(".point-used-cancel-agree-desc").show();
13218                        return false;
13219                    } else {
13220                        $(".point-used-cancel-agree-desc").hide();
13221                    }
13222
13223                    $.processON();
13224
13225                    f.submit();
13226                    ocModal.modal('hide');
13227
13228                },'close','등록하기','cl-s-order-cancel cl-modal cl-s-btn cover ' + checkEscrowClass, false, '', function() {
13229                    var totalCnt = 0, totalNomalCheck = 0, nomalCheck = 0, price = 0, deliveryPrice = 0, gradeDiscountPrice = 0,
13230                        $form = $('form[name="cancel_form"]');
13231
13232                    $('.status-checkbox').each(function(i, index) {
13233                        if ($(this).is(":checked") === true) {
13234                            price += ($(this).closest('.cl-s-product-jumbotron').find('.option-check').attr('data-optionPrice') * 1);
13235                            gradeDiscountPrice += Number($(this).data('grade_discount_price') || 0);
13236                            totalCnt++;
13237                            if ($(this).attr('data-type') == 'normal') {
13238                                nomalCheck++;
13239                                var mix_yn = $(this).data('mix_yn');
13240                                var delivery_price = 0;
13241                                var delivery_template_seq = $(this).data('delivery_template_seq');
13242                                var delivery_type = $(this).data('delivery_type');
13243                                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) {
13244                                    delivery_price = Number($(this).data('delivery_price'));
13245                                }
13246                                deliveryPrice += delivery_price;
13247                            }
13248                        }
13249
13250                        if ($(this).attr('data-type') == 'normal') {
13251                            totalNomalCheck++;
13252                        }
13253                    });
13254
13255                    if(c_data.order_status == 'W') {
13256                        $("#product-check, .status-checkbox").click(function(e){
13257                            return false;
13258                        });
13259                    }
13260                    var product_price = price + getPointCalcDeliveryPrice(deliveryPrice),
13261                        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);
13262
13263                    rePayment = (rePayment > 0) ? rePayment : 0;
13264
13265                    // coupon 처리
13266                    var coupon = c_data.pay_info.coupon_list,
13267                        cancel_coupon_price = 0;
13268                    if(coupon.length) {
13269                        var checked_order_number = $('.cancel-info-data:checked').map(function(){ return this.value; }).toArray();
13270
13271                        $.each(coupon, function(i,v) {
13272                            if(checked_order_number.indexOf(v.order_number) > -1 || v.kind == 'C') {
13273                                cancel_coupon_price += parseInt(v.discount_price);
13274
13275                                // 환불금에서 쿠폰처리
13276                                if($('.coupon-detail-info[data-seq="' + v.seq + '"]').length == 0) {
13277                                    $('.cancel-coupon-title').append('<span class="coupon-name coupon-detail-info" data-seq="' + v.seq + '">' + v.coupon_name + '</span>');
13278                                    $('#cancel-coupon-detail').append('<span class="coupon-price coupon-detail-info" data-seq="' + v.seq + '">-' + number_format(parseInt(v.discount_price)) + '원</span>');
13279                                }
13280                            } else {
13281                                $('.coupon-detail-info[data-seq="' + v.seq + '"]').remove();
13282                            }
13283                        });
13284                        // 취소된 쿠폰 저장
13285                    }
13286                    product_price = product_price - parseInt(cancel_coupon_price);
13287                    product_price = product_price - gradeDiscountPrice;
13288                    
13289                    var use_point = (rePayment - product_price > 0) ? 0 : rePayment - product_price;
13290                    product_price = product_price + use_point;
13291
13292                    $('#cancel-price').html(number_format(price)+'원');
13293                    $('#cancel-delivery-price').html(number_format(deliveryPrice)+'원');
13294                    $('#cancel-point-price').html(number_format(use_point)+'원');
13295                    $('#cancel-coupon-price').html(((cancel_coupon_price > 0) ? '-' + number_format(cancel_coupon_price) : '0')+'원');
13296                    $('#cancel-grade-discount-price').html(((gradeDiscountPrice > 0) ? '-' + number_format(gradeDiscountPrice) : '0')+'원');
13297                    $('#return-total-price').html(number_format(product_price));
13298
13299                    $('.cancel-info-data').on('change', function (e) {
13300                        if($(this).hasClass('noneAll')) return;    
13301                        var cancel_after_point = my_point;
13302                        var disp_used_point_total = 0;
13303                        var deliveryPrice = 0;
13304                        var extra_delivery_flag = {};
13305                        var dtl_copy = JSON.parse(JSON.stringify(dtl));
13306
13307
13308                        var product_number = $(this).attr('data-product_number');
13309                        if($(this).attr('data-option_type') != 'A' && !$('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:not(:checked)').length) {
13310                            $('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type="A"]').prop('checked',true);
13311                        } 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')) {
13312                            $('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:last').prop('checked',fal
13312se);
13313                        }
13314
13315                        if($("input[name='order_number_ary[]']:checked").length) {
13316                            coupon.map(function(v,k) {  coupon[k]['apply'] = '' });
13317                            $("input[name='order_number_ary[]']:checked").each(function() {
13318                                cancel_after_point = Number(cancel_after_point) + ((Number($(this).data("expired_point"))) - Number($(this).data("curr_point")));
13319                                disp_used_point_total += ((Number($(this).data("expired_point"))) - Number($(this).data("curr_point")));
13320                                c_ord_num = $(this).val();
13321
13322                                if($(this).data('type') != 'normal' || $(this).data('option_type') == 'A') return;
13323                                var mix_yn = $(this).data('mix_yn');
13324                                var delivery_price = 0;
13325                                var delivery_template_seq = $(this).data('delivery_template_seq');
13326                                var delivery_type = $(this).data('delivery_type');
13327                                var product_weight = $(this).data('product_weight');
13328
13329                                if(delivery_type != 'DELIVERY' && delivery_type != 'DIRECT') return;
13330                                // if(dtl[delivery_template_seq]['price_type'] != 'WEIGHT' && dtl[delivery_template_seq]['price_type'] != 'QUANTITY') {
13331                                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) {
13332                                    delivery_price = Number($(this).data('delivery_price'));
13333                                    
13334                                    coupon.map(function(v,k) { if(v.order_number == c_ord_num && delivery_price > 0 && v.benefit == 'DELIVERY') coupon[k]['apply'] = '1';  });
13335                                }
13336
13337                                if(dtl[delivery_template_seq]['price_type'] != 'WEIGHT' && dtl[delivery_template_seq]['price_type'] != 'QUANTITY') {
13338                                } else {
13339                                    dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_weight'] -= Number((Number($(this).data('product_weight')) * Number($(this).data('quantity'))).toFixed(3));
13340                                    dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_weight'] = Number(dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_weight'].toFixed(3));
13341                                    dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_quantity'] -= Number($(this).data('quantity'));
13342
13343                                    if(dtl[delivery_template_seq]['price_type_detail']['method'] == 'REPEAT') {
13344                                        if(dtl[delivery_template_seq]['price_type'] == 'WEIGHT') {
13345                                            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'];
13346                                        } else if(dtl[delivery_template_seq]['price_type'] == 'QUANTITY') {
13347                                            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'];
13348                                        }
13349                                        // if()
13350                                    } else if(dtl[delivery_template_seq]['price_type_detail']['method'] == 'DIFFERENTIAL') {
13351                                        if(dtl[delivery_template_seq]['price_type'] == 'WEIGHT') {
13352                                            $.each(dtl[delivery_template_seq]['price_type_detail'].detail, function() {
13353                                                var r_value = Number(Object.keys(this)[0]);
13354                                                var r_price = Number(Object.values(this)[0]);
13355                                                if(dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_weight'] == 0) {
13356                                                    dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_price'] = 0;
13357                                                } else if(dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_weight'] >= r_value) {
13358                                                    dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_price'] = r_price;
13359                                                }                                                  
13360                                            });
13361                                        } else if(dtl[delivery_template_seq]['price_type'] == 'QUANTITY') {
13362                                            $.each(dtl[delivery_template_seq]['price_type_detail'].detail, function() {
13363                                                var r_value = Number(Object.keys(this)[0]);
13364                                                var r_price = Number(Object.values(this)[0]);
13365                                                if(dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_quantity'] == 0) {
13366                                                    dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_price'] = 0;
13367                                                } else if(dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_quantity'] >= r_value) {
13368                                                    dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_price'] = r_price;
13369                                                }                                                  
13370                                            });
13371                                        }
13372                                    }
13373                                    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) 
13374                                        extra_delivery_flag[delivery_template_seq+'|'+delivery_type] = true;
13375                                    else 
13376                                        extra_delivery_flag[delivery_template_seq+'|'+delivery_type] = false;
13377                                }
13378                                deliveryPrice += delivery_price;
13379                            });
13380                        }
13381
13382                        $form.find('.extra-delivery-fee-box').remove();
13383
13384                        if(cancel_after_point < 0) {
13385                            $(".point-used-desc #disp_cancel_after_point").html(addCommas(Math.abs(cancel_after_point)));
13386                            $(".point-used-desc #disp_used_point_total").html(addCommas(Math.abs(disp_used_point_total)));
13387                            $(".point-used-desc").removeClass("hide");
13388                        } else {
13389                            $(".point-used-desc").addClass("hide");
13390                            $(".point-used-desc #disp_cancel_after_point").html("");
13391                            $(".point-used-desc #disp_used_point_total").html("");
13392                        }
13393
13394                        var price = 0;
13395                        var gradeDiscountPrice = 0;
13396                        var oLength = $('.option-check').length;
13397                        var totalCnt = 0, totalNomalCheck = 0, nomalCheck = 0;
13398                        
13399                        $form.find('.order-cancel-content.extra-info').remove();
13400
13401                        if ($(this).hasClass('noneAll') === true) {
13402                            if ($(this).hasClass('noneChecked') === true) {
13403                                $(this).prop('checked', false);
13404                            } else {
13405                                $(this).prop('checked', true);
13406                                $(".status-checkbox").each(function () {
13407                                    if ($(this).prop('disabled') !== true) $(this).prop('checked', true);
13408                                });
13409                            }
13410                        }
13411
13412                        $(".status-checkbox").each(function (i, index) {
13413                            if ($(this).is(":checked") === true) {
13414                                price += ($(this).closest('.cl-s-product-jumbotron').find('.option-check').attr('data-optionPrice') * 1);
13415                                gradeDiscountPrice += Number($(this).data('grade_discount_price') || 0);
13416                                totalCnt++;
13417                                if ($(this).attr('data-type') == 'normal') nomalCheck++;
13418                            }
13419
13420                            if ($(this).attr('data-type') == 'normal') totalNomalCheck++;
13421                        });
13422
13423                        var product_price = price + getPointCalcDeliveryPrice(deliveryPrice),
13424                            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);
13425
13426                        rePayment = (rePayment > 0) ? rePayment : 0;
13427                        
13428                        // coupon 처리
13429                        var cancel_coupon_price = 0;
13430                        if(coupon.length) {
13431                            var checked_order_number = $('.cancel-info-data:checked').map(function(){ return this.value; }).toArray();
13432                            $.each(coupon, function(i,v) {
13433                                rePayment -= v.discount_price;
13434                                v.apply = (v.apply || v.benefit != 'DELIVERY') ? '1' : '';
13435                                if((checked_order_number.indexOf(v.order_number) > -1 && v.apply) || v.kind == 'C') {
13436                                    cancel_coupon_price += parseInt(v.discount_price);
13437                                    // 환불금에서 쿠폰처리
13438                                    if($('.coupon-detail-info[data-seq="' + v.seq + '"]').length == 0) {
13439                                        $('.cancel-coupon-title').append('<span class="coupon-name coupon-detail-info" data-seq="' + v.seq + '">' + v.coupon_name + '</span>');
13440                                        $('#cancel-coupon-detail').append('<span class="coupon-price coupon-detail-info" data-seq="' + v.seq + '">-' + number_format(parseInt(v.discount_price)) + '원</span>');
13441                                    }
13442                                } else {
13443                                    $('.coupon-detail-info[data-seq="' + v.seq + '"]').remove();
13444                                }
13445                            });
13446                            // 취소된 쿠폰 저장
13447                        }
13448
13449                        product_price = product_price - parseInt(cancel_coupon_price);
13450                        product_price = product_price - gradeDiscountPrice;
13451
13452                        var use_point = (rePayment - product_price > 0) ? 0 : rePayment - product_price;
13453                        product_price = product_price + use_point;
13454
13455                        $('#cancel-price').html(number_format(price)+'원');
13456                        $('#cancel-delivery-price').html(number_format(deliveryPrice)+'원');
13457                        $('#cancel-point-price').html(number_format(use_point)+'원');
13458                        $('#cancel-coupon-price').html(((cancel_coupon_price > 0) ? '-' + number_format(cancel_coupon_price) : '0')+'원');
13459                        $('#cancel-grade-discount-price').html(((gradeDiscountPrice > 0) ? '-' + number_format(gradeDiscountPrice) : '0')+'원');
13460                        $('#return-total-price').html(number_format(product_price));
13461
13462                        var priceSumArr = [];
13463                        var extra_charge_flag = {};
13464                        if(ocModal.find('.cancel-info-data:checked').length) {
13465                            ocModal.find('.cancel-info-data:checked').each(function() {
13466                                if($(this).data('type') != 'normal') 
13467                                    return;
13468
13469                                var dts = $(this).data('delivery_template_seq');
13470                                if(dtl[dts]['price_type'] != 'FREE_CONDITION') return;
13471                                var dt = $(this).data('delivery_type');
13472                                if(dt != 'DELIVERY' && dt != 'DIRECT') return;
13473
13474                                if(!priceSumArr.hasOwnProperty(dts)) {
13475                                    priceSumArr[dts] = [];
13476                                
13477                                }
13478
13479                                if(!priceSumArr[dts].hasOwnProperty(dt)) {
13480                                    priceSumArr[dts][dt] = 0;
13481                                }
13482                                // cancel_after_point = Number(cancel_after_point) + ((Number($(this).data("usable_point")) + Number($(this).data("expired_point"))) - Number($(this).data("curr_point")));
13483                                var selectedPrice = 0;
13484                                selectedPrice = Number($(this).closest('tr').find('[data-optionprice]').data('optionprice'));
13485                                priceSumArr[dts][dt] += selectedPrice;
13486
13487                                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) {
13488                                    extra_charge_flag[dts + '|' + dt] = true;
13489                                } else {
13490                                    extra_charge_flag[dts + '|' + dt] = false;
13491                                }
13492                            });
13493                        }
13494                        
13495                        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);
13496
13497                        if($('input[name="order_number_ary[]"]').length == $('input[name="order_number_ary[]"]:checked').length) $('#product-check').prop('checked', true);
13498                        else $('#product-check').prop('checked', false);
13499                    });
13500
13501                    $(document).on('click', '#product-check', function () {
13502                        var price = 0;
13503                        var deliveryPrice = 0;
13504                        var totalCnt = 0, totalNomalCheck = 0, nomalCheck = 0;
13505                        $form.find('.order-cancel-content.extra-info').remove();
13506                        if ($(this).hasClass('noneAll') === true) {
13507                            $(this).prop('checked', true);
13508                            $(".status-checkbox").each(function () {
13509                                if ($(this).prop('disabled') !== true) $(this).prop('checked', true).change();
13510                            });
13511                        }
13512                        if ($(this).is(":checked") === true) {
13513                            $(".status-checkbox").each(function (i) {
13514                                if ($(this).prop('disabled') !== true) {
13515                                    $(this).prop('checked', true).change();
13516                                }
13517
13518                            });
13519                        } else {
13520                            $(".status-checkbox").each(function () {
13521                                if ($(this).prop('disabled') !== true) $(this).prop('checked', false).change();
13522                            });
13523
13524                            $('#cancel-price').html('0원');
13525                            $('#cancel-delivery-price').html('0원');
13526                            $('#cancel-point-price').html('0원');
13527                            $('#cancel-grade-discount-price').html('0원');
13528                            $('#return-total-price').html('0');
13529                        }
13530                    });
13531
13532                    /* first option setting */
13533                    $('.cl-s-order-cancel .cl-s-form-selector').each(function(e) {
13534                        var checkSelectOption = ($(this).find('select option').length > 0) ? true : false;
13535                        if(checkSelectOption) {
13536                            var selectId = $(this).find('select').attr('id'),
13537                                val = $(this).find('select').children().eq(0).val();
13538                            $(this).find('select').selectpicker({'val':val, dropupAuto:false});
13539                        }
13540                    });
13541
13542                    $('.cl-s-order-cancel .cl-s-form-group').on('click',function(e) {
13543                        if($(e.target).hasClass('cl-s-form-group')) {
13544                            $(e.target).find('.cl-s-form-control:not([type=hidden])').focus();
13545                        }
13546                    });
13547
13548                    $('#cancel-reason').on({
13549                        'show.bs.select': function (e) {
13550                            $(this).closest('.cl-s-form-selector').addClass('active');
13551                        },
13552                        'hidden.bs.select': function(e) {
13553                            $(this).closest('.cl-s-form-selector').removeClass('active');
13554
13555                            if($('#cancel-reason').prop('value') == '') {
13556                                $(this).closest('.cl-s-form-selector').addClass('empty');
13557                            } else {
13558                                $(this).closest('.cl-s-form-selector').removeClass('empty');
13559                            }
13560                        },
13561                        'changed.bs.select': function (e, clickedIndex, newValue, oldValue) {
13562                            // console.log(this.value, clickedIndex, newValue, oldValue);
13563                        }
13564                    });
13565
13566                    $('.cl-s-order-cancel .control-textarea').on({
13567                        focus: function(e) {
13568                            $(this).closest('.cl-s-form-wrap').addClass('active');
13569                        },
13570                        blur: function(e) {
13571                            var val = $(this).val().trim();
13572
13573                            $(this).closest('.cl-s-form-wrap').removeClass('active');
13574                            if(val.length == 0) {
13575                                $(this).closest('.cl-s-form-wrap').removeClass('error').addClass('empty');
13576                                $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
13577                                return false;
13578                            } else {
13579                                $(this).closest('.cl-s-form-wrap').removeClass('empty');
13580                                var error_str = '';
13581                                if(checkEmojis(val)) error_str = $.lang[LANG]['config.unable.emoji'];
13582                                else if(val.length < 5) error_str = $.lang[LANG]['customsite.validate.message.minlengthto5'];
13583
13584                                if(error_str.length > 0) {
13585                                    $(this).closest('.cl-s-form-wrap').addClass('error');
13586                                    if($(this).parent().find('.cl-s-control-label.error').length > 0) {
13587                                        $(this).parent().find('.cl-s-control-label.error').html(error_str);
13588                                    } else {
13589                                        $(this).after('<label for="input" class="cl-s-control-label error">' + error_str + '</label>');
13590                                    }
13591                                    return false;
13592                                }
13593                            }
13594
13595                            $(this).closest('.cl-s-form-wrap').removeClass('error').removeClass('empty');
13596                            $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
13597                        }
13598                    });
13599
13600                    $('.cl-s-form-wrap .cl-s-form-control').on({
13601                        focus: function(e) {
13602                            $(this).closest('.cl-s-form-wrap').addClass('active');
13603                        },
13604                        blur: function(e) {
13605                            var val = $(this).val().trim();
13606                            
13607                            $(this).closest('.cl-s-form-wrap').removeClass('active');
13608                            if(val.length == 0) {
13609                                $(this).closest('.cl-s-form-wrap').removeClass('error').addClass('empty');
13610                                $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
13611                                return false;
13612                            } else {
13613                                $(this).closest('.cl-s-form-wrap').removeClass('empty');
13614
13615                                if(checkEmojis(val)) {
13616                                    $(this).closest('.cl-s-form-wrap').addClass('error');
13617                                    if($(this).parent().find('.cl-s-control-label.error').length > 0) {
13618                                        $(this).parent().find('.cl-s-control-label.error').html($.lang[LANG]['config.unable.emoji']);
13619                                    } else {
13620                                        $(this).after('<label for="input" class="cl-s-control-label error">' + $.lang[LANG]['config.unable.emoji'] + '</label>');
13621                                    }
13622                                    return false;
13623                                }
13624                            }
13625
13626                            $(this).closest('.cl-s-form-wrap').removeClass('error');
13627                            $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
13628                        }
13629                    });
13630
13631                    if(escrow == 'Y') {
13632                        $('.cancel-info-data').off('change');
13633                    }
13634                
13635                    ocModal.find('[data-toggle="popover"]').popover();
13636                });
13637
13638            },'json');
13639        },
13640        orderReturnExchangeModal: function(sid, pnum, onum, ognum, status, pclass) {
13641            if(typeof sid == 'undefined' || typeof pnum == 'undefined' || typeof onum == 'undefined') {
13642                alert('정보가 올바르지 않습니다');
13643                return false;
13644            }
13645
13646            $.post('/_check_order', { sid:sid, pnum:pnum, onum:onum, mode:'return', ognum: ognum }, function(data) {
13647                var LUX = false;
13648                if(data.lux) LUX = data.lux;
13649
13650                if(typeof data.error != 'undefined' && data.error) {
13651                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'close');
13652                    return false;
13653                }
13654                var c_data = data.r, checkboxNone = '', noneAll = '', noneChecked = '', checkNoneAll = '', checkEscrowFooter = '', checkEscrowClass = '', checkEscrowExchangeFooter = '', checkDepositCancel = '';
13655                
13656                var checkEscrow = '', exchangeCheck = 'N';
13657                var dtl = c_data.delivery_template_list;
13658                var used_code_coupon = false;
13659                
13660                if (status == 'Y') {
13661                    checkboxNone = 'checked';
13662                    noneAll = ' noneAll';
13663                    checkNoneAll = 'fule';
13664                    checkEscrow = '<div class="escrow-warring top-escrow">\
13665                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="15" height="15">\
13666                                        <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"/>\
13667                                        <rect fill="#4789e7" x="6" y="3" width="1" height="5"/>\
13668                                        <rect fill="#4789e7" x="6" y="9" width="1" height="1"/>\
13669                                    </svg>\
13670                                    에스크로 결제 상품은 취소/반품 요청 시 전체선택만 가능합니다.\
13671                                </div>';
13672
13673                    checkEscrowFooter = '<div class="escrow-warring bottom-escrow">\
13674                                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="15" height="15">\
13675                                                <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"/>\
13676                                                <rect fill="#4789e7" x="6" y="3" width="1" height="5"/>\
13677                                                <rect fill="#4789e7" x="6" y="9" width="1" height="1"/>\
13678                                            </svg>\
13679                                            에스크로 환불 안내\
13680                                            <div class="escrow-return-info">- 취소처리 시 구매자의 환불정산액에서 취소 수수료(330원)가 차감됩니다.</div>\
13681                                            <div class="escrow-return-info">- 환불정산액은 취소처리 후 1~3영업일 후에 지급됩니다.</div>\
13682                                        </div>';
13683                    checkEscrowClass = 'cl-s-escrow-info';
13684
13685                    checkEscrowExchangeFooter = '\
13686                        <div class="escrow-warring escrow-exchange-warning bottom-escrow" style="display: none;">\
13687                            <div class="escrow-return-info">- 에스크로 결제 상품의 경우, 교환 요청/완료 시에는 반품이 불가능합니다.</div>\
13688                            <div class="escrow-return-info">- 자세한 사항은 판매자의 안내를 따라주세요.</div>\
13689                        </div>\
13690                    ';
13691                }
13692
13693                if(c_data.pay_info.coupon_list && c_data.pay_info.coupon_list.length) {
13694                    $.each(c_data.pay_info.coupon_list, function(k, v) {
13695                        if(v.kind == 'C') {
13696                            used_code_coupon = true;
13697                        }
13698                    })
13699                }
13700
13701                if(used_code_coupon) {
13702                    checkboxNone = 'checked';
13703                    noneAll = ' noneAll';
13704                    checkNoneAll = 'fule';
13705                    checkDepositCancel = '<div class="modal-comment deposit-cancel-desc codecoupon-cancel-desc">\
13706                                <div class="desc-box">\
13707                                    <div class="desc-title">코드쿠폰 사용 주문취소 안내</div>\
13708                                    <div class="section">- 코드쿠폰 사용 주문 건은 <span class="cl-red">전체 반품</span>만 가능합니다.</div>\
13709                                    <div class="section">- 전체 반품 후 구매를 원하는 상품은 다시 주문해주세요.</div>\
13710                                    ' + (c_data.order_status == 'W' ? '<div class="section">- 혹시나 입금을 하신 경우 별도로 문의 주시기 바랍니다.</div>' : '') + '\
13711                                </div>\
13712                            </div>\
13713                        ';
13714                        
13715                    checkEscrowExchangeFooter = '\
13716                    <div class="code-coupon-exchange-warning escrow-warring escrow-exchange-warning bottom-escrow" style="display: none;">\
13717                        <div class="escrow-return-info">- 코드 쿠폰이 적용된 주문건은 교환 접수 시 반품이 불가능합니다.</div>\
13718                        <div class="escrow-return-info">- 자세한 사항은 판매자의 안내를 따라주세요.</div>\
13719                    </div>\
13720                ';
13721                }
13722                
13723                var modal_str = '\
13724                    <form name="re_form" method="post" action="/_return_exchange">\
13725                        <input type="hidden" name="sid" value="' + sid + '">\
13726                        <input type="hidden" name="order_group" id="cancel-order-group" value="' + ognum + '">\
13727                        <input type="hidden" name="order_number" id="cancel-order-number" value="' + onum + '">\
13728                        <input type="hidden" name="m_status" value="M">\
13729                        <div class="cl-s-btn-group-toggle btn-group btn-group-toggle" data-toggle="buttons">\
13730                ';
13731
13732                if(status == 'Y' && data.r.exchange_check == true) {
13733                    modal_str += '\
13734                            <label class="btn btn-secondary disable">\
13735                                <input type="radio" name="status" id="order-radio-return" value="R"> 반품 요청\
13736                            </label>\
13737                            <label class="btn btn-secondary active">\
13738                                <input type="radio" name="status" id="order-radio-exchange" value="E" checked>
13738 교환 요청\
13739                            </label>\
13740                    ';
13741                } else {
13742                    modal_str += '\
13743                            <label class="btn btn-secondary active">\
13744                                <input type="radio" name="status" id="order-radio-return" value="R" checked> 반품 요청\
13745                            </label>\
13746                            <label class="btn btn-secondary">\
13747                                <input type="radio" name="status" id="order-radio-exchange" value="E"> 교환 요청\
13748                            </label>\
13749                    ';
13750                }
13751
13752                modal_str += '\
13753                        </div>\
13754                        '+checkEscrow+'\
13755                        <div class="cancel-product-title">\
13756                            <div class="newcheckbox hand">\
13757                                <label>\
13758                                    <input type="checkbox" class="'+noneAll+'" id="product-check" '+checkboxNone+'>\
13759                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
13760                                        <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"/>\
13761                                    </svg>\
13762                                    <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
13763                                        <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"/>\
13764                                    </svg>\
13765                                </label>\
13766                            </div>\
13767                            반품/교환요청 상품\
13768                        </div>';
13769                        var my_point = Number(data.r.my_point);
13770                        var gradeDeliveryBenefit = c_data.pay_info && c_data.pay_info.grade_delivery_benefit ? c_data.pay_info.grade_delivery_benefit : {};
13771                        var gradeDeliveryBenefitUsed = String(gradeDeliveryBenefit.used || '').toUpperCase() == 'Y';
13772                        var gradeDeliveryBenefitDiscount = gradeDeliveryBenefitUsed ? Number(gradeDeliveryBenefit.discount_price || 0) : 0;
13773                        var getPointCalcDeliveryPrice = function(deliveryPrice) {
13774                            deliveryPrice = Number(deliveryPrice || 0);
13775                            if(!gradeDeliveryBenefitUsed || gradeDeliveryBenefitDiscount <= 0) return deliveryPrice;
13776
13777                            return Math.max(deliveryPrice - gradeDeliveryBenefitDiscount, 0);
13778                        };
13779                        var weight_template_product = {};
13780
13781                        for (var i=0;i<data.r.odata.length;i++) {
13782                            if(c_data.odata[i].state != 'normal') return;
13783                            if (c_data.odata[i].exchange_check == 'Y') exchangeCheck = 'Y';
13784                            var dts = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_template_seq : '';
13785                            if(c_data.odata[i].state == 'normal' && c_data.odata[i].mix_yn != 'Y') dts += '-' + c_data.odata[i].product_number;
13786                            var dt = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_type : '';
13787
13788                            if(!weight_template_product.hasOwnProperty(dts)) weight_template_product[dts] = {};
13789                            if(!weight_template_product[dts].hasOwnProperty(dt)) weight_template_product[dts][dt] = {};
13790                            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];
13791
13792                            var tooltip = '';
13793                            if(dtl[dts]['price_type'] == 'WEIGHT' || dtl[dts]['price_type'] == 'QUANTITY') {
13794                                if(dtl[dts]['price_type_detail']['method'] == 'DIFFERENTIAL') {
13795                                    if(dtl[dts]['price_type'] == 'QUANTITY') {
13796                                        tooltip += '<li class=\'title\'>수량별 배송비</li>';
13797                                        $(dtl[dts]['price_type_detail']['detail']).each(function(k, detail) {
13798                                            var d_v = Object.keys(detail)[0];
13799                                            var d_p = detail[d_v];
13800                                            tooltip += '<li class=\'item\'>' + d_v + '개 이상 ' + number_format(d_p) + '원</li>';
13801                                        });
13802                                    } else if(dtl[dts]['price_type'] == 'WEIGHT') {
13803                                        tooltip += '<li class=\'title\'>무게별 배송비</li>';
13804                                        $(dtl[dts]['price_type_detail']['detail']).each(function(k, detail) {
13805                                            var d_v = Object.keys(detail)[0];
13806                                            var d_p = detail[d_v];
13807                                            tooltip += '<li class=\'item\'>' + d_v + 'Kg 이상 ' + number_format(d_p) + '원</li>';
13808                                        });
13809                                    }
13810                                } else if(dtl[dts]['price_type_detail']['method'] == 'REPEAT') {
13811                                    if(dtl[dts]['price_type'] == 'QUANTITY') {
13812                                        tooltip += '<li class=\'title\'>수량별 배송비</li>';
13813                                        tooltip += '<li class=\'item\'>' + number_format(dtl[dts]['repeat_value']) + '개 구매시마다 ' + number_format(dtl[dts]['repeat_price']) + '원 반복 부과</li>';
13814                                    } else if(dtl[dts]['price_type'] == 'WEIGHT') {
13815                                        tooltip += '<li class=\'title\'>무게별 배송비</li>';
13816                                        tooltip += '<li class=\'item\'>' + number_format(dtl[dts]['repeat_value']) + 'Kg마다 ' + number_format(dtl[dts]['repeat_price']) + '원 반복 부과</li>';
13817                                    }
13818                                }
13819                                if(tooltip && (dt == 'DELIVERY' || dt == 'DIRECT'))  {
13820                                    if(!LUX) tooltip += '<li class=\'desc\'>추가 상품은 배송비 조건에 반영되지 않습니다.</li>';
13821
13822                                    if(dtl[dts]['price_type'] == 'WEIGHT' && weight_template_product[dts][dt]) {
13823                                        tooltip += '<li class=\'title product-weight\'>상품별 무게</li>';
13824                                        $.each(weight_template_product[dts][dt], function(k, v) {
13825                                            tooltip += '<li class=\'item\'>' + v.product_name + ' : ' + number_format(v.product_weight) + 'kg</li>';
13826                                        });
13827                                    }
13828
13829                                    tooltip = '<ul class=\'delivery-tooltip\'>' + tooltip + '</ul>';
13830                                    dtl[dts]['tooltip'] = tooltip;
13831                                }
13832                            }
13833                        }
13834                        
13835                        modal_str += '<table class="table product-table">';
13836                        for (var i=0;i<data.r.odata.length;i++) {
13837                            if (c_data.odata[i].d_status == '' || c_data.odata[i].d_status == 'CN') {
13838                                noneChecked = '';
13839                                if (!checkNoneAll) noneAll = '';
13840                            } else {
13841                                if (!checkNoneAll) noneAll = 'noneAll';
13842                                noneChecked = 'noneChecked';
13843                            }
13844
13845                            var curr_point = 0;
13846                            var usable_point = 0;
13847                            var refund_point = 0;
13848                            var expired_point = 0;
13849
13850                            if(c_data.odata[i].used_point) {
13851                                curr_point = Math.abs(c_data.odata[i].used_point.point);
13852                                usable_point = Math.abs(c_data.odata[i].used_point.usable_point);
13853                            }
13854
13855                            // if(c_data.odata[i].refund_point) {
13856                            //     refund_point = c_data.odata
13857                            // }
13858
13859                            if(c_data.odata[i].expired_point) {
13860                                expired_point = Math.abs(c_data.odata[i].expired_point.point);
13861                            }
13862
13863                            var dts = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_template_seq : '';
13864                            if(c_data.odata[i].state == 'normal' && c_data.odata[i].mix_yn != 'Y') dts += '-' + c_data.odata[i].product_number;
13865                            var dt = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_type : '';
13866
13867                            modal_str += '\
13868                            <tr class="cl-s-product-jumbotron clearfix">\
13869                                <td>\
13870                                <div class="newcheckbox hand">\
13871                                    <label>\
13872                                        <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
13872+'" 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) +'">\
13873                                        <svg viewBox="0 0 16 16" width="16" height="16">\
13874                                            <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"/>\
13875                                        </svg>\
13876                                        <svg class="active" viewBox="0 0 16 16" width="16" height="16">\
13877                                            <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"/>\
13878                                        </svg>\
13879                                    </label>\
13880                                </div>\
13881                                <div class="cl-s-product-thumb">\
13882                                    <img src="' + c_data.pdata[i].img + '" alt="' + c_data.pdata[i].name + '" class="' + c_data.pdata[i].img_align + '" />\
13883                                </div>\
13884                                <div class="cl-s-product-info">\
13885                                    <h5 class="cl-s-product-title">' + c_data.pdata[i].name + '</h5>\
13886                            ';
13887
13888                            var price = c_data.odata[i].price,
13889                                quantity = Number(c_data.odata[i].quantity),
13890                                sum_price = quantity * price;
13891                                option_name = (typeof c_data.pdata[i].option != "undefined" && c_data.pdata[i].option) ? c_data.pdata[i].option : '',
13892                                option_str = '',
13893                                etc_str = (typeof c_data.pdata[i].etc_date != "undefined" && c_data.pdata[i].etc_date) ? '<span>선택일자: '+c_data.pdata[i].etc_date+'</span>' : '',
13894                                option_title = (c_data.pdata[i].option_type == 'A') ? '추가옵션: ' + (c_data.pdata[i].option_group ? c_data.pdata[i].option_group + ' : ' : '') : '옵션';
13895                            if(option_name) {
13896                                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>';
13897                            } else {
13898                                option_str = (c_data.pdata[i].option_text_str) ? '<span>' + option_title + ': '+c_data.pdata[i].option_text_str+'</span>' : '';
13899                            }
13900
13901                            modal_str += '\
13902                                    <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>\
13903                                </div>\
13904                            </td>';
13905
13906                            if(c_data.odata[i].state == 'normal') {
13907                                var delivery_cnt = dtl[dts]['dtype'][dt].delivery_cnt;
13908                                if(!dtl[dts]['dtype'][dt].hasOwnProperty('counter')) {
13909                                    dtl[dts]['dtype'][dt]['counter'] = 0;
13910                                }
13911
13912                                dtl[dts]['dtype'][dt]['counter']++;
13913
13914                                if(dtl[dts]['dtype'][dt]['counter'] == 1) {
13915                                    modal_str +='\
13916                                        <td rowspan="' + delivery_cnt + '" class="delivery-price"><div>배송비</div><div class="price"><span>';
13917                                    if(dt == 'DELIVERY' || dt == 'DIRECT') {
13918                                        if(dtl[dts]['price_type'] == 'ETC') {
13919                                            modal_str += '별도안내</span>';
13920                                        } else {
13921                                            modal_str += number_format(dtl[dts]['dtype'][dt]['price']) + '</span> 원';    
13922                                        }
13923                                        if(dtl[dts]['pay_type'] == 'DELIVERED') modal_str += '(착불)';
13924
13925                                        if(dtl[dts]['price_type'] == 'FREE_CONDITION') {
13926                                            modal_str += '<div class="price-desc">' + number_format(dtl[dts]['free_condition']) + '원 이상<br>배송비 무료</div>';
13927                                        }
13928                                    } else {
13929                                        modal_str += $.lang[LANG]['shopping.delivery.template.delivery_type.' + dt.toLowerCase()] + '</span>';
13930                                        if(dt == 'QUICK') modal_str += '(착불)';
13931                                    }
13932                                    if(dtl[dts]['tooltip'] && (dt == 'DELIVERY' || dt == 'DIRECT')) {
13933                                        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.
1393366 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>';
13934                                    }
13935                                    modal_str +='</div></td>\
13936                                    ';
13937                                }
13938
13939                                modal_str += '\
13940                                </tr>';
13941
13942                                if(dtl[dts]['dtype'][dt]['counter'] == dtl[dts]['dtype'][dt]['delivery_cnt']) {
13943                                    modal_str += '\
13944                                        <tr class="cl-s-product-jumbotron clearfix delivery-price delivery-price-mobile">\
13945                                            <td><div class="delivery-title">묶음 배송비</div><div class="delivey-price"><span>';
13946
13947                                    if(dtl[dts]['tooltip'] && (dt == 'DELIVERY' || dt == 'DIRECT')) {
13948                                        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>';
13949                                    }
13950
13951                                    if(dt == 'DELIVERY' || dt == 'DIRECT') {
13952                                        modal_str += number_format(dtl[dts]['dtype'][dt]['price']) + '</span> 원';
13953                                        if(dtl[dts]['pay_type'] == 'DELIVERED') modal_str += '(착불)';
13954                                        if(dtl[dts]['price_type'] == 'FREE_CONDITION') {
13955                                            modal_str += '<div class="price-desc">' + number_format(dtl[dts]['free_condition']) + '원 이상 배송비 무료</div>';
13956                                        }
13957                                    } else {
13958                                        modal_str += $.lang[LANG]['shopping.delivery.template.delivery_type.' + dt.toLowerCase()] + '</span>';
13959                                        if(dt == 'QUICK') modal_str += '(착불)';
13960                                    }
13961
13962                                    modal_str += '</div></td>\
13963                                        </tr>\
13964                                    ';
13965                                }
13966                            }
13967                        }
13968
13969                        modal_str += '</table>';
13970
13971                        modal_str += '<div class="order-re-content">\
13972                            <div class="cl-s-form-selector">\
13973                                <select class="selectpicker dropdown" id="re-reason" name="reason">\
13974                                    <option value="구매의사 취소">구매의사 취소</option>\
13975                                    <option value="다른 상품 잘못 주문">다른 상품 잘못 주문</option>\
13976                                    <option value="상품파손">상품파손</option>\
13977                                    <option value="배송지연">배송지연</option>\
13978                                    <option value="상품정보 상이">상품정보 상이</option>\
13979                                    <option value="오배송">오배송</option>\
13980                                    <option value="기타">기타</option>\
13981                                </select>\
13982                                <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>\
13983                            </div>\
13984                            <div class="cl-s-form-wrap">\
13985                                <div class="cl-s-form-group input-label-hide">\
13986                                    <textarea class="cl-s-form-control cl-s-form-textarea" id="re-requests" name="requests" maxlength="500" required="required"></textarea>\
13987                                    <label for="input" class="cl-s-control-label">자세한 내용을 적어주세요. (500자 이내)</label>\
13988                                </div>\
13989                            </div>\
13990                        </div>';
13991                        /*  반품/교환 사진 제거
13992                            <div class="cl-s-files re-files">\
13993                                <input id="re-file" type="file" name="files[]" multiple data-sid="' + sid + '" data-uid=\"' + c_data.writer.id + '\">\
13994                                <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>\
13995                                <ul class="cl-s-files-list re-files-list clearfix">\
13996                                </ul>\
13997                            </div>\
13998                        */
13999
14000                        modal_str += checkEscrowExchangeFooter;
14001
14002                        modal_str += '<div class="order-cancel-content">\
14003                            <div class="cancel-info-box">\
14004                                <div class="cancel-info"><span class="cancel-info-title">반품상품 합계</span><span class="cancel-info-price" id="cancel-price">0원</span></div>\
14005                                <div class="cancel-info"><span class="cancel-info-title">반품 배송비 합계</span><span class="cancel-info-price" id="cancel-delivery-price">0원</span></div>\
14006                                <div class="cancel-info"><span class="cancel-info-title">적립금</span><span class="cancel-info-price" id="cancel-point-price">0원</span></div>\
14007                                <div class="cancel-info"><span class="cancel-info-title">쿠폰</span><span class="cancel-info-price" id="cancel-coupon-price">0원</span></div>\
14008                                <div class="cancel-info"><span class="cancel-info-title">
14008등급할인</span><span class="cancel-info-price" id="cancel-grade-discount-price">0원</span></div>\
14009                                <div class="cancel-info"><span class="cancel-info-title cancel-coupon-title"></span><span class="cancel-info-price" id="cancel-coupon-detail"></span></div>\
14010                                <div class="cancel-info-line"></div>\
14011                                <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>\
14012                            </div>'+checkEscrowFooter+'\
14013                        </div>';
14014                        modal_str += checkDepositCancel;
14015                    
14016                    if (pclass == '무통장 입금' || pclass == '가상계좌') {
14017                        var returnClass = '';
14018                        if (c_data.return_bank.length > 1 && c_data.return_bank.indexOf('')===-1) returnClass = 'returnDisabled';
14019
14020                        modal_str += '\
14021                            <div id="return-modal">\
14022                                <div class="modal-sub-title">환불 계좌</div>\
14023                                <ul class="qna-writer clearfix">\
14024                                    <li class="">\
14025                                        <div class="cl-s-form-wrap '+returnClass+'">\
14026                                            <div class="cl-s-form-group">';
14027                                            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]+'">';
14028                                            else modal_str += '<input type="text" class="cl-s-form-control" id="no-bank" name="no_bank" required="required" value="">';
14029                                            modal_str += '<label for="input" class="cl-s-control-label">은행명</label>\
14030                                            </div>\
14031                                        </div>\
14032                                    </li>\
14033                                    <li>\
14034                                        <div class="cl-s-form-wrap '+returnClass+'">\
14035                                            <div class="cl-s-form-group">';
14036                                            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]+'">';
14037                                            else modal_str += '<input type="text" class="cl-s-form-control" id="no-bank-name" name="no_bank_name" required="required">';
14038                                            modal_str += '<label for="input" class="cl-s-control-label">예금주</label>\
14039                                            </div>\
14040                                        </div>\
14041                                    </li>\
14042                                    <li>\
14043                                        <div class="cl-s-form-wrap '+returnClass+'">\
14044                                            <div class="cl-s-form-group">';
14045                                            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]+'">';
14046                                            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="">';
14047                                            modal_str += '<label for="input" class="cl-s-control-label">계좌번호</label>\
14048                                            </div>\
14049                                        </div>\
14050                                    </li>\
14051                                </ul>\
14052                                <div class="modal-comment">동일 주문 내 여러 상품을 환불 요청하시는 경우, ì
14052µœì´ˆ 입력한 환불계좌로 일괄 환불처리됩니다.</div>\
14053                                <div class="modal-comment point-used-desc hide">\
14054                                    <div class="desc-box">\
14055                                        <div class="desc-title">적립금 환불 안내</div>\
14056                                        <div class="section">상품(들)을 구매하여 적립된 적립금 <span id="disp_used_point_total" class="point-color"></span>원이 이미 사용되거나 유효기간이 만료되었습니다.</div>\
14057                                        <div class="section">현재 보유 적립금이 <span class="point-color">' + addCommas(my_point) + '</span>원 으로 구매 적립된 적립금 <span id="disp_cancel_after_point" class="point-color"></span>원을 취소 처리할 수 없습니다.</div>\
14058                                        <div class="section">미 취소된 적립금에 대한 처리는 판매자와 협의해주세요.</div>\
14059                                    </div>\
14060                                    <div class="newcheckbox hand">\
14061                                        <label style="margin-left: 25px;">\
14062                                            <input type="checkbox" class="cancel-agree" />\
14063                                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
14064                                                <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>\
14065                                            </svg>\
14066                                            <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
14067                                                <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>\
14068                                            </svg>\
14069                                        위 내용을 확인하였습니다.</label>\
14070                                    </div>\
14071                                    <div class="point-used-cancel-agree-desc">\
14072                                        <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>\
14073                                        적립금 환불 안내에 동의해주세요.\
14074                                    </div>\
14075                                </div>\
14076                            </div>\
14077                        ';
14078                    }
14079                    modal_str += '</form>\
14080                ';
14081                
14082                var oreModal = $(this).showModalFlat('반품/교환 요청', modal_str,true,true,function () {
14083
14084                    var f = document.re_form;
14085
14086                    if(oreModal.find('#re-reason').prop('value') == '') {
14087                        // $('#re-reason').selectpicker('toggle');
14088                        // return false;
14089                        $('#re-reason').closest('.cl-s-form-selector').addClass('empty');
14090                    }
14091
14092                    oreModal.find('.cl-s-form-wrap').each(function() {
14093                        var check_input = $(this).find('.cl-s-form-control'),
14094                            val = check_input.val().trim();
14095
14096                        if(val.length == 0) {
14097                            $(this).removeClass('error').addClass('empty');
14098                            $(this).find('.cl-s-control-label.error').remove();
14099                        } else {
14100                            if($(this).hasClass('error')) {
14101                                check_input.focus();
14102                            }
14103                        }
14104                    });
14105                    var checkCnt = 0;
14106
14107                    $(".status-checkbox").each(function (i, index) {
14108                        if ($(this).is(":checked") === true) {
14109                            checkCnt++;
14110                        }
14111                    });
14112
14113                    if (checkCnt < 1) {
14114                        alert('상품을 1개 이상 선택해 주세요');
14115                        return false;
14116                    }
14117
14118                    if(oreModal.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').length > 0) {
14119                        // oreModal.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').eq(0).find('.cl-s-form-control').focus();
14120                        return false;
14121                    }
14122
14123
14124                    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) {
14125                        $(".point-used-cancel-agree-desc").show();
14126                        return false;
14127                    } else {
14128                        $(".point-used-cancel-agree-desc").hide();
14129                    }
14130
14131                    var activeStatus = oreModal.find('.cl-s-btn-group-toggle .btn-secondary.active input[name="status"]').val();
14132                    if(activeStatus) {
14133                        oreModal.find('input[name="status"][value="' + activeStatus + '"]').prop('checked', true);
14134                        oreModal.find('input[name="status"]').not('[value="' + activeStatus + '"]').prop('checked', false);
14135                    }
14136
14137                    $.processON();
14138
14139                    f.submit();
14140
14141                },'close','등록하기','cl-s-order-returnexchange cl-s-order-cancel cl-modal cl-s-btn cover ' + checkEscrowClass, false, '', function() {
14142                    var totalCnt = 0, totalNomalCheck = 0, nomalCheck = 0;
14143                    var price = 0;
14144                    var deliveryPrice = 0;
14145                    var gradeDiscountPrice = 0;
14146                    
14147                    var mix_yn = $(this).data('mix_yn');
14148                    var delivery_price = 0;
14149                    var $form = $('form[name="re_form"]');
14150                    
14151                    $('.status-checkbox').each(function(i, index) {
14152                        if ($(this).is(":checked") === true) {
14153                            price += ($(this).closest('.cl-s-product-jumbotron').find('.option-check').attr('data-optionPrice') * 1);
14154                            gradeDiscountPrice += Number($(this).data('grade_discount_price') || 0);
14155                            totalCnt++;
14156                            if ($(this).attr('data-type') == 'normal') {
14157                                nomalCheck++;
14158                                var mix_yn = $(this).data('mix_yn');
14159                                var delivery_price = 0;
14160                                var delivery_template_seq = $(this).data('delivery_template_seq');
14161                                var delivery_type = $(this).data('delivery_type');
14162                                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) {
14163                                    delivery_price = Number($(this).data('delivery_price'));
14164                                }
14165                                deliveryPrice += delivery_price;
14166                            }
14167                        }
14168
14169                        if ($(this).attr('data-type') == 'normal') {
14170                            totalNomalCheck++;
14171                        }
14172                    });
14173
14174                    var product_price = price + getPointCalcDeliveryPrice(deliveryPrice),
14175                        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);
14176
14177                    rePayment = (rePayment > 0) ? rePayment : 0;
14178
14179                    // coupon 처리
14180                    var coupon = c_data.pay_info.coupon_list,
14181                        cancel_coupon_price = 0;
14182                    if(coupon.length) {
14183                        var checked_order_number = $('.cancel-info-data:checked').map(function(){ return this.value; }).toArray();
14184                        $.each(coupon, function(i,v) {
14185                            if(checked_order_number.indexOf(v.order_number) > -1 || v.kind == 'C') {
14186                                cancel_coupon_price += parseInt(v.discount_price);
14187
14188                                // 환불금에서 쿠폰처리
14189                                if($('.coupon-detail-info[data-seq="' + v.seq + '"]').length == 0) {
14190                                    $('.cancel-coupon-title').append('<div class="coupon-name coupon-detail-info" data-seq="' + v.seq + '">' + v.coupon_name + '</div>');
14191                                    $('#cancel-coupon-detail').append('<div class="coupon-price coupon-detail-info" data-seq="' + v.seq + '">-' + number_format(parseInt(v.discount_price)) + '원</div>');
14192                                }
14193                            } else {
14194                                $('.coupon-detail-info[data-seq="' + v.seq + '"]').remove();
14195                            }
14196                        });
14197                        // 취소된 쿠폰 저장
14198                        
14199                    }
14200                    product_price = product_price - parseInt(cancel_coupon_price);
14201                    product_price = product_price - gradeDiscountPrice;
14202
14203                    var use_point = (rePayment - product_price > 0) ? 0 : rePayment - product_price;
14204                    product_price = product_price + use_point;
14205
14206                    $('#cancel-price').html(number_format(price)+'원');
14207                    $('#cancel-delivery-price').html(number_format(deliveryPrice)+'원');
14208                    $('#cancel-point-price').html(number_format(use_point)+'원');
14209                    $('#cancel-coupon-price').html(((cancel_coupon_price > 0) ? '-' + number_format(cancel_coupon_price) : '0')+'원');
14210                    $('#cancel-grade-discount-price').html(((gradeDiscountPrice > 0) ? '-' + number_format(gradeDiscountPrice) : '0')+'원');
14211                    $('#return-total-price').html(number_format(product_price));
14212
14213                    $('.cancel-info-data').on('change', function () {
14214                        if($(this).hasClass('noneAll')) return;    
14215                        var cancel_after_point = my_point;
14216                        var disp_used_point_total = 0;
14217                        var deliveryPrice = 0;
14218
14219                        var product_number = $(this).attr('data-product_number');
14220                        // console.log(product_number);
14221                        if($('input[name="status"]:checked').val() == 'R') { // 반품일때만 
14222                            if($(this).attr('data-option_type') != 'A' && !$('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:not(:checked)').length) {
14223                                $('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type="A"]').prop('checked',true);
14224                            } 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')) {
14225                                $('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:last').prop('checked',fal
14225se);
14226                            }
14227                        }
14228
14229                        if($("input[name='order_number_ary[]']:checked").length) {
14230                            coupon.map(function(v,k) { coupon[k]['apply'] = '';  });
14231                            $("input[name='order_number_ary[]']:checked").each(function() {
14232                                cancel_after_point = Number(cancel_after_point) + ((Number($(this).data("expired_point"))) - Number($(this).data("curr_point")));
14233                                disp_used_point_total += ((Number($(this).data("expired_point"))) - Number($(this).data("curr_point")));
14234                                c_ord_num = $(this).val();
14235
14236                                if($(this).data('type') != 'normal' || $(this).data('option_type') == 'A') return;
14237                                var mix_yn = $(this).data('mix_yn');
14238                                var delivery_price = 0;
14239                                var delivery_template_seq = $(this).data('delivery_template_seq');
14240                                var delivery_type = $(this).data('delivery_type');
14241                                var product_weight = $(this).data('product_weight');
14242
14243                                
14244
14245                                if(delivery_type != 'DELIVERY' && delivery_type != 'DIRECT') return;
14246                                // if(dtl[delivery_template_seq]['price_type'] != 'WEIGHT' && dtl[delivery_template_seq]['price_type'] != 'QUANTITY') {
14247                                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) {
14248                                    delivery_price = Number($(this).data('delivery_price'));
14249
14250                                    coupon.map(function(v,k) { if(v.order_number == c_ord_num && delivery_price > 0 && v.benefit == 'DELIVERY') coupon[k]['apply'] = '1';  });
14251                                } 
14252                                deliveryPrice += delivery_price;
14253                            });
14254                        }
14255
14256                        if(cancel_after_point < 0) {
14257                            $(".point-used-desc #disp_cancel_after_point").html(addCommas(Math.abs(cancel_after_point)));
14258                            $(".point-used-desc #disp_used_point_total").html(addCommas(Math.abs(disp_used_point_total)));
14259                            $(".point-used-desc").removeClass("hide");
14260                        } else {
14261                            $(".point-used-desc").addClass("hide");
14262                            $(".point-used-desc #disp_cancel_after_point").html("");
14263                            $(".point-used-desc #disp_used_point_total").html("");
14264                        }
14265
14266                        var price = 0;
14267                        var gradeDiscountPrice = 0;
14268                        var oLength = $('.option-check').length;
14269                        var totalCnt = 0, totalNomalCheck = 0, nomalCheck = 0;
14270                        var isReturn = $('input[name="status"]:checked').val();
14271
14272
14273                        $form.find('.order-cancel-content.extra-info').remove();
14274
14275                        if ($(this).hasClass('noneAll') === true) {
14276                            if ($(this).hasClass('noneChecked') === true) {
14277                                $(this).prop('checked', false);
14278                            } else {
14279                                $(this).prop('checked', true);
14280                                $('.status-checkbox').each(function () {
14281                                    if ($(this).prop('disabled') !== true) $(this).prop('checked', true);
14282                                });
14283                            }
14284                        }
14285
14286                        $('.status-checkbox').each(function (i, index) {
14287                            if ($(this).is(':checked') === true) {
14288                                price += ($(this).closest('.cl-s-product-jumbotron').find('.option-check').attr('data-optionPrice') * 1);
14289                                gradeDiscountPrice += Number($(this).data('grade_discount_price') || 0);
14290                                totalCnt++;
14291                                if ($(this).attr('data-type') == 'normal') {
14292                                    nomalCheck++;
14293                                }
14294                            }
14295
14296                            if ($(this).attr('data-type') == 'normal') {
14297                                totalNomalCheck++;
14298                            }
14299                        });
14300
14301                        var product_price = price + getPointCalcDeliveryPrice(deliveryPrice),
14302                            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);
14303
14304                        rePayment = (rePayment > 0) ? rePayment : 0;
14305
14306
14307                        // coupon 처리
14308                        var cancel_coupon_price = 0;
14309                        if(coupon.length) {
14310                            var checked_order_number = $('.cancel-info-data:checked').map(function(){ return this.value; }).toArray();
14311                            $.each(coupon, function(i,v) {
14312                                v.apply = (v.apply || v.benefit != 'DELIVERY') ? '1' : '';
14313                                if((checked_order_number.indexOf(v.order_number) > -1 && v.apply) || v.kind == 'C') {
14314                                    cancel_coupon_price += parseInt(v.discount_price);
14315
14316                                    // 환불금에서 쿠폰처리
14317                                    if($('.coupon-detail-info[data-seq="' + v.seq + '"]').length == 0) {
14318                                        $('.cancel-coupon-title').append('<div class="coupon-name coupon-detail-info" data-seq="' + v.seq + '">' + v.coupon_name + '</div>');
14319                                        $('#cancel-coupon-detail').append('<div class="coupon-price coupon-detail-info" data-seq="' + v.seq + '">-' + number_format(parseInt(v.discount_price)) + '원</div>');
14320                                    }
14321                                } else {
14322                                    $('.coupon-detail-info[data-seq="' + v.seq + '"]').remove();
14323                                }
14324                            });
14325                            // 취소된 쿠폰 저장
14326                        }
14327                        product_price = product_price - parseInt(cancel_coupon_price);
14328                        product_price = product_price - gradeDiscountPrice;
14329                        
14330                        var use_point = (rePayment - product_price > 0) ? 0 : rePayment - product_price;
14331                        product_price = product_price + use_point;
14332                        
14333                        $('#cancel-price').html(number_format(price)+'원');
14334                        $('#cancel-delivery-price').html(number_format(deliveryPrice)+'원');
14335                        $('#cancel-point-price').html(number_format(use_point)+'원');
14336                        $('#cancel-grade-discount-price').html(((gradeDiscountPrice > 0) ? '-' + number_format(gradeDiscountPrice) : '0')+'원');
14337                        $('#cancel-coupon-price').html(((cancel_coupon_price > 0) ? '-' + number_format(cancel_coupon_price) : '0')+'원');
14338                        $('#return-total-price').html(number_format((product_price>0) ? product_price : '0'));
14339
14340                        var priceSumArr = [];
14341                        var extra_charge_flag = {};
14342                        if(oreModal.find('.cancel-info-data:checked').length) {
14343                            oreModal.find('.cancel-info-data:checked').each(function() {
14344                                if($(this).data('type') != 'normal') 
14345                                    return;
14346
14347                                var dts = $(this).data('delivery_template_seq');
14348                                if(dtl[dts]['price_type'] != 'FREE_CONDITION') return;
14349                                var dt = $(this).data('delivery_type');
14350                                if(dt != 'DELIVERY' && dt != 'DIRECT') return;
14351
14352                                if(!priceSumArr.hasOwnProperty(dts)) {
14353                                    priceSumArr[dts] = [];
14354                                }
14355                                if(!priceSumArr[dts].hasOwnProperty(dt)) {
14356                                    priceSumArr[dts][dt] = 0;
14357                                }
14358                                // cancel_after_point = Number(cancel_after_point) + ((Number($(this).data("usable_point")) + Number($(this).data("expired_point"))) - Number($(this).data("curr_point")));
14359                                var selectedPrice = 0;
14360                                selectedPrice = Number($(this).closest('tr').find('[data-optionprice]').data('optionprice'));
14361                                priceSumArr[dts][dt] += selectedPrice;
14362
14363                                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) {
14364                                    extra_charge_flag[dts + '|' + dt] = true;
14365                                } else {
14366                                    extra_charge_flag[dts + '|' + dt] = false;
14367                                }
14368                            });
14369                        }
14370
14371                        extra_charge_info($form, 'R', Object.values(extra_charge_flag).indexOf(true) > -1 ? true : false, false);
14372
14373                        if($('input[name="order_number_ary[]"]').length == $('input[name="order_number_ary[]"]:checked').length) $('#product-check').prop('checked', true);
14374                        else $('#product-check').prop('checked', false);
14375                    });
14376
14377                    $(document).on('click', '#product-check', function () {
14378                        var price = 0;
14379                        var deliveryPrice = 0;
14380                        var totalCnt = 0,
14381                            isReturn = $('input[name="status"]:checked').val();
14382                        $form.find('.order-cancel-content.extra-info').remove();   
14383                        if ($(this).hasClass('noneAll') === true) {
14384                            $(this).prop('checked', true);
14385                            $(".status-checkbox").each(function () {
14386                                if ($(this).prop('disabled') !== true) $(this).prop('checked', true).change();
14387                            });
14388                        }
14389                        if ($(this).is(':checked') === true) {
14390                            $('.status-checkbox').each(function (i) {
14391                                if ($(this).prop('disabled') !== true) {
14392                                    $(this).prop('checked', true).change();
14393                                }
14394                            });
14395                        } else {
14396                            $(".status-checkbox").each(function () {
14397                                if ($(this).prop('disabled') !== true) $(this).prop('checked', false).change();
14398                            });
14399
14400                            $('#cancel-price').html('0원');
14401                            $('#cancel-delivery-price').html('0원');
14402                            $('#cancel-point-price').html('0원');
14403                            $('#cancel-grade-discount-price').html('0원');
14404                            $('#return-total-price').html('0');
14405                        }
14406                    });
14407
14408                    /* first option setting */
14409                    $('.cl-s-order-returnexchange .cl-s-form-selector').each(function(e) {
14410                        var checkSelectOption = ($(this).find('select option').length > 0) ? true : false;
14411                        if(checkSelectOption) {
14412                            var selectId = $(this).find('select').attr('id'),
14413                                val = $(this).find('select').children().eq(0).val();
14414                            $(this).find('select').selectpicker({'val':val, dropupAuto:false});
14415                        }
14416                    });
14417
14418                    $('#re-reason').on({
14419                        'show.bs.select': function (e) {
14420                            $(this).closest('.cl-s-form-selector').addClass('active');
14421                        },
14422                        'hidden.bs.select': function(e) {
14423                            $(this).closest('.cl-s-form-selector').removeClass('active');
14424
14425                            if($('#re-reason').prop('value') == '') {
14426                                $(this).closest('.cl-s-form-selector').addClass('empty');
14427                            } else {
14428                                $(this).closest('.cl-s-form-selector').removeClass('empty');
14429                            }
14430                        },
14431                        'changed.bs.select': function (e, clickedIndex, newValue, oldValue) {
14432                            // console.log(this.value, clickedIndex, newValue, oldValue);
14433                        }
14434                    });
14435
14436
14437                    $('.cl-s-order-returnexchange .cl-s-form-group').on('click',function(e) {
14438                        if($(e.target).hasClass('cl-s-form-group')) {
14439                            $(e.target).find('.cl-s-form-control:not([type=hidden])').focus();
14440                        }
14441                    });
14442
14443
14444                    $('.cl-s-order-returnexchange .cl-s-form-textarea').on({
14445                        focus: function(e) {
14446                            $(this).closest('.cl-s-form-wrap').addClass('active');
14447                        },
14448                        blur: function(e) {
14449                            var error_str = '',
14450                                val = $(this).val().trim();
14451
14452                            $(this).closest('.cl-s-form-wrap').removeClass('active');
14453                            if(val.length == 0) {
14454                                $(this).closest('.cl-s-form-wrap').removeClass('error').addClass('empty');
14455                                $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
14456                                return false;
14457                            } else {
14458                                $(this).closest('.cl-s-form-wrap').removeClass('empty');
14459
14460                                if(checkEmojis(val)) error_str = $.lang[LANG]['config.unable.emoji'];
14461                                else if(val.length < 5) error_str = $.lang[LANG]['customsite.validate.message.minlengthto5'];
14462
14463                                if(error_str.length > 0) {
14464                                    $(this).closest('.cl-s-form-wrap').addClass('error');
14465                                    if($(this).parent().find('.cl-s-control-label.error').length > 0) {
14466                                        $(this).parent().find('.cl-s-control-label.error').html(error_str);
14467                                    } else {
14468                                        $(this).after('<label for="input" class="cl-s-control-label error">' + error_str + '</label>');
14469                                    }
14470                                    return false;
14471                                }
14472                            }
14473
14474                            $(this).closest('.cl-s-form-wrap').removeClass('error');
14475                            $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
14476                        }
14477                    });
14478
14479                    $('.cl-s-form-wrap .cl-s-form-control').on({
14480                        focus: function(e) {
14481                            $(this).closest('.cl-s-form-wrap').addClass('active');
14482                        },
14483                        blur: function(e) {
14484                            var val = $(this).val().trim();
14485
14486                            $(this).closest('.cl-s-form-wrap').removeClass('active');
14487                            if(val.length == 0) {
14488                                $(this).closest('.cl-s-form-wrap').removeClass('error').addClass('empty');
14489                                $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
14490                                return false;
14491                            } else {
14492                                $(this).closest('.cl-s-form-wrap').removeClass('empty');
14493
14494                                if(checkEmojis(val)) {
14495                                    $(this).closest('.cl-s-form-wrap').addClass('error');
14496                                    if($(this).parent().find('.cl-s-control-label.error').length > 0) {
14497                                        $(this).parent().find('.cl-s-control-label.error').html($.lang[LANG]['config.unable.emoji']);
14498                                    } else {
14499                                        $(this).after('<label for="input" class="cl-s-control-label error">' + $.lang[LANG]['config.unable.emoji'] + '</label>');
14500                                    }
14501                                    return false;
14502                                }
14503                            }
14504
14505                            $(this).closest('.cl-s-form-wrap').removeClass('error');
14506                            $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
14507                        }
14508                    });
14509
14510
14511
14512                    $(document).on('click', '.cl-s-order-returnexchange .re-img-close', function() {
14513                        $(this).closest('li').remove();
14514                    })
14515
14516                    $('.cl-s-order-returnexchange .re-file-update').on('click', function () {
14517                        $("#re-file").click();
14518                    });
14519
14520                    $('.cl-s-order-returnexchange #re-file').on({
14521                        click: function () {
14522
14523                            var reImageCnt = $('.re-files-list').children('li').length;
14524                            if (reImageCnt >= 5) {
14525                                alert('이미지는 최대 5개까지 등록이 가능합니다.');
14526                                return false;
14527                            }
14528
14529                            var sid = $('#re-file').attr('data-sid'),
14530                                uid = $('#re-file').attr('data-uid');
14531
14532                            $.uploadON();
14533                            $(this).fileupload({
14534                                url: '/_upload/type/re/sid/'+sid+'/uid/'+uid,
14535                                dataType: 'json',
14536                                pasteZone: null,
14537                                async: true,
14538                                sequentialUploads: true,
14539                                add: function(e, data) {
14540                                    var r = $.upload_add(e,data,'image');
14541
14542                                    if(r.submit) {
14543                                        var jqXHR = data.submit();
14544                                        UPLOAD++;
14545                                    } else {
14546                                        data.context.find('.loading').html('<i class="fa fa-times error"></i>');
14547                                        data.context.find('.ing').addClass('error').text(r.err);
14548                                    }
14549
14550                                    $('.uploadModal .upload-cancel .btn, .uploadModal .upload-close').off('click').on('click', function(e) {
14551                                        if(jqXHR != undefined) jqXHR.abort();
14552                                        data.context.fadeOut().remove();
14553                                        $('.uploadModal #file-upload-progress').css('width','0%');
14554                                        $.uploadOFF();
14555                                        UPLOAD = 0;
14556                                        UPLOADED = 0;
14557                                        PROGRESS = 0;
14558                                    });
14559                                },
14560                                progress: function(e, data) {
14561                                    $.upload_progress(e,data);
14562                                },                        
14563                                done: function(e, data) {
14564                                    $.upload_done(e,data);
14565                                    UPLOADED++;
14566                                    var src = (typeof data.result.magic != 'undefined') ? data.result.magic : data.result.src;
14567                                    var reImage = '\
14568                                        <li id="re-image-'+reImageCnt+'">\
14569                                            <img src="'+src+'" class="img-responsive" />\
14570                                            <input type="hidden" name="review_image[]" value="'+src+'" />\
14571                                            <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
14571-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>\
14572                                        </li>\
14573                                    ';
14574
14575                                    $(".cl-s-order-returnexchange .re-files-list").append(reImage);
14576                                    reImageCnt++;
14577
14578                                    if(UPLOADED) {
14579                                        if(UPLOAD==UPLOADED) {
14580                                            setTimeout(function() {
14581                                                $.uploadOFF();
14582                                                UPLOAD = 0;
14583                                                UPLOADED = 0;
14584                                                PROGRESS = 0;
14585                                            },1000);
14586                                        }
14587                                    }
14588                                },
14589                                progressall: function (e, data) {
14590                                    $.upload_progressall(e,data);
14591                                },
14592                                start : function(e, data) {
14593                                    $.upload_start(e,data);
14594                                    progress1 = 0; progress2 = 0; PROGRESS = 0;
14595                                },
14596                                dragover : function(e, data) {
14597                                    e.preventDefault();
14598                                },
14599                            }).prop('disabled', !$.support.fileInput)
14600                                .parent().addClass($.support.fileInput ? undefined : 'disabled');
14601                        }
14602                    });
14603                    if(status == 'Y') {
14604                        $('.status-checkbox').off('change');
14605                    }
14606                    if(status == 'Y' && data.r.exchange_check == true) {
14607                        $('.btn-group-toggle').off('click');
14608                        // console.log(oreModal.find('[btn-toggle="buttons"] .btn-secondary.disable'));
14609                        oreModal.find('[data-toggle="buttons"] .btn-secondary.disable').on('click', function(e) {
14610                            e.preventDefault();
14611                            e.stopPropagation();
14612                            alert('에스크로 결제 상품은 교환 요청/완료가 있는 경우 반품 요청이 불가능합니다.\n기타 요청이 있는 경우 관리자
14612에게 문의해 주세요.');
14613                            return false;
14614                        });
14615                    }
14616                    
14617                    oreModal.find('[data-toggle="popover"]').popover();
14618                });
14619
14620                var used_code_coupon = false;
14621                var coupon = c_data.pay_info.coupon_list;
14622                if(coupon.length) {
14623                    $.each(coupon, function(i,v) {
14624                        if(v.kind == 'C') used_code_coupon = true;
14625                    });
14626                }
14627
14628                $('.cl-s-order-returnexchange .cl-s-btn-group-toggle input:radio').on({
14629                    change: function() {
14630                        var order_status = $(this).val(),
14631                            re_reason_obj = {
14632                            'R' : '\
14633                                <option value="구매의사 취소">구매의사 취소</option>\
14634                                <option value="다른 상품 잘못 주문">다른 상품 잘못 주문</option>\
14635                                <option value="상품파손">상품파손</option>\
14636                                <option value="배송지연">배송지연</option>\
14637                                <option value="상품정보 상이">상품정보 상이</option>\
14638                                <option value="오배송">오배송</option>\
14639                                <option value="기타">기타</option>\
14640                            ',
14641                            'E' : '\
14642                                <option value="컬러 및 사이즈 변경">컬러 및 사이즈 변경</option>\
14643                                <option value="다른 상품 잘못 주문">다른 상품 잘못 주문</option>\
14644                                <option value="상품파손">상품파손</option>\
14645                                <option value="상품정보 상이">상품정보 상이</option>\
14646                                <option value="오배송">오배송</option>\
14647                                <option value="기타">기타</option>\
14648                            '
14649                        };
14650                        $('.order-candel-content.extra-info').remove();
14651                        $(this).closest('.btn-group-toggle').find('.btn-secondary').removeClass('active');
14652                        $(this).parent('.btn-secondary').addClass('active');
14653                        $(this).prop('checked', true);
14654                        $(this).closest('.btn-group-toggle').find('input:radio').not(this).prop('checked', false);
14655
14656                        if (order_status == 'R') {
14657                            if (status == 'Y' && data.r.exchange_check == true) {
14658                                alert('에스크로 결제 상품은 교환 요청/완료가 있는 경우 반품 요청이 불가능합니다.\n기타 요청이 있는 경우 관리자
14658에게 문의해 주세요.');
14659                                setTimeout(function () {
14660                                    $('#order-radio-exchange').click();
14661                                }, 500);
14662                                return false;
14663                            } else if(used_code_coupon && data.r.exchange_check == true) {
14664                                alert('코드 쿠폰이 적용된 주문건은 교환 접수 시 반품이 불가능합니다.\n자세한 사항은 판매자의 안내를 따라주세요.');
14665                                setTimeout(function() {
14666                                    $('#order-radio-exchange').click();
14667                                });
14668                                return false;
14669                            }
14670                            
14671                            $('#return-modal').css('display', 'block');
14672                            $('.order-cancel-content').css('display', 'block');
14673                            $('#no-bank').parent().parent().addClass('cl-s-form-wrap');
14674                            $('#no-bank-name').parent().parent().addClass('cl-s-form-wrap');
14675                            $('#no-bank-number').parent().parent().addClass('cl-s-form-wrap');
14676                            $('.code-coupon-exchange-warning').hide();
14677
14678                            if (status == 'Y') {
14679                                $('.status-checkbox').each(function () {
14680                                    $(this).prop('checked', true);
14681                                    $(this).addClass('noneAll');
14682                                });
14683                                $('#product-check').addClass('noneAll');
14684                                $('#product-check').prop('checked', true);
14685                                $('.escrow-warring').css({'display': 'block'});
14686                                $('.escrow-exchange-warning').hide();
14687                            } else if(used_code_coupon) {
14688                                $('.status-checkbox').each(function () {
14689                                    $(this).prop('checked', true);
14690                                    $(this).addClass('noneAll');
14691                                });
14692                                $('#product-check').addClass('noneAll');
14693                                $('#product-check').prop('checked', true);
14694                            }
14695                            var totalCnt = 0, totalNomalCheck = 0, nomalCheck = 0;
14696                            var price = 0;
14697                            var deliveryPrice = 0;
14698                            var gradeDiscountPrice = 0;
14699                            $(".status-checkbox").each(function (i, index) {
14700                                if ($(this).is(":checked") === true) {
14701                                    price += ($(this).closest('.cl-s-product-jumbotron').find('.option-check').attr('data-optionPrice') * 1);
14702                                    gradeDiscountPrice += Number($(this).data('grade_discount_price') || 0);
14703                                    totalCnt++;
14704                                    if ($(this).attr('data-type') == 'normal') {
14705                                        nomalCheck++;
14706                                        var mix_yn = $(this).data('mix_yn');
14707                                        var delivery_price = 0;
14708                                        var delivery_template_seq = $(this).data('delivery_template_seq');
14709                                        var delivery_type = $(this).data('delivery_type');
14710                                        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) {
14711                                            delivery_price = Number($(this).data('delivery_price'));
14712                                        }
14713                                        deliveryPrice += delivery_price;
14714                                    }
14715
14716                                    var product_number = $(this).attr('data-product_number');
14717                                    if($(this).attr('data-option_type') != 'A' && !$('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:not(:checked)').length) {
14718                                        $('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type="A"]').prop('checked',true).change();
14719                                    } 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')) {
14720                                        $('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:last').prop('checked',fal
14720se).change();
14721                                    }
14722                                }
14723
14724                                if ($(this).attr('data-type') == 'normal') {
14725                                    totalNomalCheck++;
14726                                }
14727                            });
14728
14729                            var product_price = price + getPointCalcDeliveryPrice(deliveryPrice),
14730                                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);
14731
14732                            rePayment = (rePayment > 0) ? rePayment : 0;
14733                            
14734                            // coupon 처리
14735                            
14736                            var cancel_coupon_price = 0;
14737                            if(coupon.length) {
14738                                var checked_order_number = $('.cancel-info-data:checked').map(function(){ return this.value; }).toArray();
14739                                $.each(coupon, function(i,v) {
14740                                    if(checked_order_number.indexOf(v.order_number) > -1 || v.kind == 'C') {
14741                                        cancel_coupon_price += parseInt(v.discount_price);
14742
14743                                        // 환불금에서 쿠폰처리
14744                                        if($('.coupon-detail-info[data-seq="' + v.seq + '"]').length == 0) {
14745                                            $('.cancel-coupon-title').append('<div class="coupon-name coupon-detail-info" data-seq="' + v.seq + '">' + v.coupon_name + '</div>');
14746                                            $('#cancel-coupon-detail').append('<div class="coupon-price coupon-detail-info" data-seq="' + v.seq + '">-' + number_format(parseInt(v.discount_price)) + '원</div>');
14747                                        }
14748                                    } else {
14749                                        $('.coupon-detail-info[data-seq="' + v.seq + '"]').remove();
14750                                    }
14751                                });
14752                                // 취소된 쿠폰 저장
14753                                
14754                            }
14755                            product_price = product_price - parseInt(cancel_coupon_price);
14756                            product_price = product_price - gradeDiscountPrice;
14757                            
14758                            var use_point = (rePayment - product_price > 0) ? 0 : rePayment - product_price;
14759                            product_price = product_price + use_point;
14760
14761                            $('#cancel-price').html(number_format(price)+'원');
14762                            $('#cancel-delivery-price').html(number_format(deliveryPrice)+'원');
14763                            $('#cancel-point-price').html(number_format(use_point)+'원');
14764                            $('#cancel-coupon-price').html(((cancel_coupon_price > 0) ? '-' + number_format(cancel_coupon_price) : '0')+'원');
14765                            $('#cancel-grade-discount-price').html(((gradeDiscountPrice > 0) ? '-' + number_format(gradeDiscountPrice) : '0')+'원');
14766                            $('#return-total-price').html(number_format(product_price));
14767                            $('.codecoupon-cancel-desc').show();
14768
14769                            var priceSumArr = [];
14770                            var extra_charge_flag = {};
14771                            if(oreModal.find('.cancel-info-data:checked').length) {
14772                                oreModal.find('.cancel-info-data:checked').each(function() {
14773                                    if($(this).data('type') != 'normal') 
14774                                        return;
14775
14776                                    var dts = $(this).data('delivery_template_seq');
14777                                    if(dtl[dts]['price_type'] != 'FREE_CONDITION') return;
14778                                    var dt = $(this).data('delivery_type');
14779                                    if(dt != 'DELIVERY' && dt != 'DIRECT') return;
14780
14781                                    if(!priceSumArr.hasOwnProperty(dts)) {
14782                                        priceSumArr[dts] = [];
14783                                    }
14784                                    if(!priceSumArr[dts].hasOwnProperty(dt)) {
14785                                        priceSumArr[dts][dt] = 0;
14786                                    }
14787                                    // cancel_after_point = Number(cancel_after_point) + ((Number($(this).data("usable_point")) + Number($(this).data("expired_point"))) - Number($(this).data("curr_point")));
14788                                    var selectedPrice = 0;
14789                                    selectedPrice = Number($(this).closest('tr').find('[data-optionprice]').data('optionprice'));
14790                                    priceSumArr[dts][dt] += selectedPrice;
14791
14792                                    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) {
14793                                        extra_charge_flag[dts + '|' + dt] = true;
14794                                    } else {
14795                                        extra_charge_flag[dts + '|' + dt] = false;
14796                                    }
14797                                });
14798                            }
14799                            
14800                            extra_charge_info($form, 'R', Object.values(extra_charge_flag).indexOf(true) > -1 ? true : false, false);
14801                        } else {
14802
14803                            $('.order-candel-content.extra-info').remove();
14804                            $('#return-modal').css('display', 'none');
14805                            $('.order-cancel-content').css('display', 'none');
14806                            $('#no-bank').parent().parent().removeClass('cl-s-form-wrap');
14807                            $('#no-bank-name').parent().parent().removeClass('cl-s-form-wrap');
14808                            $('#no-bank-number').parent().parent().removeClass('cl-s-form-wrap');
14809                            if (status == 'Y') {
14810                                $('.status-checkbox').each(function () {
14811                                    $(this).prop('checked', false);
14812                                    $(this).removeClass('noneAll');
14813                                });
14814                                $('#product-check').removeClass('noneAll');
14815                                $('#product-check').prop('checked', false);
14816                                $('.escrow-warring').css({'display': 'none'});
14817                                $('.escrow-exchange-warning').show();
14818                            } else if(used_code_coupon) {
14819                                $('.status-checkbox').each(function () {
14820                                    $(this).prop('checked', false);
14821                                    $(this).removeClass('noneAll');
14822                                });
14823                                $('#product-check').removeClass('noneAll');
14824                                $('#product-check').prop('checked', false);
14825                                $('.code-coupon-exchange-warning').show();
14826                                $('.codecoupon-cancel-desc').hide();
14827                            }
14828                        }
14829
14830                        $('#re-reason').closest('.cl-s-form-selector').removeClass('empty');
14831                        $('#re-reason').html(re_reason_obj[order_status]).selectpicker('refresh');
14832                        $('#re-reason').selectpicker('val', $('#re-reason').val());
14833                    }
14834                });
14835                if((status == 'Y' || used_code_coupon) && data.r.exchange_check == true) { // 에스크로이고 교환건 존재
14836                    $('#order-radio-exchange[value="E"]').prop('checked', true).change();
14837                }
14838
14839            },'json');
14840
14841            $('.close-button-dialog').css({'display': 'block'});
14842        },
14843        writeReviewModal: function(sid, pnum, onum, type) {
14844            if(typeof sid == 'undefined' || typeof pnum == 'undefined' || typeof onum == 'undefined') {
14845                alert('정보가 올바르지 않습니다');
14846                return false;
14847            }
14848            $.post('/_check_order', { sid:sid, pnum:pnum, onum:onum, mode:'review' }, function(data) {
14849                if(typeof data.error != 'undefined' && data.error) {
14850                    $(this).showModalFlat('', data.error, true, false, '', 'close');
14851                    return false;
14852                }
14853
14854                var c_data = data.r,
14855                    modal_str = '',
14856                    order_group = data.order_group,
14857                    picturePointStr = '';
14858
14859                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';
14860                
14861                if(c_data.writer.status == 'A') {
14862                    alert('관리자는 상품 후기 작성을 사용할 수 없습니다.');
14863                    return false;
14864                }
14865                    if (c_data.pay_info.settings.point_data != null && c_data.pay_info.settings.point_data['point_use'] == 'Y' && c_data.writer.status != 'T') {
14866                        if (c_data.pay_info.settings.point_data['review_point_status'] == 'Y') {
14867                            if(typeof c_data.pay_info.settings.point_data != "undefined" && c_data.pay_info.settings && c_data.odata.price > 0) {  
14868                                var photoPoint = (c_data.pay_info.settings.point_data['review_photo_point'] > 0) ? c_data.pay_info.settings.point_data['review_photo_point'] : 0,
14869                                    textPoint = (c_data.pay_info.settings.point_data['review_point'] > 0) ? c_data.pay_info.settings.point_data['review_point'] : 0;
14870                                    picturePointStr = '\
14871                                        <div class="cl-s-ps">\
14872                                            <svg viewBox="0 0 13 13" width="13" height="13">\
14873                                                <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"/>\
14874                                                <rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/>\
14875                                            </svg>사진 첨부 시 <span>'+number_format(photoPoint)+'원</span>이 적립됩니다.\
14876                                        </div>\
14877                                ';
14878                            }
14879
14880                            let maxPoint = textPoint;
14881                            let pointPopoverContent = `텍스트 후기 : &nbsp; ${number_format(textPoint)}원`;
14882                            if(use_review_img_upload != 'false') {
14883                                maxPoint = photoPoint;
14884                                pointPopoverContent = `텍스트 후기 : &nbsp; ${number_format(textPoint)}원 <br>포토 후기 : &nbsp; ${number_format(photoPoint)}원<br><p>텍스트 후기와 포토 후기 적립금은 중복지급되지 않으며, 최초 작성한 후기를 기준으로 지급됩니다.</p>`;
14885                            }
14886                           
14887                            if(c_data.odata.price > 0) {
14888                                modal_str += `
14889                                    <div class="review-point review-icon">후기 작성 시 적립금 <span>최대 ${maxPoint}원</span>
14890                                        <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}">
14891                                            <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"/>\
14892                                            <rect x="6" y="9" width="1" height="1"/>
14893                                            <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.
1489366 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"/>
14894                                        </svg>
14895                                    </div>
14896                                `;
14897                            }
14898                        }
14899                    }
14900
14901                    modal_str += '\
14902                    <div class="review-body review-write-body">\
14903                        <div class="cl-s-product-jumbotron clearfix">\
14904                            <div class="cl-s-product-thumb">\
14905                                <img src="' + c_data.pdata.img + '" alt="' + c_data.pdata.name + '" class="' + c_data.pdata.img_align + '" />\
14906                            </div>\
14907                            <div class="cl-s-product-info">\
14908                                <h5 class="cl-s-product-title">' + c_data.pdata.name + '</h5>\
14909                    ';
14910                    var option_title = (c_data.pdata.option_type == 'A') ? '추가옵션: ' + (c_data.pdata.option_group ? c_data.pdata.option_group + ': ' : '') : '옵션: ';
14911                    if(typeof c_data.pdata.option != "undefined" && c_data.pdata.option) {
14912                        modal_str += (c_data.pdata.option_text_str)? '\
14913                                <div class="option-str">' + option_title + c_data.pdata.option + ' / ' + c_data.pdata.option_text_str + '</div>\
14914                        ' : '\
14915                                <div class="option-str">' + option_title + c_data.pdata.option + '</div>\
14916                        ';
14917                    } else {
14918                        modal_str += (c_data.pdata.option_text_str)? '\
14919                                <div class="option-str">' + c_data.pdata.option_text_str + '</div>\
14920                        ' : '';
14921                    }
14922                    if(typeof c_data.pdata.etc_date != "undefined" && c_data.pdata.etc_date) {
14923                        modal_str += '\
14924                                <div class="option-str">선택일자: ' + c_data.pdata.etc_date + '</div>\
14925                        ';
14926                    }
14927                    modal_str += '\
14928                            </div>\
14929                        </div>\
14930                        <div class="review-star">\
14931                            <h5>상품이 만족스러우셨나요?</h5>\
14932                            <div class="star text-center">\
14933                                <span data-idx="1" class="active"></span>\
14934                                <span data-idx="2" class="active"></span>\
14935                                <span data-idx="3" class="active"></span>\
14936                                <span data-idx="4" class="active"></span>\
14937                                <span data-idx="5" class="active"></span>\
14938                            </div>\
14939                        </div>\
14940                        <div class="review-content">\
14941                            <h5>어떤 점이 좋았나요?</h5>\
14942                            <div class="cl-s-form-wrap">\
14943                                <div class="cl-s-form-group input-label-hide">\
14944                                    <textarea class="cl-s-form-control" id="review-str" name="review" maxlength="1000" required="required"></textarea>\
14945                                    <label for="input" class="cl-s-control-label">자세한 내용을 적어주세요. (1000자 이내)</label>\
14946                                </div>\
14947                            </div>\
14948                        ';
14949                        if(use_review_img_upload != 'false') {
14950                        modal_str += '\
14951                            <div class="cl-s-files review-files file-center">\
14952                                <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 + '\">\
14953                                <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>';
14954                    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;
14955                        modal_str += '\
14956                                <ul class="cl-s-files-list review-files-list clearfix files-list-wrap">\
14957                                </ul>\
14958                            </div>\
14959                            ';
14960                        }
14961                        modal_str += '\
14962                            </div>\
14963                        </div>\
14964                            ';
14965                
14966                // $('.flat-modal .modal').modal('hide');
14967                var wrModal = $(this).showModalFlat('후기 작성', modal_str, true, true,function () {
14968
14969                    var cl_s_f_body = $('.cl-s-product-review-write .review-content');
14970                    cl_s_f_body.find('.cl-s-form-wrap').each(function() {
14971                        var check_input = $(this).find('.cl-s-form-control'),
14972                            val = check_input.val().trim();
14973
14974                        if(val.length == 0) {
14975                            $(this).removeClass('error').addClass('empty');
14976                            $(this).find('.cl-s-control-label.error').remove();
14977                        } else {
14978                            if($(this).hasClass('error')) {
14979                                check_input.focus();
14980                            }
14981                        }
14982                    });
14983
14984                    if(cl_s_f_body.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').length > 0) {
14985                        cl_s_f_body.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').eq(0).find('.cl-s-form-control').focus();
14986                        return false;
14987                    }
14988
14989                    var page_mode = ($('.cl-s-mypage').length > 0) ? 'mypage' : 'no_member',
14990                        review = $('#review-str').val().trim(),
14991                        review_star = $('.cl-s-product-review-write .review-star .star .active').length,
14992                        review_image = new Array();
14993                        review_image_orig = new Array();
14994
14995                    $('input[name="review_image[]"]').each(function(i) {
14996                        review_image[i] = $(this).val();
14997                    });
14998
14999                    $('input[name="review_image_orig[]"]').each(function(i) {
15000                        review_image_orig[i] = $(this).val();
15001                    });
15002
15003                    var review_data = {
15004                        status : 'S',
15005                        page_mode : page_mode,
15006                        pnum : pnum,
15007                        onum : onum,
15008                        mb_status : c_data.writer.status,
15009                        review : review,
15010                        review_count : review_star,
15011                        review_image : review_image,
15012                        review_image_orig : review_image_orig
15013                    };
15014
15015                    if(c_data.writer.status == 'T') {
15016                        review_data['name'] = c_data.odata.name;
15017                        // review_data['order_group'] = c_data.order_data.group;
15018                    }
15019
15020                    $('.ok-button-dialog').prop('disabled', true);
15021
15022                    $.post('/_review_write', { sid:sid, order_group: order_group, data:JSON.stringify(review_data) }, function(rw_data) {
15023                        if(typeof rw_data.error != 'undefined' && rw_data.error) {
15024                            $(this).showModalFlat('ERROR', rw_data.error, true, false, '', 'close');
15025                            return false;
15026                        }
15027
15028                        location.reload();
15029                    }, 'json');
15030
15031                },'close','등록하기','cl-s-product-review-write cl-modal cl-s-btn cover', true, '', function() {
15032
15033                    $('.cl-s-product-review-write .cl-s-form-group').on('click',function(e) {
15034                        if($(e.target).hasClass('cl-s-form-group')) {
15035                            $(e.target).find('.cl-s-form-control:not([type=hidden])').focus();
15036                        }
15037                    });
15038                    $('[data-toggle="popover"]').popover();
15039                    $('.cl-s-product-review-write .cl-s-form-control').on({
15040                        focus: function(e) {
15041                            $(this).closest('.cl-s-form-wrap').addClass('active');
15042                        },
15043                        blur: function(e) {
15044                            var val = $(this).val().trim();
15045
15046                            $(this).closest('.cl-s-form-wrap').removeClass('active');
15047                            if(val.length == 0) {
15048                                $(this).closest('.cl-s-form-wrap').removeClass('error').addClass('empty');
15049                                $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
15050                                return false;
15051                            } else {
15052                                $(this).closest('.cl-s-form-wrap').removeClass('empty');
15053                                var passEmoji = ($.inArray($(this).attr('name'),['review']) > -1) ? true : false,
15054                                    error_str = '';
15055                                if(!passEmoji && checkEmojis(val)) error_str = $.lang[LANG]['config.unable.emoji'];
15056                                else if(val.length < 5) error_str = $.lang[LANG]['customsite.validate.message.minlengthto5'];
15057                                
15058                                if(error_str.length > 0) {
15059                                    $(this).closest('.cl-s-form-wrap').addClass('error');
15060                                    if($(this).parent().find('.cl-s-control-label.error').length > 0) {
15061                                        $(this).parent().find('.cl-s-control-label.error').html(error_str);
15062                                    } else {
15063                                        $(this).after('<label for="input" class="cl-s-control-label error">' + error_str + '</label>');
15064                                    }
15065                                    return false;
15066                                }
15067                            }
15068
15069                            $(this).closest('.cl-s-form-wrap').removeClass('error').removeClass('empty');
15070                            $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
15071                        }
15072                    });
15073
15074                    $(document).on('click', '.cl-s-product-review-write .review-img-close', {mode: 'review'}, deleteReviewQnaImg);
15075
15076                    $('.cl-s-product-review-write .review-file-update').on('click', function () {
15077                        $("#review-file").click();
15078                    });
15079
15080                    $('.cl-s-product-review-write #review-file').on('click', {mode: 'review'}, uploadReviewQnaImg);
15081
15082                    $('.cl-s-product-review-write .review-star .star span').on('click', function() {
15083                        var rCount = $(this).attr('data-idx');
15084                        $(this).parent().children('span').removeClass('active');
15085                        $(this).addClass('active').prevAll('span').addClass('active');
15086                    });
15087                }, function() {
15088                    if($('.cl-s-product-review-write .review-img-close').length > 0){
15089                        $.each($('.cl-s-product-review-write .review-img-close'), function(){
15090                            $(this).trigger('click');
15091                        });
15092                    }
15093                });
15094
15095
15096            },'json');
15097
15098        },
15099
15100        orderConfirmModal: function(sid, pnum, onum, ognum, status, dStatus, pclass) {
15101            if(typeof sid == "undefined" || typeof pnum == "undefined" || typeof onum == "undefined") {
15102                alert('정보가 올바르지 않습니다');
15103                return false;
15104            }
15105            $.post('/_check_order', { sid:sid, pnum:pnum, onum:onum, mode:'confirm', ognum: ognum }, function(data) {
15106
15107                if(typeof data.error != "undefined" && data.error) {
15108                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'close');
15109                    return false;
15110                }
15111                var c_data = data.r, checkboxNone = '', noneAll = '', noneChecked = '', checkNoneAll = '', checkEscrowFooter = '', checkEscrowClass = '', checkOrderConfirm = '';
15112                var dtl = c_data.delivery_template_list;
15113                var used_code_coupon = false;
15114                
15115                if(c_data.pay_info.coupon_list && c_data.pay_info.coupon_list.length) {
15116                    $.each(c_data.pay_info.coupon_list, function(k, v) {
15117                        if(v.kind == 'C') {
15118                            used_code_coupon = true;
15119                        }
15120                    })
15121                }
15122
15123                if(used_code_coupon) {
15124                    checkboxNone = 'checked';
15125                    noneAll = ' noneAll';
15126                    checkNoneAll = 'fule';
15127                    checkOrderConfirm = '<div class="modal-comment deposit-cancel-desc codecoupon-cancel-desc order-cancel-content">\
15128                                <div class="desc-box">\
15129                                    <div class="desc-title">코드쿠폰 사용 구매확정 안내</div>\
15130                                    <div class="section">- 코드쿠폰 사용 주문 건은 <span class="cl-red">전체 구매확정</span>만 가능합니다.</div>\
15131                                </div>\
15132                            </div>\
15133                        ';
15134                }
15135
15136                var modal_str = '\
15137                    <form name="cancel_form" method="post" action="/_confirm">\
15138                        <input type="hidden" name="sid" value="' + sid + '">\
15139                        <input type="hidden" name="order_group" id="cancel-order-group" value="' + ognum + '">\
15140                        <input type="hidden" name="order_number" id="cancel-order-number" value="' + onum + '">\
15141                        <div class="cancel-product-title">\
15142                            <div class="newcheckbox hand">\
15143                                <label>\
15144                                    <input type="checkbox" class="'+noneAll+'" id="product-check" '+checkboxNone+'>\
15145                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
15146                                        <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"/>\
15147                                    </svg>\
15148                                    <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
15149                                        <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"/>\
15150                                    </svg>\
15151                                </label>\
15152                            </div>\
15153                            구매확정 상품\
15154                        </div>';
15155
15156                        modal_str += '<table class="table product-table">';
15157                        for (var i=0;i<data.r.odata.length;i++) {
15158                            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') {
15159                                noneChecked = '';
15160                                if (!checkNoneAll) noneAll = '';
15161                            } else {
15162                                if (!checkNoneAll) noneAll = 'noneAll';
15163                                noneChecked = 'noneChecked';
15164                            }
15165                            if (c_data.odata[i].p_status == 'W') {
15166                                if (!checkNoneAll) noneAll = 'noneAll';
15167                                noneChecked = 'noneChecked';
15168                                checkboxNone = 'checked';
15169                            }
15170
15171                            var dts = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_template_seq : '';
15172                            if(c_data.odata[i].state == 'normal' && c_data.odata[i].mix_yn != 'Y') dts += '-' + c_data.odata[i].product_number;
15173                            var dt = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_type : '';
15174
15175                            modal_str += '\
15176                            <tr class="cl-s-product-jumbotron clearfix">\
15177                                <td>\
15178                                <div class="newcheckbox hand">\
15179                                    <label>\
15180                                        <input type="checkbox" class="status-checkbox cancel-info-data '+noneAll+' '+noneChecked+'" data-type="'+c_data.pdata[i].state
15180+'" 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) + '">\
15181                                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
15182                                        <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"/>\
15183                                        </svg>\
15184                                        <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
15185                                        <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"/>\
15186                                        </svg>\
15187                                    </label>\
15188                                </div>\
15189                                <div class="cl-s-product-thumb">\
15190                                    <img src="' + c_data.pdata[i].img + '" alt="' + c_data.pdata[i].name + '" class="' + c_data.pdata[i].img_align + '" />\
15191                                </div>\
15192                                <div class="cl-s-product-info">\
15193                                    <h5 class="cl-s-product-title">' + c_data.pdata[i].name + '</h5>\
15194                            ';
15195
15196                            // console.log(c_data.odata[i]);
15197
15198                            var price = (Number(c_data.odata[i].sale_price) > 0) ? c_data.odata[i].sale_price : c_data.odata[i].price,
15199                                quantity = Number(c_data.odata[i].quantity),
15200                                optionPrice = c_data.odata[i].price * quantity,
15201                                sum_price = quantity * price,
15202                                option_name = (typeof c_data.pdata[i].option != "undefined" && c_data.pdata[i].option) ? c_data.pdata[i].option : '',
15203                                option_str = '',
15204                                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>' : '',
15205                                option_title = (c_data.pdata[i].option_type == 'A') ? '추가옵션: ' + (c_data.pdata[i].option_group ? c_data.pdata[i].option_group + ': ' : '') : '옵션: ';
15206                            if(option_name) {
15207                                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>';
15208                            } else {
15209                                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>' : '';
15210                            }
15211                            modal_str += '\
15212                                    <div class="option-str option-check" data-optionPrice="'+optionPrice+'">' + option_str + etc_str + '<span>' + quantity + '개</span><div class="price"><span>
15212' + number_format(optionPrice) + '</span> 원</div></div>\
15213                                </div>\
15214                                </td></tr>\
15215                            ';
15216
15217                        }
15218                        modal_str += '</table>';
15219
15220
15221                    var status = [];
15222                    for (var i=0;i<c_data.pdata.length;i++) {
15223                        status.push(c_data.pdata[i].p_status);
15224                    }
15225                    modal_str += checkOrderConfirm;
15226                    modal_str += '\
15227                        <div class="modal-sub-title order-cancel-content">구매확정을 진행하시겠습니까?</div>\
15228                        <div class="modal-comment order-cancel-content"></div>\
15229                    ';
15230
15231
15232                var ocModal = $(this).showModalFlat('구매 확정', modal_str,true,true,function () {
15233
15234                    var f = document.cancel_form;
15235
15236                    ocModal.find('.cl-s-form-wrap').each(function() {
15237                        var check_input = $(this).find('.cl-s-form-control'),
15238                            val = check_input.val().trim();
15239
15240                        if(val.length == 0) {
15241                            $(this).removeClass('error').addClass('empty');
15242                            $(this).find('.cl-s-control-label.error').remove();
15243                        } else {
15244                            if($(this).hasClass('error')) {
15245                                check_input.focus();
15246                            }
15247                        }
15248                    });
15249                    var checkCnt = 0;
15250
15251                    $(".status-checkbox").each(function (i, index) {
15252                        if ($(this).is(":checked") === true) {
15253                            checkCnt++;
15254                        }
15255                    });
15256
15257                    if (checkCnt < 1) {
15258                        alert('상품을 1개 이상 선택해 주세요');
15259                        return false;
15260                    }
15261
15262                    if(ocModal.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').length > 0) {
15263                        // ocModal.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').eq(0).find('.cl-s-form-control').focus();
15264                        return false;
15265                    }
15266
15267                    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) {
15268                        $(".point-used-cancel-agree-desc").show();
15269                        return false;
15270                    } else {
15271                        $(".point-used-cancel-agree-desc").hide();
15272                    }
15273
15274                    $.processON();
15275
15276                    f.submit();
15277                    ocModal.modal('hide');
15278
15279                },'취소','확인','cl-s-order-cancel cl-modal cl-s-btn cover ', false, '', function() {
15280                    var totalCnt = 0, totalNomalCheck = 0, nomalCheck = 0, price = 0, deliveryPrice = 0,
15281                        $form = $('form[name="cancel_form"]');
15282
15283                    $('.status-checkbox').each(function(i, index) {
15284                        if ($(this).is(":checked") === true) {
15285                            price += ($(this).closest('.cl-s-product-jumbotron').find('.option-check').attr('data-optionPrice') * 1);
15286                            totalCnt++;
15287                        }
15288
15289                        if ($(this).attr('data-type') == 'normal') {
15290                            totalNomalCheck++;
15291                        }
15292                    });
15293
15294                    $('.cancel-info-data').on('change', function (e) {
15295                        if($(this).hasClass('noneAll')) return;    
15296
15297                        var product_number = $(this).attr('data-product_number');
15298                        if($(this).attr('data-option_type') != 'A' && !$('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:not(:checked)').length) {
15299                            $('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type="A"]').prop('checked',true);
15300                        } 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')) {
15301                            $('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:last').prop('checked',fal
15301se);
15302                        }
15303
15304                        var totalCnt = 0, totalNomalCheck = 0, nomalCheck = 0;
15305                        
15306                        $form.find('.order-cancel-content.extra-info').remove();
15307
15308                        if ($(this).hasClass('noneAll') === true) {
15309                            if ($(this).hasClass('noneChecked') === true) {
15310                                $(this).prop('checked', false);
15311                            } else {
15312                                $(this).prop('checked', true);
15313                                $(".status-checkbox").each(function () {
15314                                    if ($(this).prop('disabled') !== true) $(this).prop('checked', true);
15315                                });
15316                            }
15317                        }
15318
15319                        $(".status-checkbox").each(function (i, index) {
15320                            if ($(this).is(":checked") === true) {
15321                                price += ($(this).closest('.cl-s-product-jumbotron').find('.option-check').attr('data-optionPrice') * 1);
15322                                totalCnt++;
15323                                if ($(this).attr('data-type') == 'normal') nomalCheck++;
15324                            }
15325
15326                            if ($(this).attr('data-type') == 'normal') totalNomalCheck++;
15327                        });
15328
15329                        if($('input[name="order_number_ary[]"]').length == $('input[name="order_number_ary[]"]:checked').length) $('#product-check').prop('checked', true);
15330                        else $('#product-check').prop('checked', false);
15331                    });
15332
15333                    $(document).on('click', '#product-check', function () {
15334
15335                        $form.find('.order-cancel-content.extra-info').remove();
15336                        if ($(this).hasClass('noneAll') === true) {
15337                            $(this).prop('checked', true);
15338                            $(".status-checkbox").each(function () {
15339                                if ($(this).prop('disabled') !== true) $(this).prop('checked', true).change();
15340                            });
15341                        }
15342                        if ($(this).is(":checked") === true) {
15343                            $(".status-checkbox").each(function (i) {
15344                                if ($(this).prop('disabled') !== true) {
15345                                    $(this).prop('checked', true).change();
15346                                }
15347
15348                            });
15349                        } else {
15350                            $(".status-checkbox").each(function () {
15351                                if ($(this).prop('disabled') !== true) $(this).prop('checked', false).change();
15352                            });
15353                        }
15354                    });
15355
15356                    ocModal.find('[data-toggle="popover"]').popover();
15357                });
15358
15359            },'json');
15360            $('.close-button-dialog').css({'display': 'block'});
15361        },        
15362        editReviewModal: function(sid, pnum, onum, seq) {
15363            if(typeof sid == "undefined" || typeof pnum == "undefined" || typeof onum == "undefined") {
15364                alert('정보가 올바르지 않습니다');
15365                return false;
15366            }
15367            $.post('/_check_review', { sid:sid, seq: seq, mode:'review' }, function(data) {
15368
15369                if(typeof data.error != "undefined" && data.error) {
15370                    $(this).showModalFlat('', data.error, true, false, '', 'close');
15371                    return false;
15372                }
15373
15374                var c_data = data.r,
15375                    modal_str = '\
15376                    <div class="review-body review-write-body">\
15377                        <div class="cl-s-product-jumbotron clearfix">\
15378                            <div class="cl-s-product-thumb">\
15379                                <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>\
15380                            </div>\
15381                            <div class="cl-s-product-info">\
15382                                <h5 class="cl-s-product-title"><a href="' + c_data.pdata.product_url + '" target="_blank">' + c_data.pdata.name + '</a></h5>\
15383                    ';
15384                    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';
15385                    var option_title = (c_data.pdata.option_type == 'A') ? '추가옵션: ' + (c_data.pdata.option_group ? c_data.pdata.option_group + ': ' : '') : '옵션: ';
15386                    if(typeof c_data.pdata.option != "undefined" && c_data.pdata.option) {
15387                        modal_str += (c_data.pdata.option_text_str)? '\
15388                                <div class="option-str">' + option_title + c_data.pdata.option + ' / ' + c_data.pdata.option_text_str + '</div>\
15389                        ' : '\
15390                                <div class="option-str">' + option_title + c_data.pdata.option + '</div>\
15391                        ';
15392                    } else {
15393                        modal_str += (c_data.pdata.option_text_str)? '\
15394                                <div class="option-str">' + option_title + c_data.pdata.option_text_str + '</div>\
15395                        ' : '';
15396                    }
15397                    if(typeof c_data.pdata.etc_date != "undefined" && c_data.pdata.etc_date) {
15398                        modal_str += '\
15399                                <div class="option-str">선택일자: ' + c_data.pdata.etc_date + '</div>\
15400                        ';
15401                    }
15402                    var image = c_data.review.review_image.split("||").filter(function(v){return v!==''});
15403                    var image_orig = c_data.review.review_image_orig.split("||").filter(function(v){return v!==''});
15404                    var reviewImage = '';
15405                    if(image.length > 0) {
15406                        for (var i=0;i<image.length;i++) {
15407                            reviewImage += '\
15408                                <li id="review-image-'+i+'">\
15409                                    <img src="'+image[i]+'" class="img-responsive" />\
15410                                    <input type="hidden" name="review_image[]" value="'+image[i]+'" />\
15411                                    <input type="hidden" name="review_image_orig[]" value="'+image_orig[i]+'" />\
15412                                    <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>\
15413                                </li>\
15414                            ';
15415                        }
15416                    }
15417                    
15418                    modal_str += '\
15419                            </div>\
15420                        </div>\
15421                        <div class="review-star">\
15422                            <h5>상품이 만족스러우셨나요?</h5>\
15423                            <div class="star text-center">';
15424                            for(var i=0;i<5;i++) {
15425                                var rs_onof = (i < c_data.review.review_score) ? 'active' : '';
15426                                modal_str += '<span data-idx="'+(i+1)+'" class="'+rs_onof+'"></span>';
15427                            }
15428                            modal_str += '\
15429                            </div>\
15430                        </div>\
15431                        <div class="review-content">\
15432                            <h5>어떤 점이 좋았나요?</h5>\
15433                            <div class="cl-s-form-wrap">\
15434                                <div class="cl-s-form-group input-label-hide">\
15435                                    <textarea class="cl-s-form-control" id="review-str" name="review" maxlength="1000" required="required">'+c_data.review.review+'</textarea>\
15436                                    <label for="input" class="cl-s-control-label">자세한 내용을 적어주세요. (1000자 이내)</label>\
15437                                </div>\
15438                            </div>\
15439                        ';
15440                        if(use_review_img_upload != 'false') {
15441                        modal_str += '\
15442                            <div class="cl-s-files review-files">\
15443                                <input id="review-file" type="file" name="files[]" multiple data-sid="' + sid + '" data-uid=\"' + c_data.writer.id + '\" data-seq=\"'+seq+'\">\
15444                                <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>\
15445                                <ul class="cl-s-files-list review-files-list clearfix" >\
15446                                '+reviewImage+'\
15447                                </ul>\
15448                            </div>\
15449                        ';
15450                        }
15451                        modal_str += '\
15452                        </div>\
15453                    </div>\
15454                \
15455                ';
15456
15457                // $('.flat-modal .modal').modal('hide');
15458                var wrModal = $(this).showModalFlat('후기 작성', modal_str, true, true, function () {
15459
15460                    var cl_s_f_body = $('.cl-s-product-review-write .review-content');
15461                    cl_s_f_body.find('.cl-s-form-wrap').each(function() {
15462                        var check_input = $(this).find('.cl-s-form-control'),
15463                            val = check_input.val().trim();
15464
15465                        if(val.length == 0) {
15466                            $(this).removeClass('error').addClass('empty');
15467                            $(this).find('.cl-s-control-label.error').remove();
15468                        } else {
15469                            if($(this).hasClass('error')) {
15470                                check_input.focus();
15471                            }
15472                        }
15473                    });
15474
15475                    if(cl_s_f_body.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').length > 0) {
15476                        cl_s_f_body.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').eq(0).find('.cl-s-form-control').focus();
15477                        return false;
15478                    }
15479
15480                    var review = $('#review-str').val().trim(),
15481                        review_star = $('.cl-s-product-review-write .review-star .star .active').length,
15482                        review_image = new Array();
15483                        review_image_orig = new Array();
15484                    $('input[name="review_image[]"]').each(function(i) {
15485                        review_image[i] = $(this).val();
15486                    });
15487                    $('input[name="review_image_orig[]"]').each(function(i) {
15488                        review_image_orig[i] = $(this).val();
15489                    });
15490                    
15491                    var review_data = {
15492                        status : 'U',
15493                        page_mode : 'product',
15494                        pnum : pnum,
15495                        onum : onum,
15496                        seq : seq,
15497                        mb_status : c_data.writer.status,
15498                        review : review,
15499                        review_count : review_star,
15500                        review_image : review_image,
15501                        review_image_orig : review_image_orig
15502                    };
15503
15504                    if(c_data.writer.status == 'T') {
15505                        review_data['name'] = c_data.odata.name;
15506                        // review_data['order_group'] = c_data.order_data.group;
15507                    }
15508
15509                    $('.ok-button-dialog').prop('disabled', true);
15510                    
15511                    $.post('/_review_write', { sid:sid, data:JSON.stringify(review_data) }, function(rw_data) {
15512                        if(typeof rw_data.error != 'undefined' && rw_data.error) {
15513                            $(this).showModalFlat('ERROR', rw_data.error, true, false, '', 'close');
15514                            return false;
15515                        }
15516
15517                        wrModal.modal('hide');
15518                        setTimeout(function () {
15519                            location.reload();
15520                        }, 200); 
15521                    }, 'json');
15522
15523
15524
15525                },'close','수정하기','cl-s-product-review-write cl-modal cl-s-btn cover', true, '', function() {
15526                    $('.cl-s-product-review-write .cl-s-form-group').on('click',function(e) {
15527                        if($(e.target).hasClass('cl-s-form-group')) {
15528                            $(e.target).find('.cl-s-form-control:not([type=hidden])').focus();
15529                        }
15530                    });
15531
15532                    $('.cl-s-product-review-write .cl-s-form-control').on({
15533                        focus: function(e) {
15534                            $(this).closest('.cl-s-form-wrap').addClass('active');
15535                        },
15536                        blur: function(e) {
15537                            var val = $(this).val().trim();
15538
15539                            $(this).closest('.cl-s-form-wrap').removeClass('active');
15540                            if(val.length == 0) {
15541                                $(this).closest('.cl-s-form-wrap').removeClass('error').addClass('empty');
15542                                $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
15543                                return false;
15544                            } else {
15545                                $(this).closest('.cl-s-form-wrap').removeClass('empty');
15546
15547                                var passEmoji = ($.inArray($(this).attr('name'),['review']) > -1) ? true : false,
15548                                    error_str = '';
15549                                if(!passEmoji && checkEmojis(val)) error_str =  $.lang[LANG]['config.unable.emoji'];
15550                                else if(val.length < 5) error_str = $.lang[LANG]['customsite.validate.message.minlengthto5'];
15551
15552                                if(error_str.length > 0) {
15553                                    $(this).closest('.cl-s-form-wrap').addClass('error');
15554                                    if($(this).parent().find('.cl-s-control-label.error').length > 0) {
15555                                        $(this).parent().find('.cl-s-control-label.error').html(error_str);
15556                                    } else {
15557                                        $(this).after('<label for="input" class="cl-s-control-label error">' + error_str + '</label>');
15558                                    }
15559                                    return false;
15560                                }
15561                            }
15562
15563                            $(this).closest('.cl-s-form-wrap').removeClass('error').removeClass('empty');
15564                            $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
15565                        }
15566                    });
15567
15568
15569                    $(document).on('click', '.cl-s-product-review-write .review-img-close', {mode: 'review'}, deleteReviewQnaImg);
15570
15571
15572                    $('.cl-s-product-review-write .review-file-update').on('click', function () {
15573                        $("#review-file").click();
15574                    });
15575
15576                    $('.cl-s-product-review-write #review-file').on('click', {mode: 'review'}, uploadReviewQnaImg);
15577
15578                    $('.cl-s-product-review-write .review-star .star span').on('click', function() {
15579                        var rCount = $(this).attr('data-idx');
15580                        $(this).parent().children('span').removeClass('active');
15581                        $(this).addClass('active').prevAll('span').addClass('active');
15582                    });
15583
15584                });
15585
15586            },'json');
15587
15588        },
15589        viewReviewModal: function(sid, seq, page) {
15590            if(typeof sid == 'undefined' || typeof seq == 'undefined') {
15591                alert('정보가 올바르지 않습니다');
15592                return false;
15593            }
15594
15595            $.post('/_check_review', { sid:sid, seq:seq }, function(data) {
15596                if(typeof data.error != 'undefined' && data.error) {
15597                    $(this).showModalFlat('', data.error, true, false, '', 'close');
15598                    return false;
15599                }
15600
15601                var c_data = data.r;
15602                var um_id = c_data.review.um_id;
15603                var writer = c_data.writer.id;
15604                var writerName = (um_id == writer)? c_data.review.name : c_data.review.masked_name;
15605                    writerName = (c_data.writer.status == 'A')? c_data.review.name : writerName;
15606                var image = c_data.review.review_image.split("||").filter(function(v){return v!==''});
15607                var reviewImage = '';
15608                for (var i=0;i<image.length;i++) {
15609                    reviewImage += '<img src="'+getServeImage(image[i], '800', '')+'">';
15610                }
15611                
15612                var modal_str = '\
15613                    <div class="review-body">\
15614                        <div class="cl-s-product-jumbotron clearfix">\
15615                            <div class="cl-s-product-thumb">\
15616                                <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>\
15617                            </div>\
15618                            <div class="cl-s-product-info">\
15619                                <h5 class="cl-s-product-title"><a href="' + c_data.pdata.product_url + '" target="_blank">' + c_data.pdata.name + '</a></h5>\
15620                            ';
15621                    var option_title = (c_data.pdata.option_type == 'A') ? '추가옵션: ' + (c_data.pdata.option_group ? c_data.pdata.option_group + ': ' : '') : '옵션: ';                            
15622                    if(typeof c_data.pdata.option != "undefined" && c_data.pdata.option) {
15623                        modal_str += '\
15624                                <div class="option-str">' + option_title + c_data.pdata.option + '</div>\
15625                        ';
15626                    }
15627                    if(typeof c_data.pdata.etc_date != "undefined" && c_data.pdata.etc_date) {
15628                        modal_str += '\
15629                                <div class="option-str">선택일자: ' + c_data.pdata.etc_date + '</div>\
15630                        ';
15631                    }
15632
15633                    c_data.review_status = (c_data.writer.status=='T' && page=='mypayment')? 'Y':c_data.review_status;
15634                    modal_str += '\
15635                            </div>\
15636                        </div>\
15637                        <div class="review-member-info">\
15638                            <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>';
15639                            if (c_data.review_status == 'Y' || c_data.review_status == 'A' || c_data.writer.status == 'A') {
15640                                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+'">';
15641                                if (c_data.review_status == 'Y' && c_data.review.status == 'N' && c_data.review.seq.indexOf('mlux|') == -1) {
15642                                    modal_str += '<button type="button" class="review-edit">수정</button>';
15643                                    modal_str += '<button type="button" class="review-delete">삭제</button>';
15644                                }
15645                                if (c_data.writer.status == 'A' && c_data.review.seq.indexOf('mlux|') == -1) {
15646                                    modal_str += '<button type="button" class="review-delete">삭제</button>';
15647                                }
15648                                modal_str += '</div>\
15649                                ';
15650                            }
15651                        modal_str += '\
15652                        </div>\
15653                        <div class="view-review-box">\
15654                            <div class="review-score">';
15655                            for(var i=0;i<5;i++) {
15656                                var rs_onof = (i < c_data.review.review_score) ? 'on' : 'off';
15657                                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>';
15658                            }
15659
15660                            if(c_data.review.inflow=='NAVERPAY') {
15661                                if(c_data.review.review_image) {
15662                                    reviewImage = '<img src="' + c_data.review.review_image 
15662+ '" />';
15663                                } else {
15664                                    reviewImage = '';
15665                                }
15666                            }
15667
15668                            modal_str += '\
15669                            </div>\
15670                            <div class="review-box-content">'+nl2br(c_data.review.review)+'</div>\
15671                            <div class="review-box-image">'+reviewImage+'</div>\
15672                            ';
15673                            if(c_data.review.status == 'Y'){
15674                            modal_str += '\
15675                            <div class="review-box-content review-answer answer-content_'+seq+'">\
15676                                <div class="review-answer-info"><span>관리자<span class="view-review-date">'+c_data.review.answer_date+'</span></span></div>\
15677                                <div class="review-content">'+nl2br(c_data.review.answer)+'\
15678                            </div>'; //end review-answer-content
15679                            if(c_data.writer.status == 'A') {
15680                                modal_str += '\
15681                                    <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+'">\
15682                                        <button type="button" class="btn answer-modify-btn" data-seq="'+seq+'">수정</button>\
15683                                        <button type="button" class="btn answer-delete-btn" onclick="answerDelete('+seq+')">답글 삭제</button>\
15684                                    </div>\
15685                                ';
15686                            }
15687                            modal_str += '\
15688                            </div>'; //end review-answer
15689                            }          
15690                            
15691                            if(c_data.writer.status == 'A' && c_data.review.seq.indexOf('mlux|') == -1){
15692                            modal_str += '\
15693                            <div class="answer-editor answer-editor_'+seq+' answer_'+c_data.review.status+'">\
15694                                <div class="review-answer-info">답글</div>\
15695                                <textarea id="answer-'+seq+'" placeholder="답글을 작성해 주세요.">'+nl2br(c_data.review.answer)+'</textarea>\
15696                                <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+'">';
15697                            if(c_data.review.status == 'N'){
15698                            modal_str += '\
15699                                    <button type="button" class="btn answer-submit-btn">답글 등록</button>';
15700                            }
15701                            else{
15702                            modal_str += '\
15703                                    <button type="button" class="btn answer-cancel-btn">취소</button>\
15704                                    <button type="button" class="btn answer-submit-btn">답글 수정</button>';
15705                            }
15706                            modal_str += '\
15707                                </div>\
15708                            </div>';
15709                            }
15710                modal_str += '\
15711                        </div>\
15712                    </div>'; //end view-review-box
15713
15714                // $('.flat-modal .modal').modal('hide');
15715                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 () {
15716                    $(document).off('click', '.review-edit');
15717                    $(document).on('click', '.review-edit', function (e) {
15718                        e.stopPropagation();
15719                        var $parent = $(this).parent(),
15720                            pnum = $parent.attr('data-pnum'),
15721                            onum = $parent.attr('data-onum'),
15722                            seq = $parent.attr('data-seq');
15723
15724                        $('.modal-backdrop').fadeOut(200);
15725                        $('.modal').fadeOut(200);
15726                        setTimeout(function () {
15727                            $('.modal-backdrop').remove();
15728                            $('.modal').remove();
15729                            $('button[data-dismiss="modal"]').trigger('click');
15730                            $.shoppingmall.editReviewModal(sid, pnum, onum, seq);
15731                        }, 200);
15732                    });
15733
15734                    $(document).off('click', '.review-delete');
15735                    $(document).off('click', '.answer-modify-btn');
15736                    $(document).off('click', '.answer-cancel-btn');
15737                    $(document).off('click', '.answer-submit-btn');
15738
15739                    $(document).on('click', '.review-delete', function () {
15740                    $this = $(this)
15741                        var $parent = $(this).parent(),                            
15742                            on = $parent.attr('data-onum'),
15743                            og = $parent.attr('data-ogroup');
15744                        $.ajax({
15745                            url: '/_review_delete_chk',
15746                            type: 'post',
15747                            data: {
15748                                review_og : og,
15749                                review_on : on 
15750                            },
15751                            success: function (data) {
15752                                var parsedData = JSON.parse(data);
15753                                if(parsedData.result == true ){
15754                                    if (confirm('정말로 삭제하시겠습니까?')) {
15755                                        var pnum = $parent.attr('data-pnum'),
15756                                            onum = $parent.attr('data-onum'),
15757                                            seq = $parent.attr('data-seq'),
15758                                            on = $parent.attr('data-onum'),                                            
15759                                            og = $parent.attr('data-ogroup');
15760                                        $.ajax({
15761                                            url: '/_review_delete',
15762                                            type: 'post',
15763                                            data: {
15764                                                sid: sid,
15765                                                seq: seq,
15766                                                review_og : og,
15767                                                review_on : on                                                 
15768                                            },
15769                                            success: function (data) {
15770                                                alert('삭제가 완료되었습니다.');
15771                                                location.reload();
15772                                            }
15773                                        });
15774                                    }
15775                                } else {
15776                                    console.log($(this),"2번")
15777                                    if($('.rv-cancel-paddingedit').length == 0) {
15778                                        $this.closest('.cl-s-product-review-view .modal-content').css('opacity','.5');
15779                                        var modal = $(this).showModalFlat('후기 삭제에 따른<br>적립금 회수 안내','후기를 삭제하시면 후기 작성 적립금이 회수됩니다.<br>후기를 삭제 하시겠습니까?',true,true,function(){                    
15780                                            var $parent = $this.parent(),
15781                                                pnum = $parent.attr('data-pnum'),
15782                                                onum = $parent.attr('data-onum'),
15783                                                seq = $parent.attr('data-seq'),
15784                                                on = $parent.attr('data-onum'),
15785                                                og = $parent.attr('data-ogroup');
15786
15787                                            $.ajax({
15788                                                url: '/_review_delete',
15789                                                type: 'post',
15790                                                data: {
15791                                                    sid: sid,
15792                                                    seq: seq,
15793                                                    review_og : og,
15794                                                    review_on : on 
15795                                                },
15796                                                success: function (data) {
15797                                                    alert('삭제가 완료되었습니다.');
15798                                                    location.reload();
15799                                                }
15800                                            });                            
15801                                        },'cancel','ok','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 review-opacity rv-cancel-paddingedit','',function(){
15802                                            $this.closest('.cl-s-product-review-view .modal-content').css('opacity','unset'); 
15803                                        }, function() {
15804                                            $(document).on('click', '.ok-button-dialog', function (e) {
15805                                                $(this).prop("disabled", true);
15806                                            });                                        
15807                                            $(document).on('keydown', function(e) {
15808                                                if(e.keyCode == 27) modal.modal('hide');
15809                                            });
15810                                        }, function() {
15811                                            $this.closest('.cl-s-product-review-view .modal-content').css('opacity','unset');
15812                                        });
15813                                    }
15814                                }
15815                            }
15816                        });   
15817
15818                    });
15819
15820                    $(document).on('click', '.answer-modify-btn', function(){
15821                        var $parent = $(this).parent(),
15822                            pnum = $parent.attr('data-pnum'),
15823                            onum = $parent.attr('data-onum'),
15824                            seq = $parent.attr('data-seq');
15825
15826                        $('.answer-content_'+seq).hide();
15827                        $('.answer-editor_'+seq).show();
15828                    });
15829
15830                    $(document).on('click', '.answer-cancel-btn', function(){
15831                        var $parent = $(this).parent(),
15832                            pnum = $parent.attr('data-pnum'),
15833                            onum = $parent.attr('data-onum'),
15834                            seq = $parent.attr('data-seq');
15835
15836                        $('.answer-content_'+seq).show();
15837                        $('.answer-editor_'+seq).hide();
15838                    });
15839
15840                    $(document).on('click', '.answer-submit-btn', function(){
15841                        var $parent = $(this).parent(),
15842                            pnum = $parent.attr('data-pnum'),
15843                            onum = $parent.attr('data-onum'),
15844                            seq = $parent.attr('data-seq');
15845
15846                        $.ajax({
15847                            url: '/_review_msg_write',
15848                            type: 'post',
15849                            data: {
15850                                sid: sid,
15851                                seq: seq,
15852                                review_admin_msg: $('#answer-'+seq).val()
15853                            },
15854                            success: function (data) {
15855                                alert('답글이 등록되었습니다.');
15856                                location.reload();
15857                            }
15858                        });
15859                    });
15860
15861                    $(document).on('click', '.answer-delete-btn', function(){
15862                        if (confirm('정말로 삭제하시겠습니까?')) {
15863                            var $parent = $(this).parent(),
15864                                pnum = $parent.attr('data-pnum'),
15865                                onum = $parent.attr('data-onum'),
15866                                seq = $parent.attr('data-seq');
15867
15868                            $.ajax({
15869                                url: '/_review_msg_write',
15870                                type: 'post',
15871                                data: {
15872                                    sid: sid,
15873                                    seq: seq,
15874                                },
15875                                success: function (data) {
15876                                    alert('답글이 삭제되었습니다.');
15877                                    location.reload();
15878                                }
15879                            });
15880                        }
15881                    });
15882                });
15883
15884
15885            },'json');
15886
15887        },
15888        editQnAModal: function(sid, pnum, seq, onum) {
15889            if(typeof property == 'undefined') {
15890                // alert('편집모드에서 지원하지 않습니다');
15891                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() {
15892                    $(document).on('keydown', function(e) {
15893                        if(e.keyCode == 27) modal.modal('hide');
15894                    });
15895                });
15896                return false;
15897            }
15898            if(typeof property.LOAD != 'undefined' && property.LOAD == 'RENDER') {
15899                alert('미리보기에서는 지원하지 않습니다');
15900                return false;
15901            }
15902            if(typeof seq == 'undefined' || seq == '') seq = -1;
15903            var mode = (seq == -1) ? 'new' : 'edit';
15904            var onum = (typeof onum == 'undefined' || onum == '')? '':onum;
15905            
15906            $.ajax({
15907                url: '/_qna_edit',
15908                type: 'POST',
15909                dataType: 'json',
15910                data: { sid:sid, pnum:pnum, seq:seq, mode:mode },
15911                async: false,
15912                cache: false,
15913                success: function(data) {
15914                    if (data.result == 'fail') {
15915                        location.href = '/_login';
15916                        return false;
15917                    }
15918
15919                    if (data.error) {
15920                        $(this).showModalFlat('', data.error, true, false, '', 'close');
15921                        return false;
15922                    }
15923
15924                    var status = data.um_status;
15925                    if(status == 'A') {
15926                        alert('관리자는 상품문의하기를 사용할 수 없습니다.');
15927                        return false;
15928                    }
15929
15930                    var qna_files_str = qna_secret_str = qna_answer_email_str = qna_answer_alimtalk_str = '';
15931
15932                    if(mode == 'edit') {
15933                        if(data['secret'] == 'Y') qna_secret_str = 'checked';
15934                        if(data['answer_email'] == 'Y') qna_answer_email_str = 'checked';
15935                        if(data['answer_alimtalk'] == 'Y') qna_answer_alimtalk_str = 'checked';
15936
15937                        if(data['qna_image']) {
15938                            var image = data['qna_image'].split('||').filter(function(v){return v!==''});
15939                            var image_orig = data['qna_image_orig'].split('||').filter(function(v){return v!==''});
15940                            $.each(image, function(i,v) {
15941                                qna_files_str += '\
15942                                    <li id="qna-image-' + i + '">\
15943                                        <img src="' + v + '" class="img-responsive" />\
15944                                        <input type="hidden" name="qna_image[]" value="' + v + '"/>\
15945                                        <input type="hidden" name="qna_image_orig[]" value="' + image_orig[i] + '"/>\
15946                                        <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>\
15947                                    </li>\
15948                                ';
15949                            });
15950                        }
15951                    }
15952                    data['email'] = (data['email'] !== null)? data['email']:'';
15953                    seq = (seq !== -1)? seq:'';
15954                    var qna_writer_str = (data['member']) ? '\
15955                        <input type="hidden" id="qna-name" class="cl-s-form-control" name="qna_name" value="' + data['name'] + '">\
15956                        <input type="hidden" id="qna-email" class="cl-s-form-control" name="qna_email" value="' + data['email'] + '">\
15957                        <input type="hidden" id="qna-tel" class="cl-s-form-control" name="qna_tel" value="' + data['tel'] + '">\
15958                        <input type="hidden" id="order-number" name="order_number" value="' + onum + '">\
15959                    ' : '\
15960                        <input type="hidden" id="order-number" name="order_number" value="' + onum + '">\
15961                            <ul class="qna-writer clearfix">\
15962                                <li>\
15963                                    <div class="cl-s-form-wrap">\
15964                                        <div class="cl-s-form-group">\
15965                                            <input type="text" class="cl-s-form-control" id="qna-name" name="qna_name" required="required" value="' + data['name'] + '">\
15966                                            <label for="input" class="cl-s-control-label">이름</label>\
15967                                        </div>\
15968                                    </div>\
15969                                </li>\
15970                                <li>\
15971                                    <div class="cl-s-form-wrap">\
15972                                        <div class="cl-s-form-group">\
15973                                            <input type="password" class="cl-s-form-control" id="qna-password" name="qna_password" required="required">\
15974                                            <label for="input" class="cl-s-control-label">비밀번호</label>\
15975                                        </div>\
15976                                    </div>\
15977                                </li>\
15978                            </ul>\
15979                        ';
15980
15981                    var qna_privacy_str = '\
15982                            <hr class="line"/>\
15983                            <div class="qna-privacy">\
15984                    ';
15985                    if(!data['member']) {
15986                        if(data['um_qna_fin'] == 'Y') {
15987                            qna_privacy_str += '\
15988                                <div class="cl-s-checkbox">\
15989                                    <label class="privacy-toggle" data-view="#qna-email-input">\
15990                                        <input type="checkbox" id="qna-btn-email" name="answer_email" value="Y" ' + qna_answer_email_str + '>\
15991                                        <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>\
15992                                        <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>\
15993                                        이메일로 답변완료 알림 받기\
15994                                    </label>\
15995                                </div>\
15996                                <div class="cl-s-form-wrap" id="qna-email-input" style="display:' + ((qna_answer_email_str == 'checked')? 'block':'none') + ';">\
15997                                    <div class="cl-s-form-group">\
15998                                        <input type="text" class="cl-s-form-control" id="qna-email" name="qna_email" data-type="email" required="required" value="' + data['email'] + '">\
15999                                        <label for="input" class="cl-s-control-label">이메일 주소</label>\
16000                                    </div>\
16001                                </div>\
16002                            ';
16003                            if(data['talk_cnt'] > 0) { //alimtalk
16004                                qna_privacy_str += '\
16005                                <div class="cl-s-checkbox">\
16006                                    <label class="privacy-toggle" data-view="#qna-tel-input">\
16007                                        <input type="checkbox" id="qna-btn-alimtalk" name="answer_alimtalk" value="Y" ' + qna_answer_alimtalk_str + '>\
16008                                        <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>\
16009                                        <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>\
16010                                        알림톡으로 답변완료 알림 받기\
16011                                    </label>\
16012                                </div>\
16013                                <div class="cl-s-form-wrap" id="qna-tel-input" style="display:' + ((qna_answer_alimtalk_str == 'checked')? 'block':'none') + ';">\
16014                                    <div class="cl-s-form-group">\
16015                                        <input type="text" class="cl-s-form-control" id="qna-tel" name="qna_tel" data-type="tel" required="required" value="' + data['tel'] + '">\
16016                                        <label for="input" class="cl-s-control-label">
16016전화번호</label>\
16017                                    </div>\
16018                                </div>\
16019                                ';
16020                            }
16021                        }
16022                        qna_privacy_str += '\
16023                                <div class="cl-s-checkbox">\
16024                                    <label>\
16025                                        <input type="checkbox" id="qna-btn-privacy" name="qna_btn_privacy">\
16026                                        <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>\
16027                                        <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>\
16028                                        <a href="javascript:;" class="qna-view-privacy privacy-toggle" data-view="#qna-privacy-textarea">개인정보 수집 및 이용</a>에 동의합니다.\
16029                                    </label>\
16030                                </div>\
16031                                <div class="qna-privacy-textarea hide" name="privacy_textarea" id="qna-privacy-textarea" style="display:none;">\
16032                                    ※ 비회원 서비스문의를 위한 개인정보 수집·이용 동의(필수)<br>\
16033                                    서비스 이용자의 개인정보를 수집하는 목적은 다음과 같습니다.\
16034                                    <table>\
16035                                        <colgroup>\
16036                                            <col width="25%">\
16037                                            <col width="45%">\
16038                                            <col width="30%">\
16039                                        </colgroup>\
16040                                        <thead>\
16041                                            <tr>\
16042                                                <th>수집목적</th>\
16043                                                <th>수집항목</th>\
16044                                                <th>이용기간</th>\
16045                                            </tr>\
16046                                        </thead>\
16047                                        <tbody>\
16048                                            <tr>\
16049                                                <td>문의 응대 및 서비스 개선</td>\
16050                                                <td>(필수) 이름, 이메일, 문의내용</td>\
16051                                                <td>문의 종료일로 5년</td>\
16052                                            </tr>\
16053                                        </tbody>\
16054                                    </table>\
16055                                    <br>\
16056                                    - 동의를 거부할 권리가 있으나, 동의거부에 따른 서비스 이용에 제한이 있을 수 있습니다.<br>\
16057                                    - 회사는 계약 및 서비스 이행을 위해 개인정보 처리업무를 위탁할 수 있으며, 개인정보처리방침에 그 내용을 고지합니다.<br>\
16058                                </div>\
16059                        ';
16060                    } else {
16061                        if(data['um_qna_fin'] == 'Y') {
16062                            qna_privacy_str += '\
16063                                <div class="cl-s-checkbox">\
16064                                    <label>\
16065                                        <input type="checkbox" id="qna-btn-email" name="answer_email" value="Y" ' + qna_answer_email_str + '>\
16066                                        <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>\
16067                                        <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>\
16068                                        이메일로 답변완료 알림 받기\
16069                                    </label>\
16070                                </div>\
16071                            ';
16072                            
16073                            if(data['talk_cnt'] > 0) { //alimtalk
16074                                qna_privacy_str += '\
16075                                <div class="cl-s-checkbox">\
16076                                    <label>\
16077                                        <input type="checkbox" id="qna-btn-alimtalk" name="answer_alimtalk" value="Y" ' + qna_answer_alimtalk_str + '>\
16078                                        <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>\
16079                                        <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>\
16080                                        알림톡으로 답변완료 알림 받기\
16081                                    </label>\
16082                                </div>\
16083                                ';
16084                            }
16085                        }
16086                    }
16087                    qna_privacy_str += '\
16088                        </div>\
16089                    '; //qna-privacy
16090
16091                    var modal_str = '\
16092                        <div class="qna-body">\
16093                            <h5 class="product-title">' + data['ptitle'] + '</h5>\
16094                            ' + qna_writer_str + '\
16095                            <ul class="qna-content">\
16096                                <li>\
16097                                    <div class="cl-s-form-wrap">\
16098                                        <div class="cl-s-form-group">\
16099                                            <input type="text" class="cl-s-form-control" id="qna-title" name="title" required="required" maxlength="100" value="' + data['title'] + '">\
16100                                            <label for="input" class="cl-s-control-label">제목</label>\
16101                                        </div>\
16102                                    </div>\
16103                                </li>\
16104                                <li>\
16105                                    <div class="cl-s-form-wrap">\
16106                                        <div class="cl-s-form-group input-label-hide">\
16107                                            <textarea type="text" class="cl-s-form-control" id="qna-str" name="qna" maxlength="500" required="required">' + data['qna'] + '</textarea>\
16108                                            <label for="input" class="cl-s-control-label">자세한 내용을 적어주세요. (500자 이내)</label>\
16109                                        </div>\
16110                                    </div>\
16111                                </li>\
16112                                <li class="last clearfix">\
16113                                    <div class="qna-secret">\
16114                                        <div class="secret cl-s-checkbox">\
16115                                            <label>\
16116                                                <input type="checkbox" id="secret-checkbox" name="secret" value="Y" ' + qna_secret_str + '>\
16117                                                <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>\
16118                                                <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>\
16119                                                비밀글\
16120                                            </label>\
16121                                        </div>\
16122                                    </div>\
16123                                    <div class="cl-s-files qna-files f-left">\
16124                                        <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+'\">\
16125                                        <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>\
16126                                        <ul class="cl-s-files-list qna-files-list clearfix">\
16127                                            ' + qna_files_str + '\
16128                                        </ul>\
16129                                    </div>\
16130                                </li>\
16131                            </ul>\
16132                            ' + qna_privacy_str + '\
16133                        </div>\
16134                    ';
16135
16136
16137                    $('.flat-modal .modal').modal('hide');
16138                    var eqnaModal = $(this).showModalFlat('문의 작성', modal_str,true,true,function () {
16139
16140                        var error_cnt = 0;
16141                        var error_str = '';
16142                        var input_data = new Object();
16143
16144                        $('.cl-s-form-control').each(function(idx, v) {
16145                            error_str = '';
16146                            if($(v).val().trim().length == 0) {
16147                                if(!$('input[name="answer_email"]').is(':checked') && $(v).attr('name') == 'qna_email') return;
16148                                if(!$('input[name="answer_alimtalk"]').is(':checked') && $(v).attr('name') == 'qna_tel') return;
16149                                $(v).closest('.cl-s-form-wrap').addClass('empty');
16150                                error_str = '필수항목을 입력해주세요.';
16151                                error_cnt++;
16152                                if(error_cnt == 1) {
16153                                    alert(error_str);
16154                                    $(v).focus();
16155                                    return true;
16156                                }
16157                            } else {
16158                                $(v).closest('.cl-s-form-wrap').removeClass('empty');
16159                                var key = $(v).attr('name');
16160                                var val = $(v).val().trim();
16161                                var passEmoji = ($.inArray(key,['title','qna']) > -1) ? true : false;
16162
16163                                if(!passEmoji && checkEmojis(val)) error_str = $.lang[LANG]['config.unable.emoji'];
16164                                // else if(typeof regexp[key] != "undefined" && !regexp[key].test(val)) error_str = $.lang[LANG]['siteum.regexp.check.'+key];
16165
16166                                if(error_str && error_str.length > 0) {
16167                                    error_cnt ++;
16168                                    if(error_cnt == 1) $(v).focus();
16169
16170                                    $(v).closest('.cl-s-form-wrap').addClass('error');
16171                                    if($(v).closest('.cl-s-form-group').find('.cl-s-control-label.error').length > 0) {
16172                                        $(v).closest('.cl-s-form-group').find('.cl-s-control-label.error').html(error_str);
16173                                    } else {
16174                                        $(v).closest('.cl-s-form-group input').after('<label class="cl-s-control-label error">' + error_str + '</label>');
16175                                    }
16176                                } else {
16177                                    $(v).closest('.cl-s-form-wrap').removeClass('error');
16178                                    $(v).closest('.cl-s-form-group').find('.cl-s-control-label.error').remove();
16179                                    input_data[key] = $(v).val().trim();
16180                                }
16181                            }
16182
16183                        });
16184
16185
16186                        if(error_cnt > 0) {
16187                            // alert(error_str);
16188                            return false;
16189                        }
16190                        
16191                        if(status != 'U') {
16192                            if(!$('#qna-btn-privacy').prop('checked')) {
16193                                $("#qna-btn-privacy").addClass('error');
16194                                alert('개인정보 수집 및 이용 동의에 체크해 주세요.');
16195                                return false;
16196                            }
16197
16198                            if(!$('input[name="answer_email"]').is(':checked')) {
16199                                input_data['qna_email'] = '';
16200                            } else {
16201                                var regexp = {
16202                                    qna_email : /^[a-zA-Z0-9+-\_.]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/i,
16203                                };
16204                                if(typeof regexp['qna_email'] != "undefined" && !regexp['qna_email'].test(input_data['qna_email'])) {
16205                                    alert($.lang[LANG]['siteum.regexp.check.email']);
16206                                    input_data['qna_email'] = '';
16207                                    $('#qna-email').closest('.cl-s-form-wrap').addClass('error');
16208                                    return false;
16209                                }
16210                            }
16211
16212                            if(!$('input[name="answer_alimtalk"]').is(':checked')) {
16213                                input_data['qna_tel'] = '';
16214                            } else {
16215                                if(input_data['qna_tel'].length > 0 && (input_data['qna_tel'].length < 10 || input_data['qna_tel'].length > 15)) {
16216                                    alert('올바르지 않은 번호 양식입니다.\n번호를 다시 확인해 주세요.');
16217                                    input_data['qna_tel'] = '';
16218                                    $('#qna-tel').closest('.cl-s-form-wrap').addClass('error');
16219                                    return false;
16220                                }
16221                            }
16222                        }
16223
16224                        if($('.qna-files-list').children('li').length > 0) {
16225                            var qna_files = '';
16226                            var qna_files_orig = '';
16227                            $('.qna-files-list').children('li').each(function() {
16228                                if(qna_files != '')  qna_files +='||';
16229                                qna_files += $(this).find('input[name="qna_image[]"]').val();
16230                                if(qna_files_orig != '')  qna_files_orig +='||';
16231                                qna_files_orig += $(this).find('input[name="qna_image_orig[]"]').val();
16232                            });
16233                        }
16234                        input_data['qna_image'] = (qna_files) ? qna_files : '';
16235                        input_data['qna_image_orig'] = (qna_files_orig) ? qna_files_orig : '';
16236                        input_data['secret'] = ($('#secret-checkbox').prop('checked')) ? 'Y' : '';
16237                        input_data['answer_email'] = ($('input[name="answer_email"]').prop('checked')) ? 'Y' : 'N';
16238                        input_data['answer_alimtalk'] = ($('input[name="answer_alimtalk"]').prop('checked')) ? 'Y' : 'N';
16239
16240                        var qna_status = { new:'S', edit:'E' },
16241                            page_type = (property.VIEW) ? 'product' : '';
16242                            
16243                        if($('.cl-s-mypage').length > 0) page_type = 'mypage';
16244                        else if($('.cl-s-nonmember-payment').length > 0) page_type = 'no_member';
16245
16246                        input_data['sid'] = sid;
16247                        input_data['page_mode'] = page_type;
16248                        input_data['qna_seq'] = (seq > 0) ? seq : '';
16249                        input_data['qna_type'] = 'P';
16250                        input_data['product_number'] = pnum;
16251                        input_data['order_number'] = onum;
16252                        input_data['status'] = qna_status[mode];
16253                        input_data['mb_status'] = status;
16254                        input_data['qna_page'] = (property.VIEW) ? property.PAGE : '';
16255                        
16256                        $('.ok-button-dialog').prop('disabled', true).addClass('spinner');
16257                        $.ajax({
16258                            url: '/_qna_update',
16259                            type: 'post',
16260                            data: input_data,
16261                            async: true,
16262                            cache: false,
16263                            success: function(data) {
16264                                if(typeof data.error != 'undefined') {
16265                                    alert(data.error);
16266                                    return false;
16267                                }
16268                                location.reload();
16269                            },
16270                            error: function(request,status,error) {
16271                                console.log('code:'+request.status+'\n'+'message:'+request.responseText+'\n'+'error:'+error);
16272                                return false;
16273                            }
16274
16275                        });
16276
16277                    },'close','등록하기','cl-s-product-qna-edit cl-modal cl-s-btn cover', true, '', function() {
16278                        $('.cl-s-product-qna-edit .cl-s-form-group').on('click',function(e) {
16279                            if($(e.target).hasClass('cl-s-form-group')) {
16280                                $(e.target).find('.cl-s-form-control:not([type=hidden])').focus();
16281                            }
16282                        });
16283
16284                        $('.cl-s-product-qna-edit .cl-s-form-control').on({
16285                            focus: function(e) {
16286                                $(this).closest('.cl-s-form-wrap').addClass('active');
16287                            },
16288                            blur: function(e) {
16289                                var type = $(this).attr('data-type'),
16290                                    // regexp = {
16291                                    //     email : /^[a-zA-Z0-9+-\_.]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/i
16292                                    // },
16293                                    // checkRegexp = (typeof type != 'undefined' && typeof regexp[type] != 'undefined') ? true : false,
16294                                    passEmoji = ($.inArray($(this).attr('name'),['title','qna']) > -1) ? true : false,
16295                                    error_str = '',
16296                                    val = $(this).val().trim();
16297
16298                                $(this).closest('.cl-s-form-wrap').removeClass('active');
16299                                if(val.length == 0) {
16300                                    $(this).closest('.cl-s-form-wrap').removeClass('error').addClass('empty');
16301                                    $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
16302                                    return false;
16303                                } else if(!passEmoji && checkEmojis(val)) error_str = $.lang[LANG]['config.unable.emoji'];
16304                                // else if(checkRegexp && !regexp[type].test(val)) error_str = $.lang[LANG]['siteum.regexp.check.'+type];
16305
16306                                $(this).closest('.cl-s-form-wrap').removeClass('empty');
16307                                if(error_str.length > 0) {
16308                                    $(this).closest('.cl-s-form-wrap').addClass('error');
16309                                    if($(this).parent().find('.cl-s-control-label.error').length > 0) {
16310                                        $(this).parent().find('.cl-s-control-label.error').html(error_str);
16311                                    } else {
16312                                        $(this).after('<label for="input" class="cl-s-control-label error">'+error_str+'</label>');
16313                                    }
16314                                    return false;
16315                                } else {
16316                                    $(this).closest('.cl-s-form-wrap').removeClass('error');
16317                                    $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
16318                                }
16319
16320                            }
16321                        });
16322
16323                        $('.cl-s-product-qna-edit #qna-tel').on('keyup', function(e) {
16324                            var txt = $(this).val();
16325                            var match = txt.match(/[0-9]+/g);
16326                            $(this).val(match);
16327                        });
16328
16329                        $('.cl-s-product-qna-edit #qna-btn-privacy').on('change', function(e) {
16330                            if($(this).prop('checked')) $(this).removeClass('error');
16331                            else $(this).addClass('error');
16332                        });
16333
16334                        $(document).on('click', '.cl-s-product-qna-edit .qna-img-close', {mode: 'qna'}, deleteReviewQnaImg);
16335
16336                        $('.cl-s-product-qna-edit .qna-file-update').on('click', function () {
16337                            $("#qna-file").click();
16338                        });
16339
16340                        $('.cl-s-product-qna-edit #qna-file').on('click', {mode: 'qna'}, uploadReviewQnaImg);
16341
16342                        $('label.privacy-toggle').on('change', function(e) {
16343                            var $toggle = $($(this).attr('data-view'));
16344                            if ($(this).find('input[type="checkbox"]').is(':checked')) {
16345                                $toggle.removeClass('hide');
16346                                $toggle.slideDown(300);
16347                            } else {
16348                                $toggle.slideUp(300, function() {
16349                                    $toggle.addClass('hide');
16350                                });
16351                            }
16352                        });
16353
16354                        $('a.privacy-toggle').on('click', function(e) {
16355                            e.preventDefault();
16356                            var $toggle = $($(this).attr('data-view'));
16357                            if ($toggle.hasClass('hide')) {
16358                                $toggle.removeClass('hide');
16359                                $toggle.slideDown(300);
16360                            } else {
16361                                $toggle.slideUp(300, function() {
16362                                    $toggle.addClass('hide');
16363                                });
16364                            }
16365                        });
16366
16367                    }, function(){
16368                        if(qna_files_str.length === 0){
16369                            if($('.cl-s-product-qna-edit .qna-img-close').length > 0){
16370                                $.each($('.cl-s-product-qna-edit .qna-img-close'), function(){
16371                                    $(this).trigger('click');
16372                                });
16373                            }
16374                        }
16375                    });
16376
16377                },
16378                error: function(request,status,error) {
16379                    console.log('code:'+request.status+'\n'+'message:'+request.responseText+'\n'+'error:'+error);
16380                    return false;
16381                }
16382            });
16383
16384        },
16385        orderReceiptModal: function(sid, ogroup, refund) { 
16386
16387            $.post('/_check_receipt', { sid:sid, order_group:ogroup, mode:'default', refund : refund }, function(data) {
16388
16389                if(typeof data.error != 'undefined' && data.error) {
16390                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'ok');
16391                    return false;
16392                }
16393
16394                var d_price = (typeof data.r.delivery_price != 'undefined' && data.r.delivery_price) ? data.r.delivery_price : 0,
16395                    d_price_str = number_format(d_price) + ' 원',
16396                    o_list_cnt = data.r.list.length,
16397                    o_org_total = 0,
16398                    o_total = 0;
16399
16400                var orm_html = '\
16401                    <div class="receipt-wrap">\
16402                        <table>\
16403                            <colgroup>\
16404                                <col width="*" />\
16405                                <col width="120px" />\
16406                                <col width="100px" />\
16407                            </colgroup>\
16408                            \
16409                            <thead>\
16410                                <tr>\
16411                                    <th>상품정보</th>\
16412                                    <th>상품가격</th>\
16413                                    <th>배송비<span class="visible-xs"> ' + d_price_str + '</span></th>\
16414                                </tr>\
16415                            </thead>\
16416                            <tbody>\
16417                ';
16418
16419                var refund_count = 0, list_count = 0;
16420                $.each(data.r.list, function(i, val) {
16421                    if(refund) {
16422                        if(val['d_status'] == 'CY' || val['d_status'] == 'RY') ;
16423                        else {
16424                            return true;
16425                        }
16426                    }
16427
16428                    var option_name    = (!$.isEmptyObject(val['option_list']) && val['option_list']['option_name']) ? val['option_list']['option_name'] : '',
16429                        option_type = (val['option_list']['option_type']=='A') ? '추가옵션' : '옵션',
16430                        option_str     = '';
16431                    if(val['option_list']['option_type']=='A' && val['option_list']['option_group']) {
16432                        option_type = option_type + ' : ' + val['option_list']['option_group'];
16433                    }
16434                    if(option_name && option_name!='noneOption') {
16435                        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>';
16436                    } else {
16437                        option_str     = (val['option_list']['option_text_str']) ? '<span>'+option_type+' : ' + val['option_list']['option_text_str'] + '</span>' : '';
16438                    }
16439                    var checkSale = (typeof val['option_list']['sale_price'] != "undefined" && val['option_list']['sale_price']) ? true : false,
16440                        oi_org_price = (checkSale) ? val['option_list']['sale_price'] : val['option_list']['price'],
16441                        oi_price     = val['option_list']['price'],
16442                        oi_quantity  = val['option_list']['quantity'],
16443                        oi_sum       = oi_price * oi_quantity,
16444                        rowspan = 0;
16445
16446                    if(refund) {
16447                        rowspan = data.r.refund;
16448                    } else {
16449                        rowspan = o_list_cnt;
16450                    }
16451                    o_org_total += (oi_org_price * oi_quantity);
16452                    o_total += oi_sum;
16453
16454                    orm_html += '\
16455                                <tr class="or-grid">\
16456                                    <td class="mp-info">\
16457                                        <div class="cl-s-product-jumbotron clearfix">\
16458                                            <div class="cl-s-product-thumb">\
16459                                                <img src="' + val["pimg"] + '" alt="' + val["pname"] + '" class="img-responsive"/>\
16460                                            </div>\
16461                                            <div class="cl-s-product-info">\
16462                                                <h5 class="cl-s-product-title">' + val["pname"] + '</h5>\
16463                                                <div class="option-str">\
16464                                                    <div>\
16465                                                        <span class="visible-xs option-price">' + number_format(oi_sum) + ' 원</span>\
16466                                                        ' + option_str + '\
16467                                                        <span>' + oi_quantity + '개</span>\
16468                                                    </div>';
16469                                        if(val["etc_info"]) {
16470                                            orm_html += '\
16471                                                    <div>선택일자 : '+val["etc_info"]+'</div>';
16472                                        }
16473                                        orm_html += '\
16474                                                </div>\
16475                                            </div>\
16476                                        </div>\
16477                                    </td>\
16478                                    <td>' + number_format(oi_sum) + ' 원</td>\
16479                    ';
16480
16481                    if(list_count == 0) orm_html += '<td rowspan="' + ((rowspan) ? rowspan : '') + '">' + d_price_str + '</td>';
16482                    list_count++;
16483
16484                    orm_html += '\
16485                                </tr>\
16486                    ';
16487
16488                });
16489
16490                orm_html += '\
16491                            </tbody> \
16492                        </table>\
16493                        <p class="description">현금영수증은 발급 완료된 주문건에 한해 조회 및 출력이 가능하며, 구매확정일 기준으로 발급됩니다.<br>신용카드 매출 전표는 결제완료 시 자동 발급되며, 결제완료 후 확인 및 출력이 가능합니다.\
16494                ';
16495
16496                if(data.r.class_cd == 'PAKM') {
16497                    orm_html += '\
16498                    <br>카카오페이머니 결제 건은 카카오페이 APP에서 전표발행이 제공됩니다.\
16499                    ';
16500                }
16501
16502                orm_html += '</p>\
16503                ';
16504
16505
16506                orm_html += '\
16507                        <div class="receipt-btn-box">\
16508                ';
16509                if(data.r.pay_method != '무통장 입금' && data.r.class_cd != 'PAKM' && data.r.pay_method != '포인트 결제') {
16510                    orm_html += '<span class="cl-s-btn cl-s-btn-12 cl-s-btn-primary btn-card-slip" data-tno="' + data.r.tno + '">카드전표</span>';
16511                }
16512                orm_html += '\
16513                            <span class="cl-s-btn cl-s-btn-12 cl-s-btn-primary btn-receipt-details ' + ((refund == true) ? 'refund' : '') + '">' + ((refund == true) ? '환불영수증' : '구매영수증') + '</span>\
16514                        </div>\
16515                        <span class="cl-s-btn cl-s-btn-12 cl-s-btn-default btn-order-receipt-close">닫기</span>\
16516                    </div">\
16517                ';
16518                var title = (refund) ? '환불 영수증 발급내역' : '영수증 발급내역';
16519                var orModal = $(this).showModalFlat(title, orm_html, true, false, '', 'close', '', 'cl-s-receipt cl-modal cover', false, '', function() {
16520                    $('.btn-order-receipt-close').on('click', function() {
16521                        orModal.modal('hide');
16522                    });
16523
16524                    $('.btn-card-slip').on('click', function() {
16525                        var tno = $(this).data('tno');
16526                        if(data.r.class_cd == 'PANP') {
16527                            window.open('https://new-m.pay.naver.com');
16528                        } else if(isNaN(tno)) { // nicepay
16529                            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');
16530                        } else { // kcp
16531                            // window.open('https://www.kcp.co.kr/center.paysearch.do', '', 'width=1000,height=500,scrollbars=yes');
16532                            window.open('https://www.kcp.co.kr/viewPaymentParent/viewPayment', '', 'width=1200,height=860,scrollbars=yes');
16533                        }
16534                        
16535                    });
16536
16537                    $('.btn-receipt-details').on('click', function() {
16538                        var refund = ($(this).hasClass('refund')) ? true : false;
16539                        $.shoppingmall.orderReceiptDetailModal(sid, ogroup, refund);
16540                    });
16541
16542                });
16543
16544            }, 'json');
16545
16546        },
16547        orderReceiptDetailModal: function(sid, ogroup, refund) {
16548
16549            $.post('/_check_receipt', { sid:sid, order_group:ogroup, mode:'detail', refund : refund }, function(data) {
16550
16551                if(typeof data.error != 'undefined' && data.error) {
16552                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'ok');
16553                    return false;
16554                }
16555                var ordm_html = '\
16556                    <div class="receipt-wrap">\
16557                        <table>\
16558                            <colgroup>\
16559                                <col width="25%" />\
16560                                <col width="75%" />\
16561                            </colgroup>\
16562                            \
16563                            <tbody id="receipt-list">\
16564                                <tr>\
16565                                    <td><span>주문번호</span><br>ORDER NO.</td>\
16566                                    <td>' + ogroup + '</td>\
16567                                </tr>';
16568                if(refund) {
16569                    ordm_html+= '\
16570                                <tr>\
16571                                    <td><span>환불일자</span><br>REFUND DATE</td>\
16572                                    <td>' + data.pay_info.reg_date + '</td>\
16573                                </tr>\
16574                    ';
16575                } else {
16576                    ordm_html+= '\
16577                                <tr>\
16578                                    <td><span>주문날짜</span><br>TRANS DATE</td>\
16579                                    <td>' + data.pay_info.reg_date + '</td>\
16580                                </tr>\
16581                    ';
16582                }
16583                ordm_html+= '\
16584                                <tr>\
16585                                    <td><span>상품명</span><br>DESCRIPTION</td>\
16586                                    <td>' + data.pay_info.product_name + '</td>\
16587                                </tr>\
16588                                <tr>\
16589                                    <td><span>합계</span><br>TOTAL</td>\
16590                                    <td><span>'+number_format(data.pay_info.payment)+'</span> 원</td>\
16591                                </tr>\
16592                                <tr>\
16593                                    <td><span>회사명</span><br>COMPANY NAME</td>\
16594                                    <td>' + data.setting.b_name + '</td>\
16595                                </tr>\
16596                                <tr>\
16597                                    <td><span>대표자</span><br>MASTER</td>\
16598                                    <td>' + data.setting.b_rep + '</td>\
16599                                </tr>\
16600                                <tr>\
16601                                    <td><span>사업자등록번호</span><br>BUSINESS NO.</td>\
16602                                    <td>' + data.setting.b_number + '</td>\
16603                                </tr>\
16604                                <tr>\
16605                                    <td><span>회사주소</span><br>ADDRESS</td>\
16606                                    <td>' + data.setting.b_addr + '</td>\
16607                                </tr>\
16608                                <tr>\
16609                                    <td><span>문의전화</span><br>TEL</td>\
16610                                    <td>' + data.setting.b_tel + '</td>\
16611                                </tr>\
16612                                <tr>\
16613                                    <td><span>서명</span><br>SIGNATURE</td>\
16614                                    <td>' + data.pay_info.buyr_name + '</td>\
16615                                </tr>\
16616                            </tbody>\
16617                        </table>\
16618                        <div class="additional-box">구매 영수증은 세금계산서 등 증빙서류로 활용할 수 없습니다.</div>\
16619                    </div>\
16620                ';
16621                var title = (refund) ? '환불영수증' : '구매영수증';
16622                var ordModal = $(this).showModalFlat(title, ordm_html, true, true, function() {
16623
16624                    $.shoppingmall.printModal(".cl-s-receipt-view");
16625
16626                }, 'close', '출력', 'cl-s-receipt-view cl-modal cover', false);
16627
16628
16629            }, 'json');
16630        },
16631        printModal: function(modalEL) {
16632            var popupWindow = window.open("", "printPopup", "_blank" );
16633
16634            var style = $('#cl_shopping').attr('href');
16635
16636            popupWindow.document.write('<head>');
16637            popupWindow.document.write($('head').html());
16638            popupWindow.document.write('<link rel="stylesheet" href="'+style+'">');
16639            popupWindow.document.write('<style>');
16640            popupWindow.document.write($('#el_0css').html());
16641            popupWindow.document.write('.close-button-dialog, .ok-button-dialog {display:none !important;}');
16642            popupWindow.document.write('.cl-mobile-btn, button.close {display:none !important;}');
16643            popupWindow.document.write('.modal-dialog {width:700px !important;max-width:700px !important;}');
16644            popupWindow.document.write('</style>');
16645            popupWindow.document.write('</head>');
16646
16647            var $table = $(modalEL);
16648     
16649            popupWindow.document.write('<body>');
16650            popupWindow.document.write('<div style="display:block;" class="flat-modal cl-flat-modal">');
16651            popupWindow.document.write($table.parent().parent().html());
16652            popupWindow.document.write('
16652</div></body>');
16653
16654            popupWindow.document.close();
16655
16656            setTimeout(function () {
16657                popupWindow.print();
16658            }, 1500);
16659        },
16660        orderDownloadModal: function(sid, pnum, onum) {
16661
16662            $.post('/_check_download', { sid:sid, pnum:pnum, onum:onum }, function(data) {
16663                
16664                if(typeof data.error != "undefined" && data.error) {
16665                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'close');
16666                    return false;
16667                }
16668
16669                var cnacelBtn = $('.mp-table[data-onum='+ onum +']').find('button[data-fn="orderCancel"]');
16670                cnacelBtn.remove();
16671
16672                var download_href = data.r.url,
16673                    download_name = data.r.name,
16674                    download_real_name = data.r.real_name,
16675                    download_count = data.r.count;
16676
16677                var download_url = new getLocation(download_href),
16678                    file_name = encodeURIComponent(download_name),
16679                    file_real_name = encodeURIComponent(download_real_name),
16680                    go = '/down?n=' + file_real_name + '&s=' + (download_url.pathname).replace('/cr-resource/forum/','').replace('/','&f='),
16681                    temp_el = '<a href="'+go+'" target="_blank" download id="cl-download-a"></a>';
16682
16683                $('body').append(temp_el);
16684                document.querySelector('#cl-download-a').click();
16685                $('#cl-download-a').remove();
16686                
16687                if(download_count > 0) {
16688                    $('.mp-table[data-onum=' + onum + ']').find('.download-str span').text(download_count);
16689                } else {
16690                    $('.mp-table[data-onum=' + onum + ']').find('.download-str').html('<div class="cl-red">다운로드 기한이 지났거나<br>다운로드 횟수를 모두 사용하였습니다.</div>');
16691                    $('.mp-table[data-onum=' + onum + ']').find('button[data-fn="orderDownload"]').addClass('disabled');
16692                }
16693
16694            }, 'json');
16695        },        
16696        orderusedModal: function(sid, pnum, onum) {
16697
16698            $.post('/_check_used', { sid:sid, pnum:pnum, onum:onum }, function(data) {
16699                console.log(data);
16700                if(typeof data.error != "undefined" && data.error) {
16701                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'close');
16702                    return false;
16703                }
16704
16705                var cnacelBtn = $('.mp-table[data-onum='+ onum +']').find('button[data-fn="orderCancel"]');
16706                cnacelBtn.remove();
16707
16708                var download_href = data.r.url,
16709                    download_name = data.r.name,
16710                    download_real_name = data.r.real_name,
16711                    download_count = data.r.count;
16712
16713                var download_url = new getLocation(download_href),
16714                    file_name = encodeURIComponent(download_name),
16715                    file_real_name = encodeURIComponent(download_real_name),
16716                    go = '/down?n=' + file_real_name + '&s=' + (download_url.pathname).replace('/cr-resource/forum/','').replace('/','&f='),
16717                    temp_el = '<a href="'+go+'" target="_blank" download id="cl-download-a"></a>';
16718
16719                $('body').append(temp_el);
16720                $('#cl-download-a').remove();
16721                
16722                if(download_count > 0) {
16723                    $('.mp-table[data-onum=' + onum + ']').find('.download-str span').text(download_count);
16724                } else {
16725                    $('.mp-table[data-onum=' + onum + ']').find('.download-str').html('<div class="cl-red">다운로드 기한이 지났거나<br>다운로드 횟수를 모두 사용하였습니다.</div>');
16726                    $('.mp-table[data-onum=' + onum + ']').find('button[data-fn="orderDownload"]').addClass('disabled');
16727                }
16728                
16729                window.location.reload();
16730            }, 'json');
16731        },
16732    }
16733
16734    // 파일이름 자르기
16735    function limitFilenameLength(filename, maxLength) {
16736        if (filename.length <= maxLength) return filename;
16737
16738        let ext = '';
16739        let name = filename;
16740        const dotIndex = filename.lastIndexOf('.');
16741        if (dotIndex !== -1) {
16742            ext = filename.substring(dotIndex);
16743            name = filename.substring(0, dotIndex);
16744        }
16745
16746        const trimmed = name.substring(0, maxLength - ext.length);
16747        return trimmed + '..' + ext;
16748    }
16749
16750    $.quickbasket = {
16751        data: {},
16752        dataReset: function(){
16753            $.quickbasket.data = {}
16754            $.quickbasket.productStates = {};
16755        },
16756        init: function (sid, pid, pnum) {
16757            $.ajax({
16758                url: '/_quickbasket',
16759                type: 'post',
16760                data: { 'sid':sid, 'pid':pid, 'pnum':pnum },
16761                async: false,
16762                cache: false,
16763                success: function (_data) {
16764                    var data = JSON.parse(_data);
16765
16766                    if(typeof data.error != 'undefined' & data.error) {
16767                        var error_str = (data.error == 'error-none-unique') ? '장바구니에 담기는 도중 오류가 발생했습니다.\n잠시후 다시시도 해주세요.\n같은 현상이 지속된다면 고객센터로 문의해주세요.' : data.error;
16768                        $(this).showModalFlat('INFORMATION', error_str, false, false, '', '', '', 'cl-cmmodal cl-s-btn w560 cl-p0');
16769                        return false;
16770                    }
16771
16772                    $.quickbasket.dataReset();
16773                    var quickbasket_str = '';
16774                    if(typeof data.option_data != 'undefined' && data.option_data) {
16775                        // product has options
16776                        // var check_options_merge = data.option_data.checkOptionsMerge,
16777                        var qbo_total_cnt = 0, 
16778                            qbo_total_price = 0,
16779                            qbo_select_box = '';
16780
16781                        $.quickbasket.data = data.option_data;
16782                        $.quickbasket.data.list.normal_md5 = {};
16783                        if(data.option_data.checkNomalOptionMixed) {
16784                            $.each(data.option_data.list.normal_org, function(a,b) {
16785                                var md5 = '';
16786                                switch(data.option_data.options_type) {
16787                                    case '1': md5 = clmd5.hex_md5(b.option_group + ' / ' + b.option_name); break;
16788                                    case '2': md5 = clmd5.hex_md5(b.option_mix2 + ' / ' + b.option_name); break;
16789                                    case '3': md5 = clmd5.hex_md5(b.option_mix2 + ' / ' + b.option_mix3 + ' / ' + b.option_name); break;
16790                                    default: break;
16791                                }
16792                                $.quickbasket.data.list.normal_md5[md5] = b;
16793                            });
16794                        }
16795
16796                        $.each(data.option_data.list, function(o_key, o_groups) {
16797                            if($.inArray(o_key, ['normal_org','normal_md5']) > -1) return true;
16798
16799                            var check_empty = (o_groups.length == 1 && o_groups[0]['arr'].length == 0) ? true : false;
16800                            if(!check_empty) {
16801                                 var printedTitles = [];
16802                                $.each(o_groups, function(og_idx, og_obj) {
16803                                    if (printedTitles.includes(og_obj['title'])) return true;
16804                                    printedTitles.push(og_obj['title']);                                    
16805                                    if(o_key == 'additional' && og_idx == 0) quickbasket_str += (data.option_data.checkFooterStatus[2] == 'false') ? '' : '<p class="option-title">추가옵션</p>';
16806                                    var qbo_wrap = '',
16807                                        qbo_box = '',
16808                                        qbo_noneoption_val = '';
16809                                    
16810                                    if(og_obj['arr'].length == 0 && (og_obj['value'].length == 0 || og_obj['title'] === null)) return true;
16811                                    let firstOptionNames = [];
16812                                    $.each(og_obj['arr'], function(og_idx2,og_obj2) {
16813                                        if (o_key == 'normal' && og_idx == 0) {
16814                                            // 첫 번째 옵션그룹에서 중복 이름 제거
16815                                            if (firstOptionNames.includes(og_obj2.option_name)) {
16816                                                return true; // continue (중복이면 skip)
16817                                            }
16818                                            firstOptionNames.push(og_obj2.option_name);
16819
16820                                            // download 파일명
16821                                            if (!$.quickbasket.productStates) $.quickbasket.productStates = {};
16822                                            if (og_obj2.product_state) {
16823                                                $.quickbasket.productStates[og_obj2.option_seq] = og_obj2.product_state;
16824                                            }                                            
16825                                        }                                        
16826                                        var div_property = '';
16827                                        if(o_key != 'text'  && !og_obj2.soldout) {
16828                                            div_property += 'onclick="$.quickbasket.pdOptionPick(this, \'' + data.option_data.product_price + '\')" ';
16829                                            // div_property += 'data-status="' + data.option_data.product_state + '" ';
16830                                            div_property += 'data-status="normal" ';
16831                                            div_property += (o_key == 'additional') ? 'data-option_type="' + og_obj2.option_type + '" ' : 'data-type="' + data.option_data.options_type + '" ';
16832                                            div_property += 'data-id
16832x="' + (og_idx2-1) + '" ';
16833                                            if(o_key == 'normal') div_property += 'data-option-index="' + og_idx + '" ';
16834                                            div_property += 'data-option-price="' + og_obj2.option_price + '" ';
16835                                        }
16836                                        var option_str = {
16837                                            'div_class': (og_obj2.soldout) ? 'sold-out' : '',
16838                                            'div_property': div_property,
16839                                            'span1': (og_obj2.soldout) ? '<span class="text-d-lt">' : '',
16840                                            'span2': (og_obj2.soldout) ? '</span>' : '',
16841                                            'seq': (og_obj2.soldout) ? '' : 'data-option-seq="'+og_obj2.option_seq+'"',
16842                                            'soldout': (og_obj2.soldout) ? '<label>품절</label>' : '',
16843                                        }
16844
16845                                        if(og_obj2.option_name == 'noneOption') {
16846
16847                                            if(o_key == 'text') {
16848                                                qbo_noneoption_val = (data.option_data.checkNoneTextOption) ? og_obj2.option_group + ' / ' + og_obj2.val : '';
16849                                            } else if(o_key == 'additional') {
16850                                                // var type = '';
16851                                                // 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
16852                                                var val_arr = og_obj2.val.split('||');
16853                                                if(data.option_data.checkOptionBox) {
16854                                                    if(data.option_data.checkFooterStatus[1] != 'true') {
16855                                                        qbo_select_box = '\
16856                                                            <div class="option-count-box">\
16857                                                                <input type="hidden" name="option_price[]" value="' + data.option_data.product_price + '">\
16858                                                                <input type="hidden" name="option_seq[]" class="option_seq" value="'+ val_arr[3] +'">\
16859                                                                <input type="hidden" class="total-quantity" value="'+ val_arr[2] +'">\
16860                                                                <input type="hidden" name="option_name[]" value="'+ val_arr[0] +'">\
16861                                                                <input type="hidden" name="option_type[]" value="' + ((og_obj2.option_type == null) ? '' : og_obj2.option_type) + '">\
16862                                                                <input type="hidden" name="option_text[]" value="">\
16863                                                                <div class="box-option-row">\
16864                                                                    <div class="box-option-name">' + data.option_data.product_title + '</div>\
16865                                                                </div>\
16866                                                                <div class="box-option-row">\
16867                                                                    <div class="box-option-price"><span class="option-price">' + addCommas(data.option_data.product_price) + '</span>원</div>\
16868                                                                    <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>\
16869                                                                </div>\
16870                                                            </div>\
16871                                                        ';
16872                                                        
16873                                                        qbo_total_cnt++;
16874                                                        qbo_total_price = data.option_data.product_price;
16875                                                    }
16876                                                } else {
16877                                                    qbo_select_box = '<input type="hidden" class="noneoption_seq" value="'+ og_obj2.option_seq +'">';
16878                                                }
16879                                            }
16880
16881                                        } else {
16882                                            if(o_key == 'text') {
16883                                                qbo_box += '\
16884                                                                <div class="cl-s-option-text" data-selected_option="' + ((data.option_data.options_type == 'TR') ? 'Y' : 'N') + '" data-status="' + data.option_data.product_state + '" >\
16885                                                                    <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>\
16886                                                                </div>\
16887                                                ';
16888                                            } else {
16889                                                qbo_box += '\
16890                                                    <div class="' + option_str.div_class + '" data-val="' + og_obj2.val + '" ' + option_str.div_property + '>\
16891                                                        ' + option_str.span1 + '\
16892                                                             <div class="quick-option-row">\
16893                                                                <div class="option-left">\
16894                                                                    <sp
16894an class="number">' + og_obj2.option_number + '.</span>\
16895                                                                    <span class="option-name" ' + option_str.seq + '>' + og_obj2.option_name + option_str.soldout + '</span>\
16896                                                                </div>\
16897                                                                <span class="price">' + og_obj2.option_price_str + ' 원</span>\
16898                                                            </div>';
16899                                                // download 일때 파일명 추가
16900                                                if (data.option_data.product_state === 'download' && og_obj2.product_state) {
16901                                                    var ps = JSON.parse(og_obj2.product_state);
16902                                                    if (ps.file_name && ps.file_url) {
16903                                                        var trimmedName = limitFilenameLength(ps.file_name, 14);
16904                                                        qbo_box += '\
16905                                                            <div class="quick-option-file">\
16906                                                                <span class="quick-option-file-name">' + trimmedName + '</span>\
16907                                                                <span class="quick-option-file-size">' + ps.file_size + '</span>\
16908                                                            </div>';
16909                                                    }
16910                                                }
16911
16912                                                if (og_obj2.product_state) {
16913                                                    og_obj2.val += '||' + encodeURIComponent(og_obj2.product_state);
16914                                                }
16915                                                qbo_box += '\
16916                                                        ' + option_str.span2 + '\
16917                                                    </div>\
16918                                                ';
16919                                            }
16920                                        }
16921                                    });
16922
16923                                    var qbo_key_str = (o_key == 'additional') ? 'addt' : o_key,
16924                                        qbo_required = (o_key == 'normal') ? 'option-required' : '',
16925                                        qbo_disabled = (o_key == 'normal' && og_idx > 0) ? 'option-disabled' : '',
16926                                        qbo_def_index = (o_key == 'normal') ? 'data-def-index="' + og_idx + '"' : '';
16927
16928                                    if(o_key == 'text') {
16929                                        if(data.option_data.checkFooterStatus[1] == 'true') {
16930                                            qbo_wrap = '\
16931                                                <div id="selected-product-option" data-val="' + qbo_noneoption_val + '" data-selected_option="" data-status=""></div>\
16932                                                <div class="text-option-box">\
16933                                                    ' + qbo_box + '\
16934                                                </div>\
16935                                            ';
16936                                            qbo_wrap += (qbo_box == '') ? '' : '\
16937                                                <div class="text-center text-option-btn-box">\
16938                                                    <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>\
16939                                                </div>\
16940                                            ';
16941                                        }
16942                                    } else {
16943                                        qbo_wrap = (
16944                                            (o_key == 'normal' && data.option_data.checkFooterStatus[0] == 'false') ||
16945                                            (o_key == 'additional' && data.option_data.checkFooterStatus[2] == 'false')
16946                                        ) ? '' : '\
16947                                            <div class="select-box">\
16948                                                <div class="selected-option ' + ((o_key == 'normal' && og_idx > 0) ? 'ex' : '' ) + '" id="selected-product' + ((o_key == 'normal') ? '' : qbo_key_str) + '-
16948option"  data-val="" data-selected_option="" data-status="">\
16949                                                    <span class="selected-option-text">' + og_obj['title'] + '</span>\
16950                                                    <span class="selected-option-title hide">' + og_obj['title'] + '</span>\
16951                                                    ' + clSVG('caret',8,4,false) + '\
16952                                                </div>\
16953                                            </div>\
16954                                            <div class="option-box product-option-box" style="display: none;">\
16955                                                ' + qbo_box + '\
16956                                            </div>\
16957                                        ';
16958                                    }
16959
16960                                    quickbasket_str += (qbo_wrap == '') ? '' : '\
16961                                        <div class="cl-s-option-selector cl-s-' + qbo_key_str + '-option-selector ' + qbo_required + ' ' + qbo_disabled + '" ' + qbo_def_index + '>\
16962                                            ' + qbo_wrap + '\
16963                                        </div>\
16964                                    ';
16965                                });
16966
16967                            }
16968                        });
16969
16970                        quickbasket_str += '\
16971                            <div class="option-select-box">\
16972                                ' + qbo_select_box + '\
16973                            </div>\
16974                            <div class="total-price-box">\
16975                                <span class="panel-total-title">총 상품 금액</span>\
16976                                <span class="panel-total-cnt">총 수량 <span class="total-cnt">' + qbo_total_cnt + '</span>개 </span>\
16977                                <span class="panel-total-price"><span class="total-price">' + addCommas(qbo_total_price) + '</span>원</span>\
16978                            </div>\
16979                        ';
16980
16981                        var quickBasketOptionModal = $(this).showModalFlat($.lang[LANG]['gallery.sh.quickbasket.option'], quickbasket_str, true, true, function() {
16982
16983                            if($('.cl-modal-check-quantity').length > 0) return false;
16984
16985                            var checkEmpty = false;
16986                            quickBasketOptionModal.find('.option-normal-price').each(function() {
16987                                if($(this).val() == '' || $(this).val() < 1) {
16988                                    checkEmpty = true;
16989                                    $(this).val(1);
16990                                }
16991                            });
16992                            if(checkEmpty) {
16993                                if($('.cl-modal-check-quantity').length == 0) $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
16994                                return false;
16995                            }
16996
16997                            $.quickbasket.setKeepShopping(sid,RENDER.b.PAGE,pid,pnum);
16998                            var optionName = quickBasketOptionModal.find('input[name="option_name[]"]'),
16999                                optionPrice = quickBasketOptionModal.find('input[name="option_price[]"]'),
17000                                optionCount = quickBasketOptionModal.find('input[name="option_count[]"]'),
17001                                optionSeq = quickBasketOptionModal.find('.option_seq'),
17002                                optionText = quickBasketOptionModal.find('input[name="option_text[]"]'),
17003                                optionType = quickBasketOptionModal.find('input[name="option_type[]"]'),
17004                                etcStartDate = quickBasketOptionModal.find('input[name="etc_start_date[]"]'),
17005                                etcEndDate = quickBasketOptionModal.find('input[name="etc_end_date[]"]'),
17006                                oCnt = quickBasketOptionModal.find('input[name="option_name[]"]').length,
17007                                state = data.option_data.state,
17008                                deliveryType = data.option_data.delivery_type,
17009                                deliveryPayType = data.option_data.delivery_pay_type;
17010
17011                            if (oCnt < 1) {
17012                                $.quickbasket.alertModal('ERROR','옵션을 선택해주세요.','cl-modal-check-select');
17013                                
17014                                // 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() {
17015                                //     modal.closest('.cl-flat-modal').next('.modal-backdrop.in').attr('style', 'z-index: 1050!important');
17016                                //     modal.closest('.modal').css('z-index', 1051);
17017                                //     $(document).on('keydown', function(e) {
17018                                //         if(e.keyCode == 27) modal.modal('hide');
17019                                //     });
17020                                // });
17021                                return false;
17022                            }
17023
17024                            if(quickBasketOptionModal.find('.cl-s-addt-option-selector').length > 0) { //추가옵션 존재
17025                                var optionLength = quickBasketOptionModal.find('.option-count-box:not(.additional) input[name="option_name[]"]').length;
17026                                if(optionLength < 1) {
17027                                    $.quickbasket.alertModal('ERROR','옵션을 선택해주세요.','cl-modal-check-select');
17028                                    return false;
17029                                }
17030                            }
17031
17032                            if(quickBasketOptionModal.find('.cl-s-option-text').length > 0) { //입력형옵션 존재
17033                                var optionTextArr = quickBasketOptionModal.find('input[name="option_text[]"]').map(function(){
17034                                    if($(this).val().trim() != '') {
17035                                        return $(this).val().trim();
17036                                    }
17037                                }).get();
17038                                if(optionTextArr.length < 1) {
17039                                    $.quickbasket.alertModal('ERROR','옵션을 선택해주세요.','cl-modal-check-select');
17040                                    return false;
17041                                }
17042                            }
17043
17044                            if(!quickBasketOptionModal.find('.ok-button-dialog').hasClass('active')) return false;
17045
17046                            var optionNameAry = [],
17047                                optionPriceAry = [],
17048                                optionCountAry = [],
17049                                optionSeqAry = [],
17050                                optionTextAry = [],
17051                                optionTypeAry = [],
17052                                etcStartDateAry = [],
17053                                etcEndDateAry = [];
17054                            
17055                            for (var i=0;i<oCnt;i++) {
17056                                if (optionName[i].value == 'noneOption') {
17057                                    optionName[i].value = '';
17058                                }
17059
17060                                if (optionName[i].value.length == 0) {
17061                                    if(optionText[i].value.length > 0) {
17062                                        optionSeqAry[i] = optionSeq[i].value;
17063                                    } else {
17064                                        optionSeqAry[i] = '';
17065                                    }
17066                                } else if (optionName[i].value.length > 0) {
17067                                    optionSeqAry[i] = optionSeq[i].value;
17068                                }
17069
17070                                if($("#product_state").val() == 'download') {
17071                                    optionSeqAry[i] = optionSeq[i].value;   
17072                                }
17073
17074                                optionTextAry[i] = optionText[i].value; //입력형 옵션
17075                                optionTypeAry[i] = optionType[i].value; //옵션 타입
17076                                optionNameAry[i] = optionName[i].value;
17077                                
17078                                optionPriceAry[i] = optionPrice[i].value;
17079                                optionCountAry[i] = optionCount[i].value;
17080                                
17081                                etcStartDateAry[i] = etcStartDate[i] ? etcStartDate[i].value : '';
17082                                etcEndDateAry[i] = etcEndDate[i] ? etcEndDate[i].value : '';
17083                            }
17084
17085                            var productBasketData = {
17086                                'product_number': data.option_data.product_number, // 상품 번호
17087                                'option_name': optionNameAry,                   // 옵션명
17088                                'option_text': optionTextAry,
17089                                'option_type': optionTypeAry,                   
17090                                'option_price': optionPriceAry,                 // 옵션 가격
17091                                'option_count': optionCountAry,                 // 옵션 개수
17092                                'option_seq': optionSeqAry,                     // 옵션 시퀀스
17093                                'etc_start_date': etcStartDateAry,              // 기타무형 상품 시작 날짜
17094                                'etc_end_date': etcEndDateAry,                  // 기타무형 상품 종료 날짜
17095                                'state': state,                                 // 상품 타입 (normal: 일반상품, download: 다운로드 상품, etc: 기타무형 상품)
17096                                'sid': data.option_data.sid,                    // site id,
17097                                'delivery_type' : deliveryType,                 // 배송타입
17098                                'delivery_pay_type' : deliveryPayType,          // 배송비 지불 (선착불)
17099                            }
17100
17101                            $.quickbasket.initOptions(quickBasketOptionModal, productBasketData);
17102
17103
17104                        }, 'cancel', 'gallery.sh.quickbasket.add', 'cl-cmmodal cl-s-btn w560 in-w360 cl-p0 cl-quickbasket-modal ', false, '', function() {
17105
17106                            if(quickBasketOptionModal.find('.option-count-box:not(.additional)').length >
17106 0) quickBasketOptionModal.find('.modal-footer .ok-button-dialog').addClass('active');
17107                            else quickBasketOptionModal.find('.modal-footer .ok-button-dialog').removeClass('active');
17108                            
17109                            if(quickBasketOptionModal.find('.option-select-box > .option-count-box').length > 0) quickBasketOptionModal.find('.total-price-box .total-cnt').text('1');
17110                            else quickBasketOptionModal.find('.total-price-box .total-cnt').text('0');
17111
17112                            if( quickBasketOptionModal.find('.cl-s-normal-option-selector').length == 0 &&
17113                                quickBasketOptionModal.find('.cl-s-option-date-selector').length == 0 
17114                            ) {
17115                                quickBasketOptionModal.find('.cl-s-option-text input').prop('readonly', false);
17116                            }
17117                            $.quickbasket.pdTotalPriceUpdate(quickBasketOptionModal);
17118                            $.quickbasket.bindOptionCountEvents(quickBasketOptionModal);
17119                            quickBasketOptionModal.find('.cl-s-option-text input').on('keyup blur', function(e) {
17120                                var textOptionTarr = [];
17121                                textOptionTarr = quickBasketOptionModal.find('.cl-s-option-text input').map(function(){
17122                                    var input_str = ($(this).val().trim() != '') ? $(this).val().trim() : '';
17123                                    if(input_str != '' && checkEmojis(input_str)) {
17124                                        input_str = removeEmojis(input_str);
17125                                        $(this).val(input_str);
17126                                    }
17127
17128                                    if(input_str != '') return input_str;
17129                                }).get();
17130
17131                                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) {
17132                                    quickBasketOptionModal.find('.text-option-btn').removeClass('disabled');
17133                                } else {
17134                                    quickBasketOptionModal.find('.text-option-btn').addClass('disabled');
17135                                }
17136                            });
17137
17138                            quickBasketOptionModal.find('.cl-s-option-selector').each(function(idx, item){
17139                                var cnt = quickBasketOptionModal.find('.cl-s-option-selector').length;
17140                                $(this).css('z-index', cnt - idx + 1);
17141                            });
17142                            quickBasketOptionModal.find('.cl-s-option-selector .selected-option').on('click', function (e) {
17143                                if($(this).parents('.cl-s-option-selector').hasClass('option-disabled')) return false;
17144                                var option_parent = $(this).closest('.cl-s-option-selector');
17145
17146                                if(quickBasketOptionModal.find('.product-option-box div').length == 0) return false;
17147                                if ($(this).hasClass('active') === true) {
17148                                    option_parent.find('.product-option-box').slideUp(300);
17149                                    $(this).removeClass('active');
17150                                    $(this).parents('.cl-s-option-selector').removeClass('active');
17151                                } else {
17152                                    option_parent.find('.product-option-box').slideDown(300);
17153                                    $(this).addClass('active');
17154                                    $(this).parents('.cl-s-option-selector').addClass('active');
17155                                }
17156                            });
17157
17158                            quickBasketOptionModal.on('click', function(e) {
17159                                var container = quickBasketOptionModal.find('.cl-s-normal-option-selector #selected-product-option');
17160                                if(container.has(e.target).length == 0) {
17161                                    quickBasketOptionModal.find('.cl-s-normal-option-selector .product-option-box').slide
17161Up(200);
17162                                    container.removeClass('active');
17163                                    container.parents('.cl-s-option-selector').removeClass('active');
17164                                } else {
17165                                    if($(e.target).closest('.cl-s-option-selector').length > 0) {
17166                                        $(e.target).closest('.cl-s-option-selector').siblings('.cl-s-option-selector').find('.product-option-box').slideUp(200);
17167                                    }
17168                                }
17169
17170                                if($(e.target).is('.btn')) {
17171                                    if(quickBasketOptionModal.find('.cl-modal-check-quantity').length > 0) {
17172                                        e.preventDefault(); 
17173                                        return false; 
17174                                    }
17175                                    var input_v = quickBasketOptionModal.find('.box-option-count input').val();
17176                                    if(!$(e.target).hasClass('.box-option-count') && (input_v == '' || Number(input_v) < 1)) {
17177                                        $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
17178                                        if(input_v) quickBasketOptionModal.find('.box-option-count input').val(1);
17179                                        $.quickbasket.pdTotalPriceUpdate(quickBasketOptionModal);
17180                                        return false;
17181                                    }
17182                                }
17183                            });
17184
17185                        });
17186
17187                        return false;
17188
17189                    } else {
17190                        // product none option
17191                        $.quickbasket.setKeepShopping(sid,RENDER.b.PAGE,pid,pnum);
17192                        $.quickbasket.close(true);
17193                        return false;
17194                    }
17195
17196                    // var dataObj = JSON.parse(data.r);
17197                }
17198            });
17199        },
17200        initOptions: function (qbModal, pdBasketObj) {
17201            $.ajax({
17202                url: '/_basket',
17203                type: 'post',
17204                data: pdBasketObj,
17205                async: false,
17206                cache: false,
17207                success: function (data) {
17208                    if (data == 'error-none-unique') {
17209                        alert('장바구니에 담기는 도중 오류가 발생했습니다.\n잠시후 다시시도 해주세요.\n같은 현상이 지속된다면 고객센터로 문의해주세요.');
17210                        return false;
17211                    }
17212
17213                    var checkClnav =  $.clnav.check();
17214                    var dataObj = JSON.parse(data);
17215                    var basketConfirm = dataObj.r.basket_confirm;
17216                    var state = dataObj.r.state;
17217                    var remainQuantity = dataObj.r.remain_quantity;
17218                    var totalQuantity = $('.total-quantity').val();
17219
17220                    if(basketConfirm.indexOf(false)>-1 && basketConfirm.indexOf(true)==-1){
17221                        if(state=='download'){
17222                            alert('장바구니에 이미 담겨있는 상품입니다.');
17223                        } else if(state == 'normal' && (deliveryType != dataObj.r.delivery_type || deliveryPayType != dataObj.r.delivery_pay_type)) {
17224                            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()] + '로 수정해 주세요.');
17225                        }
17226                        else{
17227                            $(this).blur();
17228                            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() {
17229                                modal.closest('.cl-flat-modal').next('.modal-backdrop.in').attr('style', 'z-index: 1050!important');
17230                                modal.closest('.modal').css('z-index', 1051);
17231                                $(document).on('keydown', function(e) {
17232                                    if(e.keyCode == 27) modal.modal('hide');
17233                                });
17234                            });
17235                        }
17236                        return false;
17237                    }
17238
17239                    var optionName = qbModal.find('input[name="option_name[]"]'),
17240                        optionPrice = qbModal.find('input[name="option_price[]"]'),
17241                        optionCount = qbModal.find('input[name="option_count[]"]'),
17242                        optionSeq = qbModal.find('.option_seq'),
17243                        optionQuantity = qbModal.find('.option-normal-price'),
17244                        etcStartDate = qbModal.find('input[name="etc_start_date[]"]'),
17245                        etcEndDate = qbModal.find('input[name="etc_end_date[]"]'),
17246                        oCnt = qbModal.find('input[name="option_name[]"]').length,
17247                        state = qbModal.find('#product_state').val();
17248
17249                    var optionNameAry = [],
17250                        optionSeqAry = [],
17251                        optionQuantityAry = [],
17252                        optionPriceAry = [],
17253                        optionCountAry =   
17254                        etcStartDateAry = [],
17255                        etcEndDateAry = [],
17256                        prod, prodAry = [],
17257                        totalPrice = qbModal.find('.total-price').text().replace(/[\{\}\[\]\/?.,;:|\)*~`!^\-+<>@\#$%&\\\=\(\'\"]/gi, ""),
17258                        fdq_arr = [];
17259
17260                    for (var i=0;i<oCnt;i++) {
17261                        if (optionName[i].value == 'noneOption') optionName[i].value = '';
17262                        optionNameAry[i] = optionName[i].value;
17263                        optionSeqAry[i] = optionSeq[i].value;
17264                        optionQuantityAry[i] = optionQuantity[i].value;
17265                        optionPriceAry[i] = (optionPrice[i].value * 1) * (optionQuantity[i].value * 1);
17266                        optionCountAry[i] = optionCount[i].value;
17267                        etcStartDateAry[i] = etcStartDate[i] ? etcStartDate[i].value : '';
17268                        etcEndDateAry[i] = etcEndDate[i] ? etcEndDate[i].value : '';
17269                        prod = {
17270                            'option_seq': optionSeq[i].value,
17271                            'option_name': optionName[i].value,
17272                            'option_quantity': optionQuantity[i].value,
17273                            'option_price': optionPriceAry[i],
17274                            'etc_option_start': etcStartDate[i] ? etcStartDate[i].value : '',
17275                            'etc_option_end': etcEndDate[i] ? etcEndDate[i].value : '',
17276                        }
17277                        prodAry[i] = prod;
17278
17279                        var fdq_pn = qbModal.find('.product-title [data-project-title]').text(),
17280                            fdq_nm = (optionName[i].value) ? optionName[i].value : qbModal.find('.option-select-box .option-count-box:eq('+i+') .box-option-name').text();
17281                        fdq_arr.push({
17282                            'id': optionSeq[i].value, 
17283                            'name': (fdq_pn != fdq_nm) ? fdq_pn + ' ' + fdq_nm : fdq_nm,
17284                            'quantity': optionQuantity[i].value, 
17285                            'price': optionPriceAry[i], 
17286                        });
17287                    }
17288
17289                    var productCart = {
17290                        'product_number': pdBasketObj.value,   // 상품 번호
17291                        'option': prodAry,                     // 옵션
17292                        'state': state,                        // 상품 타입 (normal: 일반상품, download: 다운로드 상품, etc: 기타무형 상품)
17293                        'total_price': totalPrice,             // 상품 총 가격
17294                        'sid': pdBasketObj.sid,                // site id
17295                    }
17296                    if(typeof productCartCallback == 'function') productCartCallback(productCart);
17297                    if(typeof callbackEvtAddToCart == 'function') callbackEvtAddToCart(fdq_pn,fdq_arr,totalPrice);
17298
17299                    if(basketConfirm.indexOf(true) > -1) {
17300                        var checkFixTypeMenu = (typeof $('.el-menu header.navbar').attr('data-fixtype') != 'undefined' && $('.el-menu header.navbar').attr('data-fixtype')) ? true : false;     
17301                        property.CART = (checkFixTypeMenu || checkClnav) ? dataObj.r.cart_cnt : 'true';
17302                        if(checkClnav) $.clnav.setFixnavShopping($('.cl-nav'));
17303                        else $.shopping.makeSiteFixedCART();
17304
17305                        qbModal.modal('hide');
17306                        $.quickbasket.close(false);
17307                        return false;
17308                    } else {
17309                        if(checkClnav) $.clnav.setFixnavShopping($('.cl-nav'));
17310                        else $.shopping.makeSiteFixedCART();
17311                    }
17312                }
17313            });
17314        },
17315        close: function (checkPlusCart) {
17316            quickbasket_str = '\
17317                <div class="modal-footer mt-20\">\
17318                    <button type="button" class="btn btn-sm btn-line">' + $.lang[LANG]['gallery.sh.quickbasket.goto'] + '</button>\
17319                    <button type="button" class="btn btn-sm btn-active close-button-dialog" data-dismiss="modal">' + $.lang[LANG]['gallery.sh.quickbasket.keep'] + '</button>\
17320                </div>\
17321            ';
17322
17323            var checkClnav = $.clnav.check();
17324
17325            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() {
17326                // quickBasketModal.closest('.cl-flat-modal').next('.modal-backdrop.in').attr('style', 'z-index: 1050!important');
17327                // quickBasketModal.closest('.modal').css('z-index', 1051);
17328
17329                if(checkPlusCart) {
17330                    var checkFixTypeMenu = (typeof $('.el-menu header.navbar').attr('data-fixtype') != 'undefined' && $('.el-menu header.navbar').attr('data-fixtype')) ? true : false;     
17331                    property.CART = (checkFixTypeMenu || checkClnav) ? Number(property.CART) + 1 : 'true';
17332                    if(checkClnav) $.clnav.setFixnavShopping($('.cl-nav'));
17333                    else $.shopping.makeSiteFixedCART();
17334                }
17335
17336                quickBasketModal.find('.btn-line').on('click', function(e) {
17337                    location.href = '/_cart';
17338                    quickBasketModal.modal('hide');
17339                });
17340
17341                $(document).on('keydown', function(e) {
17342                    if(e.keyCode == 13) {
17343                        e.preventDefault();
17344                        return false;
17345                    }
17346                    if(e.keyCode == 27) quickBasketModal.modal('hide');
17347                });
17348            });
17349        },
17350        alertModal: function (am_header, am_content, am_modalclass) {
17351            var am_selector = (am_modalclass) ? '.'+am_modalclass.replace(' ',',.') : '';
17352            if(am_selector != '' && $(am_selector).length > 0) return false;
17353
17354            var am_zindex = ($('body').width() < 768) ? 9998 : 1050;
17355            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() {
17356                am_modal.closest('.cl-flat-modal').next('.modal-backdrop.in').attr('style', 'z-index: '+am_zindex+'!important');
17357                am_modal.closest('.modal').css('z-index', am_zindex+1);
17358
17359                $(document).on('keydown', function(e) {
17360                    if(e.keyCode == 27) am_modal.modal('hide');
17361                });
17362            });
17363        },
17364        bindOptionCountEvents: function (quickbasketModal) {
17365            quickbasketModal = (quickbasketModal && $(quickbasketModal).length) ? $(quickbasketModal).closest('.cl-quickbasket-modal') : $('.cl-quickbasket-modal:visible').last();
17366            if(!quickbasketModal.length) quickbasketModal = $('.cl-quickbasket-modal').last();
17367
17368            quickbasketModal.find('.option-select-box .box-option-count .plus').off('click').on('click', function(e) {
17369                if($('.cl-modal-check-quantity').length > 0) {
17370                    e.preventDefault();
17371                    return false;
17372                }
17373
17374                var totalQuantity = $(this).closest('.option-count-box').find('.total-quantity').val();
17375                var count = $(this).parent().children('input').val();
17376                var optionSeq = $(this).closest('.option-count-box').find('input[name="option_seq[]"]').val();
17377                var optionName = $(this).closest('.option-count-box').find('input[name="option_name[]"]').val();
17378                var optionStartDate = $(this).closest('.option-count-box').find('input[name="etc_start_date[]"]').val();
17379                var etcTotalCount = 0;
17380
17381                var target = this;
17382                var sameCount = 0;
17383                quickbasketModal.find('input[name="option_seq[]"][value="' + optionSeq + '"]').each(function() {
17384                    if($(this).closest('.option-count-box').has(target).length === 0) {
17385                        sameCount += Number($(this).parent().find('input[name="option_count[]"]').val());
17386                    }
17387                });
17388
17389                if (count > 1000) {
17390                    $(this).blur();
17391                    $.quickbasket.alertModal('ERROR','최대 구매 수량은 1000개 입니다.','cl-modal-check-quantity');
17392                    return false;
17393                }
17394
17395                count = (count * 1) + 1;
17396
17397                if(optionStartDate!==undefined && optionStartDate.length > 0){
17398                    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[]"]');
17399                    sameOptions.each(function(){
17400                        etcTotalCount += Number($(this).val());
17401                    });
17402
17403                    if(etcTotalCount >= totalQuantity) {
17404                        $(this).blur();
17405                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
17406                        return false;
17407                    }
17408                } else {
17409                    if(count + sameCount > totalQuantity) {
17410                        $(this).blur();
17411                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
17412                        count = totalQuantity - sameCount;
17413                    }
17414                }
17415
17416                $(this).parent().children('input').val(count);
17417                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
17418            });
17419
17420            quickbasketModal.find('.option-select-box .box-option-count .min').off('click').on('click', function(e) {
17421                if($('.cl-modal-check-quantity').length > 0) {
17422                    e.preventDefault();
17423                    return false;
17424                }
17425
17426                var count = $(this).parent().children('input').val();
17427                count = (count * 1) - 1;
17428
17429                if (count < 1) {
17430                    $(this).blur();
17431                    $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
17432                    e.preventDefault();
17433                    return false;
17434                }
17435
17436                $(this).parent().children('input').val(count);
17437                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
17438            });
17439
17440            quickbasketModal.find('.option-normal-price').off('keyup.quickbasketQty blur.quickbasketQty').on('keyup.quickbasketQty blur.quickbasketQty', function(e) {
17441                if (e.keyCode == 13 || $('.cl-modal-check-quantity').length > 0) {
17442                    e.preventDefault();
17443                    return false;
17444                }
17445
17446                var totalQuantity = $(this).closest('.option-count-box').find('.total-quantity').val();
17447                var cnt = $(this).val();
17448                var optionSeq = $(this).closest('.option-count-box').find('input[name="option_seq[]"]').val();
17449                var optionName = $(this).closest('.option-count-box').find('input[name="option_name[]"]').val();
17450                var optionStartDate = $(this).closest('.option-count-box').find('input[name="etc_start_date[]"]').val();
17451                var etcTotalCount = 0;
17452
17453                cnt = (cnt) ? Number(cnt.replace(/[^0-9\.]/g,'')) : '';
17454                if (!cnt) {
17455                    e.preventDefault();
17456                    return false;
17457                }
17458                $(this).val(cnt);
17459
17460                if(cnt < 1) {
17461                    $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
17462                    $(this).val(1);
17463                    return false;
17464                }
17465                if(totalQuantity==99999 && cnt > 1000) {
17466                    $.quickbasket.alertModal('ERROR','최대 구매 수량은 1000개 입니다.','cl-modal-check-quantity');
17467                    cnt = 1000;
17468                    $(this).val(cnt);
17469                    return false;
17470                }
17471
17472                var target = this;
17473                var sameCount = 0;
17474                quickbasketModal.find('input[name="option_seq[]"][value="' + optionSeq + '"]').each(function() {
17475                    if($(this).closest('.option-count-box').has(target).length === 0) {
17476                        sameCount += Number($(this).parent().find('input[name="option_count[]"]').val());
17477                    }
17478                });
17479
17480                cnt += sameCount;
17481
17482                if(optionStartDate!==undefined && optionStartDate.length > 0){
17483                    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[]"]');
17484                    sameOptions.each(function(){
17485                        etcTotalCount += Number($(this).val());
17486                    });
17487
17488                    if(etcTotalCount > totalQuantity) {
17489                        var inputValue = $(this).val();
17490                        $(this).blur();
17491                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
17492                        $(this).val(inputValue-(etcTotalCount-totalQuantity));
17493                        return false;
17494                    }
17495                } else {
17496                    if(cnt > totalQuantity) {
17497                        $(this).blur();
17498                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
17499                        $(this).val(totalQuantity - sameCount);
17500                        return false;
17501                    }
17502                }
17503
17504                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
17505            });
17506
17507            quickbasketModal.find('.option-select-box .box-delete').off('click').on('click', function(e) {
17508                var optionCountBox = $(this).closest('.option-count-box'),
17509                    optionName = optionCountBox.find('input[name="option_name[]"]').val();
17510
17511                if(optionName == 'noneOption') {
17512                    if(quickbasketModal.find('.cl-s-option-text').length > 0) {
17513                        quickbasketModal.find('.cl-s-option-text > input').prop('readonly', false);
17514                        optionCountBox.find('input[name="option_text[]"]').val('');
17515                    }
17516                }
17517                optionCountBox.remove();
17518                if(quickbasketModal.find('.option-count-box:not(.additional)').length > 0) quickbasketModal.find('.modal-footer .ok-button-dialog').addClass('active');
17519                else quickbasketModal.find('.modal-footer .ok-button-dialog').removeClass('active');
17520
17521                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
17522            });
17523        },
17524        checkQty: function (optionAry) {
17525            var currentOptCnt = 0;
17526            var selectedSeq = optionAry[3]; // option_seq
17527            var quickbasketModal = $('.cl-quickbasket-modal:visible').last();
17528            if(!quickbasketModal.length) quickbasketModal = $('.cl-quickbasket-modal').last();
17529
17530            quickbasketModal.find('.box-option-name').each(function () {
17531                var box = $(this).closest('.option-count-box');
17532                var boxOptionSeq = box.find('.option_seq').val();
17533                var boxQty = parseInt(box.find('.option-normal-price').val() || "0", 10);
17534
17535                if (boxOptionSeq === selectedSeq) {
17536                    currentOptCnt += boxQty;
17537                }
17538            });
17539
17540            if (currentOptCnt >= Number(optionAry[2])) {
17541                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 () {
17542                    modal.closest('.cl-cmmodal').next('.modal-backdrop.in').attr('style', 'z-index: 1050!important');
17543                    modal.closest('.modal').css('z-index', 1051);
17544                    $(document).on('keydown', function (e) {
17545                        if (e.keyCode === 27) modal.modal('hide');
17546                    });
17547                });
17548                return false;
17549            }
17550
17551            return true;
17552        },
17553        pdOptionBoxHtml: function (productPrice, type, optionStatus, optionType, optionAry, textOption, textOptionObj) {
17554            // 옵션에 파일명 추가
17555            var trimmedName = '', fileSize = '';
17556            var psRaw = ($.quickbasket.productStates && optionAry[3]) ? $.quickbasket.productStates[optionAry[3]] : ''; // option_seq
17557            if (psRaw) {
17558                var ps = JSON.parse(psRaw);
17559                if (ps.file_name && ps.file_size) {
17560                    trimmedName = limitFilenameLength(ps.file_name, 14);
17561                    fileSize = ps.file_size;
17562                }
17563            }            
17564            var quickbasketModal = $('.cl-quickbasket-modal:visible').last(),
17565                total = 0,
17566                dateCheckCnt = 1,
17567                etcStartDate = '', etcEndDate = '', etcDate = '';
17568            if(!quickbasketModal.length) quickbasketModal = $('.cl-quickbasket-modal').last();
17569
17570            if (quickbasketModal.find('.cl-s-option-date-selector').length > 0) { //기간
17571                var optionStatus = 'etc';
17572                etcStartDate = quickbasketModal.find('#etc-start-date-option').val();
17573                etcEndDate = quickbasketModal.find('#etc-end-date-option').val();
17574                etcTime = quickbasketModal.find('#etc-time').val();
17575                if (etcEndDate) etcDate = etcStartDate + ' - ' + etcEndDate;
17576                else etcDate = etcStartDate;
17577                if(etcTime) {
17578                    var etcTimeTmp = etcTime.split(' ');
17579                    etcTimeTmp[0] = (etcTimeTmp[0] == 'am')? '오전 ' : '오후 ';
17580                    var etcTimeStr = etcTimeTmp[0] + etcTimeTmp[1];
17581                    etcDate += ' '+etcTimeStr;
17582                    etcStartDate += '|'+etcTime;
17583                    if(etcEndDate) etcEndDate += '|'+etcTime;
17584                }
17585
17586                var etcStartDateAry = quickbasketModal.find('#etc-start-date-option').val().split(".");
17587                var etcEndDateAry = quickbasketModal.find('#etc-end-date-option').val().split(".");
17588                var disabledDateArr = quickbasketModal.find('#etc-exclude-date').val().split(',');
17589                var startDateObj = new Date(etcStartDateAry[0], (etcStartDateAry[1] * 1) - 1, etcStartDateAry[2]);
17590                var endDateObj = new Date(etcEndDateAry[0], (etcEndDateAry[1] * 1) - 1, etcEndDateAry[2]);
17591                var betweenDate = (endDateObj.getTime() - startDateObj.getTime()) / 1000 / 60 / 60 / 24;
17592
17593                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('|'):[];
17594                var disabledDayArr = [];
17595                if(dayArr.length > 0) {
17596                    disabledDayArr = [0, 1, 2, 3, 4, 5, 6];
17597                    $.each(dayArr, function(i, v){
17598                        enableIdx = disabledDayArr.indexOf(daysObj[v]);
17599                        if(enableIdx > -1) {
17600                            disabledDayArr.splice(enableIdx, 1);
17601                        }
17602                    });
17603                }
17604
17605                for (var i=0;i<betweenDate;i++) {
17606                    var dayCheck = 0;
17607                    var dateCheck;
17608                    var dt;
17609 
17610                    dayCheck = new Date(etcStartDateAry[0], (etcStartDateAry[1] * 1) - 1, (etcStartDateAry[2] * 1) + i).getDay();
17611                    dt = new Date(etcStartDateAry[0], (etcStartDateAry[1] * 1) - 1, (etcStartDateAry[2] * 1) + i);
17612                    dateCheck = dt.getFullYear()+'.'+ String(dt.getMonth()+1).padStart(2, '0') +'.'+dt.getDate();
17613                    if (disabledDateArr.indexOf(dateCheck)===-1 && disabledDayArr.indexOf(dayCheck)===-1) dateCheckCnt++;
17614                }
17615            }
17616            var boxOptionTextStr = (textOptionObj)? textOptionObj.map(function(element, index, array){return Object.values(element);}).join(' / ') : ''; //입력옵션 텍스트값
17617            if (dateCheckCnt == 0) dateCheckCnt = 1;
17618
17619            optionAry[0] = (optionAry[0] === undefined) ? '' : strReplace(optionAry[0], '\\quot;', "&quot;");
17620            optionAry[3] = (optionAry[3] === undefined) ? quickbasketModal.find('.noneoption_seq').val() : optionAry[3];
17621            textOption = (textOption === undefined)? '' : textOption;
17622            var optionPrice = (optionAry[1] === undefined)? 0 : Number(optionAry[1]);
17623            var boxOptionPrice = 0;
17624            var boxOptionName = '';
17625            var boxOptionNameArr = new Array();
17626            if(optionType == 'A') {
17627                boxOptionNameArr.push(optionAry[0]);
17628                productPrice = 0;
17629            } else {
17630                if(optionAry[0] != '' && optionAry[0] != 'undefined') { //일반옵션
17631                    boxOptionNameArr.push(optionAry[0]);
17632                }
17633                if(etcDate != '') { //무형-날짜
17634                    if(boxOptionNameArr.indexOf(etcDate) === -1) boxOptionNameArr.push(etcDate);
17635                }
17636                if(textOption!='') { //입력옵션
17637                    boxOptionNameArr.push(boxOptionTextStr);
17638                }
17639            }
17640            boxOptionName = boxOptionNameArr.join(' / '); //옵션명
17641            var cnt = 0;
17642            quickbasketModal.find('.box-option-name').each(function () {
17643                var boxOptionSeq = $(this).closest('.option-count-box').find('.option_seq').val();
17644                var boxOptionText = $(this).closest('.option-count-box').find('input[name="option_text[]"]').val();
17645                if (quickbasketModal.find('.cl-s-option-date-selector').length > 0) { //날짜선택옵션
17646                    if ($(this).text() == boxOptionName || $(this).text() == etcDate) {
17647                        cnt++;
17648                        $(this).blur();
17649                        $.quickbasket.alertModal('ERROR','이 옵션은 이미 선택되어 있습니다.','cl-modal-check-select');
17650                    }
17651                } else {
17652                    if(textOption !== undefined && textOption != '') { //입력옵션 있음
17653                        if(optionAry[3] !== undefined) { //일반옵션 있음
17654                            if (boxOptionSeq == optionAry[3] && boxOptionText == strReplace(textOption, '&quot;', '"')) {
17655                                cnt++;
17656                                $(this).blur();
17657                                $.quickbasket.alertModal('ERROR','이 옵션은 이미 선택되어 있습니다.','cl-modal-check-select');
17658                            }
17659                        } else { //일반옵션 없음
17660                            if (boxOptionText == strReplace(textOption, '&quot;', '"')) {
17661                                cnt++;
17662                                $(this).blur();
17663                                $.quickbasket.alertModal('ERROR','이 옵션은 이미 선택되어 있습니다.','cl-modal-check-select');
17664                            }
17665                        }
17666                        
17667                    } else { //일반옵션만
17668                        if (boxOptionSeq == optionAry[3]) {
17669                            cnt++;
17670                            $(this).blur();
17671                            $.quickbasket.alertModal('ERROR','이 옵션은 이미 선택되어 있습니다.','cl-modal-check-select');
17672                        }
17673                    }   
17674                }
17675            });
17676
17677            if (cnt > 0) return false;
17678
17679            var plusOptionPrice = (optionType == 'A')? optionPrice : ((productPrice * 1) + optionPrice) * dateCheckCnt;
17680            if(plusOptionPrice < 0) {
17681                alert('구매금액이 0원보다 적을 수 없습니다.\r\n판매자에게 문의하세요.');
17682                return false;
17683            }
17684            if(optionType == 'A' && (optionAry[0]).indexOf(' / ') > -1) {
17685                var tmp = (optionAry[0]).split(' / ');
17686                optionAry[0] = tmp[1];
17687            }
17688            var totalPriceOption = (plusOptionPrice + total);
17689            var html = '';
17690                if(optionType == 'A') html += '<div class="option-count-box additional">';
17691                else html += '<div class="option-count-box">';
17692                html += '<input type="hidden" name="option_price[]" value="'+plusOptionPrice+'">';
17693                html += '<input type="hidden" name="option_seq[]" class="option_seq" value="'+optionAry[3]+'">';
17694                html += '<input type="hidden" class="total-quantity" value="'+optionAry[2]+'">';
17695                if (type) html += '<input type="hidden" name="option_name[]" value="noneOption">';
17696                else html += '<input type="hidden" name="option_name[]" value="'+optionAry[0]+'">';
17697                if(optionType != '') html += '<input type="hidden" name="option_type[]" value="'+optionType+'">';
17698                else html += '<input type="hidden" name="option_type[]" value="">';
17699                html += '<input type="hidden" name="option_text[]" value="'+textOption+'">';
17700                html += '<div class="box-option-row">';
17701                if (quickbasketModal.find('.cl-s-option-date-selector').length > 0) { //기간 있음
17702                    if(optionType != 'A') {
17703                        html += '<input type="hidden" name="etc_start_date[]" value="'+etcStartDate+'">';
17704                        html += '<input type="hidden" name="etc_end_date[]" value="'+etcEndDate+'">';
17705                    } else {
17706                        html += '<input type="hidden" name="etc_start_date[]" value="">';
17707                        html += '<input type="hidden" name="etc_end_date[]" value="">';
17708                    }
17709                    if (type) html += '<div class="box-option-name">' + etcDate + '</div>';
17710                    else html += '<div class="box-option-name">' + boxOptionName + '</div>';
17711                } else { //기간 없음
17712                    html += '<div class="box-option-name">'+boxOptionName+'</div>';
17713                }
17714                    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>';
17715                html += '</div>'; //end row
17716
17717                // 파일명 추가
17718                if (trimmedName && fileSize) {
17719                    html += '<div class="quick-option-file2">';  // 새로운 줄
17720                    html += '<span class="quick-option-file-name">' + trimmedName + '</span><br>';
17721                    html += '<span class="quick-option-file-size">' + fileSize + '</span>';
17722                    html += '</div>';
17723                }
17724
17725                html += '<div class="box-option-row">';
17726                    html += '<div class="box-option-price">
17726<span class="option-price">'+number_format(plusOptionPrice)+'</span>원</div>';
17727                    html += '<div class="box-option-count">';
17728                    html += '<div class="form-group">';
17729                    html += '<span class="min"><svg viewBox="0 0 11 11" width="11" height="11"><rect y="5" width="11" height="1"/></svg></span>';
17730                    html += '<input type="text" class="option-normal-price" value="1" numberOnly="true" name="option_count[]">';
17731                    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>';
17732                    html += '</div>';
17733                    html += '</div>';
17734                html += '</div>'; //end row
17735                html += '</div>';
17736
17737            return html;
17738        },
17739        pdOptionPick: function (obj, productPrice) {
17740            // console.log('pdOptionPick() ----------------------------------------------');
17741            // console.log($.quickbasket.data);
17742
17743            var quickbasketModal = $(obj).closest('.cl-quickbasket-modal'),
17744                type = '',
17745                option = obj.getAttribute('data-val'),
17746                optionAry = option.split('||'),
17747                optionStatus =  obj.getAttribute('data-status'),
17748                optionType = obj.getAttribute('data-option_type'),
17749                _idx = obj.getAttribute('data-idx'),
17750                total = 0,
17751                totalCnt = 1,
17752                dateCheckCnt = 1,
17753                submit = false,
17754                reSelected = false,
17755                parent = $(obj).closest('.cl-s-option-selector'),
17756                textParent = $(obj).closest('.cl-s-option-text'),
17757                selectedBoxTitle = parent.find('.selected-option-title').text(),
17758                selectedPrice = $(obj).attr('data-option-price'),
17759                onlySelectedText = $(obj).find('.option-name').text();
17760
17761            if(quickbasketModal.find('.cl-s-normal-option-selector').length > 1 && !$.quickbasket.checkQty(optionAry)) return false; //옵션재고수량 검사
17762
17763            selectedBoxTitle += (selectedBoxTitle.length > 0) ? ' / ' : '';
17764            if(selectedPrice != undefined) {
17765                selectedPrice = (selectedPrice.indexOf('-') > -1) ? '-' + number_format(selectedPrice.substring(1)) : '+' + number_format(selectedPrice);
17766                selectedPrice = ' (' + selectedPrice + '원)';
17767            } else selectedPrice = '';
17768
17769            if(parent.hasClass('cl-s-normal-option-selector')) {
17770                var selected_option = $(obj).parents('.cl-s-normal-option-selector'),
17771                    selected_index = selected_option.attr('data-def-index'),
17772                    last_index = quickbasketModal.find('.cl-s-normal-option-selector').last().attr('data-def-index');
17773                if (selected_index != last_index) reSelected = true;
17774            }
17775
17776            // 하위메뉴 리셋
17777            if(selected_index != undefined) {
17778                $.each(quickbasketModal.find('.cl-s-normal-option-selector'), function(i,v) {
17779                    if(i > Number(selected_index)) {
17780                        var otitle = $(this).find('.selected-option-title').text();
17781                        $(this).addClass('option-disabled');
17782                        $(this).find('.selected-option')
17783                                .attr('data-selected_option','')
17784                                .attr('data-val','')
17785                                .attr('data-status','');
17786                        $(this).find('.selected-option-text').text(otitle);
17787                    }
17788                });
17789            }
17790
17791            setTimeout(function() {
17792                var checkSelectEmpty = (quickbasketModal.find('.cl-s-option-selector.option-required .selected-option[data-val=""]').length > 0) ? true : false,
17793                    checkInputEmpty = false;
17794                quickbasketModal.find('.text-option-box input').each(function() {
17795                    if($(this).val() == '' || $(this).val().trim() == '') checkInputEmpty = true;
17796                });
17797
17798                if(!checkSelectEmpty && !checkInputEmpty) quickbasketModal.find('.text-option-btn').removeClass('disabled');
17799                else quickbasketModal.find('.text-option-btn').addClass('disabled');
17800            }, 100);
17801
17802            // 추가옵션 존재
17803            if(quickbasketModal.find('.cl-s-option-text input').length > 0 || quickbasketModal.find('.cl-s-normal-option-selector.option-disabled').length > 0 || reSelected) {
17804                //셀렉트박스 선택
17805                var optionSelectedVal = (quickbasketModal.find('.cl-s-option-text input').length > 0) ? quickbasketModal.find('#selected-product-option').attr('data-val') : '';
17806                var selectedOptionName = selectedBoxTitle + onlySelectedText + selectedPrice;
17807                if (optionType == null) {
17808                    parent.find('.selected-option-text').text(selectedOptionName);
17809                    parent.find('.selected-option').attr('data-selected_option', onlySelectedText);
17810                    parent.find('.selected-option').attr('data-val', option);
17811                    parent.find('.selected-option').attr('data-status', optionStatus);
17812                }
17813
17814                // console.log(obj.getAttribute('data-type'));
17815                if(quickbasketModal.find('.cl-s-normal-option-selector.option-disabled').length == 0) {
17816                    quickbasketModal.find('.cl-s-option-text input').prop('readonly', false);
17817                }
17818
17819                if(obj.getAttribute('data-type') == '1') {
17820                    quickbasketModal.find('.cl-s-normal-option-selector.option-disabled').eq(0).removeClass('option-disabled');
17821                } else if(obj.getAttribute('data-type') == '2') {
17822                    var $required = quickbasketModal.find('.cl-s-normal-option-selector').eq(1),
17823                        $op = $required.find('.product-option-box'),
17824                        idx = 0;
17825
17826                    $required.find('.selected-option-text').text('선택');
17827                    $op.empty();
17828                    var selectedMix2 = onlySelectedText;
17828 // 첫 번째 옵션에서 선택한 값
17829                    $.each($.quickbasket.data.list.normal[_idx]['value'], function(a,b) {
17830                        if (b.option_mix2 !== selectedMix2) return true;
17831                        if(b.option_status == 'H') return true;
17832                        var custom_option_number = (a + 1).toString().padStart(2, '0');
17833                        b.option_number = custom_option_number;
17834                        var div_property = '';
17835                        if(!b.soldout) {
17836                            div_property += 'onclick="$.quickbasket.pdOptionPick(this, \'' + productPrice + '\')" ';
17837                            div_property += 'data-status="normal" ';
17838                            div_property += 'data-idx="' + a + '" ';
17839                            // if(o_key == 'normal') div_property += 'data-option-index="' + og_idx + '" ';
17840                            div_property += 'data-option-price="' + b.option_price + '" ';
17841                        }
17842                        var option_str = {
17843                            'div_class': (b.soldout) ? 'sold-out' : '',
17844                            'div_property': div_property,
17845                            'span1': (b.soldout) ? '<span class="text-d-lt">' : '',
17846                            'span2': (b.soldout) ? '</span>' : '',
17847                            'seq': 'data-option-seq="'+b.option_seq+'"',
17848                            'soldout': (b.soldout) ? '<label>품절</label>' : '',
17849                        }
17850
17851                        var s = '\
17852                            <div class="' + option_str.div_class + '" data-val="' + b.val + '" ' + option_str.div_property + '>\
17853                                ' + option_str.span1 + '\
17854                                    <span class="number">' + b.option_number + '.</span>\
17855                                    <div class="option-name" ' + option_str.seq + '>' + b.option_name + option_str.soldout + '</div>\
17856                                    <span class="price">' + b.option_price_str + ' 원</span>\
17857                                ' + option_str.span2 + '\
17858                            </div>\
17859                        ';
17860
17861
17862                        /*
17863                        if(soldout == true) {
17864                            var s = '\
17865                            <div class="sold-out" data-val="' + b.option_name + '||' + b.option_price + '||0">\
17866                                <span class="text-d-lt">\
17867                                    <span class="number">' + b.option_number + '.</span>\
17868                                    <div class="option-name" data-option-seq="' + b.option_seq + '">' + b.option_name + '<label>품절</label></div>\
17869                                    <span class="price">' + b.option_price_str + ' 원</span>\
17870                                </span>\
17871                            </div>\
17872                            ';
17873                        } else {
17874                            var s = '\
17875                            <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 + '">\
17876                                <span class="number">' + b.option_number + '.</span>\
17877                                <div class="option-name" data-option-seq="' + b.option_seq + '">' + b.option_name + '</div>\
17878                                <span class="price">' + b.option_price_str + ' 원</span>\
17879                            </div>\
17880                            ';
17881                        }
17882                        */
17883                        $op.append(s);
17884                        idx++;
17885                    });
17886                    $required.removeClass('option-disabled');
17887                } else if(obj.getAttribute('data-type') == '3') {
17888
17889                    var option_index = obj.getAttribute('data-option-index'),
17890                        selected_index = Number(option_index) + 1,
17891                        $required = quickbasketModal.find('.cl-s-normal-option-selector').eq(selected_index),
17892                        $op = $required.find('.product-option-box'),
17893                        idx = 0;
17894                        $data = (option_index == '0') ? $.quickbasket.data.list.normal[_idx]['value'] : $.quickbasket.data.list.normal[_idx]['value2'];
17895
17896                    if(option_index == '1') {
17897                        var s1 = quickbasketModal.find('.cl-s-normal-option-selector').eq(0).find('.selected-option').attr('data-selected_option'),
17898                            s2 = onlySelectedText,
17899                            result = [];
17900                        $.each($.quickbasket.data.list.normal_org, function(a,b) {
17901                            if(b['option_mix2'] == s1 && b['option_mix3'] == s2) {
17902                                var tmp = b;
17903                                tmp['option_number'] = String(result.length + 1).padStart(2, '0');
17904                                result.push(tmp);
17905                            }
17906                        });
17907
17908                        $data = result;
17909                    }
17910                    // $required.find('.selected-option-text').text('선택');
17911
17912                    $op.empty();
17913                    $.each($data, function(a,b) {
17914                        var div_property = '';
17915                        if(selected_index == '2' && b.soldout) {
17916                        } else {
17917                            div_property += 'onclick="$.quickbasket.pdOptionPick(this, \'' + productPrice + '\')" ';
17918                            // div_property += 'data-status="' + data.option_data.product_state + '" ';
17919                            div_property += 'data-status="normal" data-type="3" ';
17920                            div_property += 'data-idx="' + a + '" ';
17921                            div_property += 'data-option-index="' + selected_index + '" ';
17922                            div_property += 'data-option-price="' + b.option_price + '" ';
17923                        }
17924                        var option_val_arr = b.val.split('||');
17925                        option_val_arr[0] = (selected_index == '2') ? b.option_name : b.option_mix3;
17926                        var option_str = {
17927                            'div_class': (b.soldout) ? 'sold-out' : '',
17928                            'div_property': div_property,
17929                            'span1': (b.soldout) ? '<span class="text-d-lt">' : '',
17930                            'span2': (b.soldout) ? '</span>' : '',
17931                            'seq': 'data-option-seq="'+b.option_seq+'"',
17932                            'soldout': (selected_index == '2' && b.soldout) ? '<label>품절</label>' : '',
17933                            'val' : option_val_arr.join('||'),
17934                        }
17935
17936                        var s = '\
17937                            <div class="' + option_str.div_class + '" data-val="' + option_str.val + '" ' + option_str.div_property + '>\
17938                                ' + option_str.span1 + '\
17939                                    <span class="number">' + b.option_number + '.</span>\
17940                                    <div class="option-name" ' + option_str.seq + '>' + option_val_arr[0] + option_str.soldout + '</div>\
17941                                    <span class="price">' + b.option_price_str + ' 원</span>\
17942                                ' + option_str.span2 + '\
17943                            </div>\
17944                        ';
17945
17946
17947
17948                        // var quantity = ($.quickbasket.data.product_quantity_on == 'on') ? b.option_quantity : 99999,
17949                        //     soldout = (quantity == 0 || b.option_status == 'O') ? true : false,
17950                        //     col = (selected_index == '2') ? b.option_name : b.option_mix3;
17951                        // if(selected_index == '2' && soldout == true) {
17952                        //     var s = '\
17953                        //     <div class="sold-out" data-val="' + b.option_name + '||' + b.option_price + '||0">\
17954                        //         <span class="text-d-lt">\
17955                        //             <span class="number">' + b.option_number + '.</span>\
17956                        //             <div class="option-name" data-option-seq="' + b.option_seq + '">' + col + '<label>품절</label></div>\
17957                        //             <span class="price">' + b.option_price_str + ' 원</span>\
17958                        //         </span>\
17959                        //     </div>\
17960                        //     ';
17961                        // } else {
17962                        //     var s = '\
17963                        //     <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 + '">\
17964                        //         <span class="number">' + b.option_number + '.</span>\
17965                        //         <div class="option-name" data-option-seq="' + b.option_seq + '">' + col + '</div>\
17966                        //         <span class="price">' + b.option_price_str + ' 원</span>\
17967                        //     </div>\
17968                        //     ';
17969                        // }
17970                        $op.append(s);
17971                        idx++;
17972                    });
17973                    $required.removeClass('option-disabled');
17974                }
17975                
17976                optionAry = (typeof optionSelectedVal !== 'undefined' && optionSelectedVal) ? optionSelectedVal.split('||') : optionAry;
17977                
17978                if (optionType == 'A') {
17979                    optionAry = option.split('||');
17980                }
17981                // var boxOptionName = optionAry[0] ;
17982                if (optionType != 'A') {
17983                    parent.find(".product-option-box").slideToggle(300);
17984
17985                    if (parent.find(".selected-option").hasClass('active') === true) {
17986                        parent.find(".selected-option").removeClass('active');
17987                    } else {
17988                        parent.find(".selected-option").addClass('active');
17989                    }
17990
17991                    return false;
17992                }
17993            } else {
17994                //셀렉트박스 선택
17995                var selectedOptionName = selectedBoxTitle + onlySelectedText + selectedPrice;
17996                if (optionType == null) {
17997                    parent.find('.selected-option-text').text(selectedOptionName);
17998                    parent.find('.selected-option').attr('data-selected_option', onlySelectedText);
17999                    parent.find('.selected-option').attr('data-val', option);
18000                    parent.find('.selected-option').attr('data-status', optionStatus);
18001                }
18002                
18003                option = quickbasketModal.find('.selected-option:not(#selected-delivery-type)').eq(0).attr('data-val'); 
18004                
18005                if(option == undefined || option == '') {
18006                    submit = false;
18007                } else {
18008                    optionAry = option.split('||'); 
18009                    optionStatus =  quickbasketModal.find('#selected-product-option').attr('data-status');
18010                    optionType = quickbasketModal.find('#selected-product-option').attr('data-option_type');
18011                    submit = true;
18012                }
18013            }
18014
18015            if($(obj).parents('.cl-s-option-selector').hasClass('cl-s-normal-option-selector')) {
18016                // 추가된 기본 옵션
18017                $.each(quickbasketModal.find('.selected-option.ex'), function(i,v) {
18018                    var selectedOption = $(this).attr('data-val');
18019                    if(selectedOption == undefined) selectedOption = '';
18020                    var ex_option_arry = selectedOption.split('||');
18021                    if(ex_option_arry[0] !== undefined) {
18022                        if(optionAry[0] !== undefined) optionAry[0]+=' / ' + ex_option_arry[0];
18023                    }
18024                    if(ex_option_arry[1] !== undefined) {
18025                        if(optionAry[1] !== undefined) optionAry[1] = Number(optionAry[1]) + Number(ex_option_arry[1]);
18026                    }
18027                    if(ex_option_arry[2] !== undefined) {
18028                        if(optionAry[2] !== undefined) optionAry[2] = Number(ex_option_arry[2]);
18029                    }
18030                    if(ex_option_arry[3] !== undefined) {
18031                        if($.quickbasket.data.options_type == '1') {
18032                            if(optionAry[3] !== undefined) optionAry[3]+=',' + ex_option_arry[3];
18033                        } else optionAry[3] = ex_option_arry[3];
18034                    }
18035                });
18036            }
18037            
18038            if($(obj).parents('.cl-s-option-selector').hasClass('cl-s-addt-option-selector')) {
18039                var option_title = selectedBoxTitle;
18040                option = $(obj).attr('data-val');
18041                optionType = $(obj).attr('data-option_type');
18042                optionAry = option.split('||');
18043                if(optionAry[0] !== undefined) optionAry[0] = option_title + optionAry[0];
18044                $(obj).parents('.cl-s-option-selector').removeClass('active');
18045            }
18046
18047            //html 생성
18048            var html = $.quickbasket.pdOptionBoxHtml(productPrice, type, optionStatus, optionType == null ? '' : optionType, optionAry, '');
18049            parent.find('.product-option-box').slideToggle(300);
18050
18051            if (parent.find('.selected-option').hasClass('active') === true) parent.find('.selected-option').removeClass('active');
18052            else parent.find('.selected-option').addClass('active');
18053
18054            if(quickbasketModal.find('.cl-s-option-text').length > 0 && optionType != 'A') {
18055                return false;
18056            } else {
18057                quickbasketModal.find('.option-select-box').append(html);
18058                if(quickbasketModal.find('.option-count-box:not(.additional)').length > 0) quickbasketModal.find('.modal-footer .ok-button-dialog').addClass('active');
18059                else quickbasketModal.find('.modal-footer .ok-button-dialog').removeClass('active');
18060            }
18061            
18062            //합계
18063            $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18064
18065            if (optionStatus === null || optionStatus=='etc') {
18066                var lastBox = quickbasketModal.find('.option-count-box').last();
18067                var totalQuantity = lastBox.find('.total-quantity').val();
18068                var state = quickbasketModal.find('#product_state').val();
18069                var optionSeq = lastBox.find('input[name="option_seq[]"]').val();
18070                var optionName = lastBox.find('input[name="option_name[]"]').val();
18071                var optionStartDate = lastBox.find('input[name="etc_start_date[]"]').val();
18072                var optionCount = quickbasketModal.find('input[name="option_count[]"]');
18073                var optionCountAry = [];
18074                var etcTotalCount = 0;
18075                
18076                if(optionStartDate!==undefined && optionStartDate.length > 0) { 
18077                    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[]"]');
18078                    var sameOptionsTotal = sameOptions.find('.total-quantity').val();
18079                    
18080                    sameOptions.each(function(){
18081                        etcTotalCount += Number($(this).val());
18082                    });
18083                    
18084                    if(etcTotalCount > totalQuantity) {
18085                        // alert('재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.');
18086                        $(this).blur();
18087                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18088                        lastBox.remove();
18089                    }
18090                    $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18091                    submit = true;
18092                }
18093            }
18094
18095            if(submit) {
18096                // 옵션 초기화
18097                quickbasketModal.find('.selected-option')
18098                                .attr('data-selected_option','')
18099                                .attr('data-val','')
18100                                .attr('data-status','');
18101                    // .find('.selected-option-text').text('선택');
18102                $.each(quickbasketModal.find('.cl-s-option-selector'), function(i,v) {
18103                    var title = $(this).find('.selected-option-title').text();
18104                    if(title == '') title = '선택';
18105                    $(this).find('.selected-option-text').text(title);
18106                });
18107                $.each(quickbasketModal.find('.cl-s-normal-option-selector'), function(i,v) {
18108                    if(i > 0) $(this).addClass('option-disabled');
18109                });
18110                quickbasketModal.find('#etc-start-date-option, #etc-end-date-option, #etc-time, #etc-start-date-txt, #etc-end-date-txt').val('');
18111                quickbasketModal.find('.selected-option > span').each(function(idx, v){
18112                    if($(v).attr('data-default') !== undefined) {
18113                        $(v).text($(v).attr('data-default'));
18114                    }
18115                });
18116            }
18117
18118
18119            quickbasketModal.find('.option-select-box .box-option-count .plus').off('click').on('click', function(e) {
18120                if($('.cl-modal-check-quantity').length > 0) {
18121                    e.preventDefault(); 
18122                    return false; 
18123                }
18124
18125                var totalQuantity = $(this).closest('.option-count-box').find('.total-quantity').val();
18126                var count = $(this).parent().children('input').val();
18127                var state = quickbasketModal.find('#product_state').val();
18128                var optionSeq = $(this).closest('.option-count-box').find('input[name="option_seq[]"]').val();
18129                var optionName = $(this).closest('.option-count-box').find('input[name="option_name[]"]').val();
18130                var optionStartDate = $(this).closest('.option-count-box').find('input[name="etc_start_date[]"]').val();
18131                var etcTotalCount = 0;
18132
18133                var target = this;
18134                var sameCount = 0;
18135                quickbasketModal.find('input[name="option_seq[]"][value="' + optionSeq + '"]').each(function() {
18136                    if($(this).closest('.option-count-box').has(target).length === 0) {
18137                        sameCount += Number($(this).parent().find('input[name="option_count[]"]').val());
18138                    }
18139                });
18140
18141
18142                if (count > 1000) {
18143                    $(this).blur();
18144                    $.quickbasket.alertModal('ERROR','최대 구매 수량은 1000개 입니다.','cl-modal-check-quantity');
18145                    return false;
18146                }
18147                
18148                count = (count * 1) + 1;
18149
18150                if(optionStartDate!==undefined && optionStartDate.length > 0){
18151                    etcTotalCount = 0;
18152
18153                    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[]"]');
18154
18155                    var sameOptionsTotal = sameOptions.find('.total-quantity').val();
18156                    sameOptions.each(function(){
18157                        etcTotalCount += Number($(this).val());
18158                    });
18159
18160                    if(etcTotalCount >= totalQuantity) {
18161                        $(this).blur();
18162                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18163                        return false;
18164                    }
18165                }
18166                else {
18167                    if(count + sameCount > totalQuantity) {
18168                        $(this).blur();
18169                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18170                        count = totalQuantity - sameCount;
18171                    }
18172                }
18173
18174
18175                $(this).parent().children('input').val(count);
18176                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18177            });
18178            quickbasketModal.find('.option-select-box .box-option-count .min').off('click').on('click', function(e) {
18179                if($('.cl-modal-check-quantity').length > 0) {
18180                    e.preventDefault(); 
18181                    return false; 
18182                }
18183
18184                var count = $(this).parent().children('input').val();
18185                count = (count * 1) - 1;
18186
18187                if (count < 1) {
18188                    $(this).blur();
18189                    $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
18190                    e.preventDefault(); 
18191                    return false;
18192                }
18193
18194                $(this).parent().children('input').val(count);
18195                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18196            });
18197
18198            quickbasketModal.find('.option-normal-price').off('keyup.quickbasketQty blur.quickbasketQty').on('keyup.quickbasketQty blur.quickbasketQty', function(e) {
18199                if (e.keyCode == 13 || $('.cl-modal-check-quantity').length > 0) { 
18200                    e.preventDefault(); 
18201                    return false; 
18202                }
18203
18204                var totalQuantity = $(this).closest('.option-count-box').find('.total-quantity').val(),
18205                    cnt = $(this).val();
18206                var state = quickbasketModal.find('#product_state').val();
18207                var optionSeq = $(this).closest('.option-count-box').find('input[name="option_seq[]"]').val();
18208                var optionName = $(this).closest('.option-count-box').find('input[name="option_name[]"]').val();
18209                var optionStartDate = $(this).closest('.option-count-box').find('input[name="etc_start_date[]"]').val();
18210                var etcTotalCount = 0;
18211                
18212                cnt = (cnt) ? Number(cnt.replace(/[^0-9\.]/g,'')) : '';
18213                if (!cnt) {
18214                    // if(e.type == 'blur') {
18215                    //     $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
18216                    //     return false;
18217                    // } else {
18218                    //     return false;
18219                    // }
18220                    e.preventDefault(); 
18221                    return false;
18222                }
18223                $(this).val(cnt);
18224                
18225                if(cnt < 1) {
18226                    $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
18227                    $(this).val(1);
18228                    return false;
18229                }
18230                if(totalQuantity==99999 && cnt > 1000) {
18231                    $.quickbasket.alertModal('ERROR','최대 구매 수량은 1000개 입니다.','cl-modal-check-quantity');
18232                    cnt = 1000;
18233                    $(this).val(cnt);
18234                    return false;
18235                }
18236
18237                var target = this;
18238                var sameCount = 0;
18239                quickbasketModal.find('input[name="option_seq[]"][value="' + optionSeq + '"]').each(function() {
18240                    if($(this).closest('.option-count-box').has(target).length === 0) {
18241                        sameCount += Number($(this).parent().find('input[name="option_count[]"]').val());
18242                    }
18243                });
18244
18245                cnt += sameCount;
18246
18247                if(optionStartDate!==undefined && optionStartDate.length > 0){
18248                    etcTotalCount = 0;
18249
18250                    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[]"]');
18251
18252                    var sameOptionsTotal = sameOptions.find('.total-quantity').val();
18253                    sameOptions.each(function(){
18254                        etcTotalCount += Number($(this).val());
18255                    });
18256
18257                    if(etcTotalCount > totalQuantity) {
18258                        var $this = $(this).val();
18259                        $(this).blur();
18260                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18261                        $(this).val($this-(etcTotalCount-totalQuantity));
18262                        return false;
18263                    }
18264                    
18265                }
18266                else {
18267                    if(cnt > totalQuantity) {
18268                        $(this).blur();
18269                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18270                        $(this).val(totalQuantity - sameCount);
18271                        return false;
18272                    }
18273                }
18274
18275                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18276            });
18277
18278            quickbasketModal.find('.option-select-box .box-delete').off('click').on('click', function(e) {
18279                var optionCountBox = $(this).closest('.option-count-box'),
18280                    optionName = optionCountBox.find('input[name="option_name[]"]').val();
18281
18282                if(optionName == 'noneOption') {
18283                    if(quickbasketModal.find('.cl-s-option-text').length > 0) {
18284                        quickbasketModal.find('.cl-s-option-text > input').prop('readonly', false);
18285                        optionCountBox.find('input[name="option_text[]"]').val('');
18286                    }
18287                }
18288                optionCountBox.remove();
18289                if(quickbasketModal.find('.option-count-box:not(.additional)').length > 0) quickbasketModal.find('.modal-footer .ok-button-dialog').addClass('active');
18290                else quickbasketModal.find('.modal-footer .ok-button-dialog').removeClass('active');
18291                
18292                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18293            });
18294        },
18295        pdTextOptionPick: function (pickBtn, productPrice, type, options_type) {
18296            // console.log('pdTextOptionPick() ----------------------------------------------');
18297
18298            var type = (typeof type == 'undefined') ? '' : type,
18299                pickOption = document.querySelector('#selected-product-option'),
18300                option = (pickOption !== null) ? pickOption.getAttribute('data-val') : '',
18301                optionAry = (pickOption !== null) ? option.split('||') : [],
18302                optionStatus = (pickOption !== null) ? pickOption.getAttribute('data-status') : $(pickBtn).closest('.cl-s-option-text').attr('data-status'),
18303                optionType = (pickOption !== null) ? pickOption.getAttribute('data-option_type') : type;
18304
18305            if(optionType == null) optionType = '';
18306                // _idx = obj.getAttribute('data-idx'),
18307            var stock = optionAry[2],
18308                cnt = 0,
18309                total = 0,
18310                totalCnt = 1,
18311                // dateCheckCnt = 1,
18312                // submit = false,
18313                // reSelected = false,
18314                quickbasketModal = $(pickBtn).closest('.cl-quickbasket-modal'),
18315                parent = $(pickBtn).closest('.cl-s-text-option-selector'),
18316                textParent = parent.find('.text-option-box'),
18317                textOptionT = quickbasketModal.find('.cl-s-option-text input[data-option_type="T"], .cl-s-option-text input[data-option_type="TR"]'),
18318                textOptionTarr = [];
18319                // selectedBoxTitle = parent.find('.selected-option-title').text(),
18320                // selectedPrice = $(obj).attr('data-option-price'),
18321                // onlySelectedText = $(obj).find('.option-name').text();
18322
18323            // if(selectedOption !== null && typeof obj.getAttribute('data-option_type') != 'undefined') optionType = obj.getAttribute('data-option_type');
18324            quickbasketModal.find('input[name="option_seq[]"][value="' + optionAry[3] + '"]').each(function() {
18325                if(textParent.find('input[name="product_state"]').val() == 'download') cnt += 1;
18326                else cnt += Number($(this).parent().find('input[name="option_count[]"]').val());
18327            });
18328
18329            if(cnt + 1 > stock) {
18330                $(this).blur();
18331                $.quickbasket.alertModal('ERROR','재고 수량('+stock+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18332                return false;
18333            }
18334
18335            // 추가된 기본 옵션
18336            $.each(quickbasketModal.find('.selected-option.ex'), function(i,v) {
18337                var ex_option_arry = $(this).attr('data-val').split('||');
18338                if(ex_option_arry[0] !== undefined) {
18339                    if(optionAry[0] !== undefined) optionAry[0]+=' / ' + ex_option_arry[0];
18340                }
18341                if(ex_option_arry[1] !== undefined) {
18342                    if(optionAry[1] !== undefined) optionAry[1] = Number(optionAry[1]) + Number(ex_option_arry[1]);
18343                }
18344                if(ex_option_arry[3] !== undefined) {
18345                    if($.quickbasket.data.options_type == '1') {
18346                        if(optionAry[3] !== undefined) optionAry[3]+=',' + ex_option_arry[3];
18347                    } else optionAry[3] = ex_option_arry[3];
18348                }
18349            });
18350
18351            if(options_type == 2 || options_type == 3) {
18352                var md5 = clmd5.hex_md5(optionAry[0]);
18353                if($.quickbasket.data.list.normal_md5.hasOwnProperty(md5)) {
18354                    var selected = $.quickbasket.data.list.normal_md5[md5];
18355                    optionAry[1] = selected['option_price'];
18356                    optionAry[2] = (optionAry[2] == '99999') ? '99999' : selected['option_quantity'];
18357                    optionAry[3] = selected['option_seq'];
18358                } else {
18359                    alert('옵션 선택에 오류입니다.\n 관리자에게 문의하세요');
18360                }
18361            }
18362
18363            var flag;
18364            textOptionT.each(function(){
18365                if(checkEmojis($(this).val())) {
18366                    alert('이모지를 사용할 수 없습니다.');
18367                    flag = false;
18368                    return false;
18369                }
18370            });
18371
18372            if(flag == false) {
18373                return false;
18374            }
18375
18376            textOptionT.each(function(){
18377                if($(this).val() != "") {
18378                    var objKey = $(this).attr('data-val');
18379                    var textTempObj = {};
18380                    textTempObj[$(this).attr('data-val')] = $(this).val().trim();
18381                    textOptionTarr.push(textTempObj);
18382                }
18383            });
18384
18385            var textOption = '';
18386            if(textOptionT.length == textOptionTarr.length) {
18387                textOption = strReplace(JSON.stringify(textOptionTarr), '"', '&quot;'); //JSON
18388            } else {
18389                alert('필수 입력옵션을 모두 입력해주세요.');
18390                return false;
18391            }
18392
18393            // 일반옵션 없을때 처리
18394            if(optionAry[0] == ' / noneOption') {
18395                optionAry[0] = optionAry[0].replace(' / noneOption','');
18396            }
18397
18398            var html = $.quickbasket.pdOptionBoxHtml(productPrice, type, optionStatus, optionType, optionAry, textOption, textOptionTarr);
18399            quickbasketModal.find('.option-select-box').append(html);
18400            
18401            if(quickbasketModal.find('.option-count-box:not(.additional)').length > 0) quickbasketModal.find('.modal-footer .ok-button-dialog').addClass('active');
18402            else quickbasketModal.find('.modal-footer .ok-button-dialog').removeClass('active');
18403            $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18404
18405            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);
18406            else textParent.find('input').val('');
18407
18408            quickbasketModal.find('#selected-product-option .selected-option-text').text('선택');
18409            quickbasketModal.find('#selected-product-option').attr('data-selected_option', '');
18410            quickbasketModal.find('#selected-product-option').attr('data-val', '');
18411            quickbasketModal.find('#selected-product-option').attr('data-status', '');
18412            $(pickBtn).addClass('disabled');
18413
18414            // 추가된 기본 옵션 처리
18415            quickbasketModal.find('.selected-option.ex').attr('data-selected_option', '');
18416            quickbasketModal.find('.selected-option.ex').attr('data-val', '');
18417            quickbasketModal.find('.selected-option.ex').attr('data-status', '');
18418            quickbasketModal.find('.selected-option.ex').parents('.cl-s-option-selector').addClass('option-disabled');
18419
18420            quickbasketModal.find('#etc-start-date-option, #etc-end-date-option, #etc-time, #etc-start-date-txt, #etc-end-date-txt').val('');
18421            quickbasketModal.find('.selected-option > span').each(function(idx, v){
18422                if($(v).attr('data-default') !== undefined) {
18423                    $(v).text($(v).attr('data-default'));
18424                }
18425            });
18426
18427            // $.quickbasket.pdOptionPick(this, \'' + data.option_data.product_price + '\')
18428
18429
18430            quickbasketModal.find('.option-select-box .box-option-count .plus').off('click').on('click', function(e) {
18431                if($('.cl-modal-check-quantity').length > 0) {
18432                    e.preventDefault(); 
18433                    return false; 
18434                }
18435
18436                var totalQuantity = $(this).closest('.option-count-box').find('.total-quantity').val();
18437                var count = $(this).parent().children('input').val();
18438                var state = quickbasketModal.find('#product_state').val();
18439                var optionSeq = $(this).closest('.option-count-box').find('input[name="option_seq[]"]').val();
18440                var optionName = $(this).closest('.option-count-box').find('input[name="option_name[]"]').val();
18441                var optionStartDate = $(this).closest('.option-count-box').find('input[name="etc_start_date[]"]').val();
18442                var etcTotalCount = 0;
18443
18444                var target = this;
18445                var sameCount = 0;
18446                quickbasketModal.find('input[name="option_seq[]"][value="' + optionSeq + '"]').each(function() {
18447                    if($(this).closest('.option-count-box').has(target).length === 0) {
18448                        sameCount += Number($(this).parent().find('input[name="option_count[]"]').val());
18449                    }
18450                });
18451
18452
18453                if (count > 1000) {
18454                    // alert('최대 구매 수량은 1000개 입니다.');
18455                    $(this).blur();
18456                    $.quickbasket.alertModal('ERROR','최대 구매 수량은 1000개 입니다.','cl-modal-check-quantity');
18457                    return false;
18458                }
18459                
18460                count = (count * 1) + 1;
18461
18462                if(optionStartDate!==undefined && optionStartDate.length > 0){
18463                    etcTotalCount = 0;
18464
18465                    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[]"]');
18466
18467                    var sameOptionsTotal = sameOptions.find('.total-quantity').val();
18468                    sameOptions.each(function(){
18469                        etcTotalCount += Number($(this).val());
18470                    });
18471
18472                    if(etcTotalCount >= totalQuantity) {
18473                        // alert('재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.');
18474                        $(this).blur();
18475                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18476                        return false;
18477                    }
18478                }
18479                else {
18480                    if(count + sameCount > totalQuantity) {
18481                        // alert('재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.');
18482                        $(this).blur();
18483                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18484                        count = totalQuantity - sameCount;
18485                    }
18486                }
18487
18488
18489                $(this).parent().children('input').val(count);
18490                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18491            });
18492            quickbasketModal.find('.option-select-box .box-option-count .min').off('click').on('click', function(e) {
18493                if($('.cl-modal-check-quantity').length > 0) {
18494                    e.preventDefault(); 
18495                    return false; 
18496                }
18497
18498                var count = $(this).parent().children('input').val();
18499                count = (count * 1) - 1;
18500
18501                if (count < 1) {
18502                    $(this).blur();
18503                    $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
18504                    return false;
18505                }
18506
18507                $(this).parent().children('input').val(count);
18508                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18509            });
18510            quickbasketModal.find('.option-normal-price').off('keyup.quickbasketQty blur.quickbasketQty').on('keyup.quickbasketQty blur.quickbasketQty', function(e) {
18511                if (e.keyCode == 13 || $('.cl-modal-check-quantity').length > 0) { 
18512                    e.preventDefault(); 
18513                    return false; 
18514                }
18515
18516                var totalQuantity = $(this).closest('.option-count-box').find('.total-quantity').val(),
18517                    cnt = $(this).val();
18518                var state = quickbasketModal.find('#product_state').val();
18519                var optionSeq = $(this).closest('.option-count-box').find('input[name="option_seq[]"]').val();
18520                var optionName = $(this).closest('.option-count-box').find('input[name="option_name[]"]').val();
18521                var optionStartDate = $(this).closest('.option-count-box').find('input[name="etc_start_date[]"]').val();
18522                var etcTotalCount = 0;
18523
18524                cnt = (cnt) ? Number(cnt.replace(/[^0-9\.]/g,'')) : '';
18525                if (!cnt) {
18526                    // if(e.type == 'blur') {
18527                    //     $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
18528                    //     return false;
18529                    // } else {
18530                    //     return false;
18531                    // }
18532                    e.preventDefault(); 
18533                    return false;
18534                }
18535                $(this).val(cnt);
18536                
18537                if(cnt < 1) {
18538                    $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
18539                    $(this).val(1);
18540                    return false;
18541                }
18542                if(totalQuantity==99999 && cnt > 1000) {
18543                    $.quickbasket.alertModal('ERROR','최대 구매 수량은 1000개 입니다.','cl-modal-check-quantity');
18544                    cnt = 1000;
18545                    $(this).val(cnt);
18546                    return false;
18547                }
18548
18549                var target = this;
18550                var sameCount = 0;
18551                quickbasketModal.find('input[name="option_seq[]"][value="' + optionSeq + '"]').each(function() {
18552                    if($(this).closest('.option-count-box').has(target).length === 0) {
18553                        sameCount += Number($(this).parent().find('input[name="option_count[]"]').val());
18554                    }
18555                });
18556
18557                cnt += sameCount;
18558
18559                if(optionStartDate!==undefined && optionStartDate.length > 0){
18560                    etcTotalCount = 0;
18561
18562                    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[]"]');
18563
18564                    var sameOptionsTotal = sameOptions.find('.total-quantity').val();
18565                    sameOptions.each(function(){
18566                        etcTotalCount += Number($(this).val());
18567                    });
18568
18569                    if(etcTotalCount > totalQuantity) {
18570                        var $this = $(this).val();
18571                        $(this).blur();
18572                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18573                        $(this).val($this-(etcTotalCount-totalQuantity));
18574                        return false;
18575                    }
18576                    
18577                }
18578                else {
18579                    if(cnt > totalQuantity) {
18580                        $(this).blur();
18581                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18582                        $(this).val(totalQuantity - sameCount);
18583                        return false;
18584                    }
18585                }
18586
18587                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18588            });
18589            quickbasketModal.find('.option-select-box .box-delete').off('click').on('click', function(e) {
18590                var optionCountBox = $(this).closest('.option-count-box');
18591                var optionName = optionCountBox.find('input[name="option_name[]"]').val();
18592                if(optionName == 'noneOption') {
18593                    if(quickbasketModal.find('.cl-s-option-text').length > 0) {
18594                        quickbasketModal.find('.cl-s-option-text > input').prop('readonly', false);
18595                        optionCountBox.find('input[name="option_text[]"]').val('');
18596                    }
18597                }
18598                $(this).closest('.option-count-box').remove();
18599                if(quickbasketModal.find('.option-count-box:not(.additional)').length > 0) quickbasketModal.find('.modal-footer .ok-button-dialog').addClass('active');
18600                else quickbasketModal.find('.modal-footer .ok-button-dialog').removeClass('active');
18601                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18602            });
18603        },
18604        pdTotalPriceUpdate: function (modal) {
18605            var $modal = (modal && $(modal).length) ? $(modal).closest('.cl-quickbasket-modal') : $('.cl-quickbasket-modal:visible').last();
18606            if(!$modal.length) {
18607                $modal = $('.cl-quickbasket-modal').last();
18608            }
18609            var total_price = 0,
18610                total_cnt = 0,
18611                total_grade_discount = 0,
18612                normal_rows = [],
18613                additional_rows = [],
18614                umgrade = (typeof property != 'undefined' && property.UMGRADE) ? property.UMGRADE : null,
18615                discount_use = umgrade ? String(umgrade.discount_use || '0') : '0',
18616                discount_amount = umgrade ? Number(umgrade.discount_amount || 0) : 0,
18617                discount_type = umgrade ? String(umgrade.discount_type || '0') : '0',
18618                discount_value = umgrade ? Number(umgrade.discount_value || 0) : 0,
18619                discount_max = umgrade ? Number(umgrade.discount_max || 0) : 0,
18620                grade_onoff = ($.quickbasket.data && $.quickbasket.data.grade_onoff) ? $.quickbasket.data.grade_onoff : '';
18621            $modal.find('.option-select-box').find('.option-count-box:not(.additional)').each(function() {
18622                var unti_price = $(this).find('input[name="option_price[]"]').val(),
18623                    cnt = $(this).find('.option-normal-price').val(),
18624                    price = (Number(unti_price) * Number(cnt)),
18625                    display_price = price,
18626                    option_type = $(this).find('input[name="option_type[]"]').val(),
18627                    discount_amt = 0;
18628
18629                normal_rows.push({
18630                    $el: $(this),
18631                    price: price,
18632                    option_type: option_type
18633                });
18634
18635                total_price += price;
18636                total_cnt += Number(cnt);
18637                if (discount_amt > 0) {
18638                    $(this).find('.box-option-price').html(
18639                        '<div class="option-price-original-row" style="font-size:12px; color:#999; text-decoration:line-through; line-height:1.2; margin-bottom:4px;">' +
18640                            '<span class="option-price-original">' + number_format(price) + '</span>원' +
18641                        '</div>' +
18642                        '<div class="option-price-current-row" style="line-height:1.2;">' +
18643                            '<span class="option-price">' + number_format(display_price) + '</span>원' +
18644                        '</div>'
18645                    );
18646                } else {
18647                    $(this).find('.box-option-price').html(
18648                        '<div class="option-price-current-row" style="line-height:1.2;">' +
18649                            '<span class="option-price">' + number_format(display_price) + '</span>원' +
18650                        '</div>'
18651                    );
18652                }
18653            });
18654
18655            
18656            $modal.find('.option-select-box').find('.option-count-box.additional').each(function() {
18657                var unti_price = $(this).find('input[name="option_price[]"]').val(),
18658                    cnt = $(this).find('.option-normal-price').val(),
18659                    price = (Number(unti_price) * Number(cnt));
18660
18661                additional_rows.push({
18662                    $el: $(this),
18663                    price: price
18664                });
18665
18666                total_price += price;
18667                total_cnt += Number(cnt);
18668
18669                $(this).find('.box-option-price').html(
18670                    '<div class="option-price-current-row" style="line-height:1.2;">' +
18671                        '<span class="option-price">' + number_format(price) + '</span>원' +
18672                    '</div>'
18673                );
18674            });
18675
18676            if (
18677                discount_use === '1' &&
18678                grade_onoff === 'ON' &&
18679                discount_value > 0
18680            ) {
18681                var additional_total_price = 0;
18682                $.each(additional_rows, function(_, row) {
18683                    additional_total_price += row.price;
18684                });
18685                $.each(normal_rows, function(index, row) {
18686                    var grade_discount_base_price = row.price + (index === 0 ? additional_total_price : 0),
18687                        row_discount = 0;
18688
18689                    if(grade_discount_base_price < discount_amount) return;
18690
18691                    if (discount_type === '0') {
18692                        row_discount = Math.floor(grade_discount_base_price * (discount_value / 100.0));
18693                        if (discount_max > 0 && row_discount > discount_max) {
18694                            row_discount = discount_max;
18695                        }
18696                    } else {
18697                        row_discount = discount_value;
18698                    }
18699                    if (row_discount > grade_discount_base_price) row_discount = grade_discount_base_price;
18700                    if (row_discount < 0) row_discount = 0;
18701                    total_grade_discount += row_discount;
18702                });
18703            }
18704            total_price -= total_grade_discount;
18705
18706            var $totalBox = $modal.find('.total-price-box').first();
18707            $totalBox.find('.panel-grade-price-row').remove();
18708            if (total_grade_discount > 0) {
18709                $totalBox.prepend(
18710                    '<div class="panel-grade-price-row" style="display:flex; justify-content:space-between; align-items:center; width:100%; margin-bottom:8px;">' +
18711                        '<span class="panel-total-title">등급할인 금액</span>' +
18712                        '<span class="panel-grade-price" style="font-size:16px; font-weight:bold; color:#ee445f;">-<span class="grade-price-total">0</span>원</span>' +
18713                    '</div>'
18714                );
18715                $totalBox.find('.grade-price-total').text(number_format(total_grade_discount));
18716            }
18717            $totalBox.find('.total-price').text(number_format(total_price));
18718            $totalBox.find('.total-cnt').text(total_cnt);
18719        },
18720        setKeepShopping : function(sid,page,pid,pnum) {
18721            if(typeof sid == 'undefined') sid = RENDER.b.SID;
18722            if(typeof page == 'undefined') page = (RENDER.b.VIEW) ? RENDER.b.PARENT.ppage : RENDER.b.PAGE;
18723            if(typeof pid == 'undefined') pid = (RENDER.b.VIEW) ? RENDER.b.PARENT.pid : '';
18724            if(typeof pnum == 'undefined') pnum = (RENDER.b.VIEW) ? RENDER.b.PARENT.seq : '';
18725
18726            var cookie_g = $.cookie('gallery'),
18727                cookie_keepsh = [];
18728            if(typeof cookie_g != 'undefined' && cookie_g) {
18729                cookie_keepsh = [page,cookie_g,$.cookie('loadmore-'+cookie_g),$.cookie('gallery-category-'+cookie_g),$.cookie('gallery-orderby-'+cookie_g),$.cookie('gallery-item')];
18730            } else {
18731                if(pid && pnum) cookie_keepsh = [page,pid,'1','','recent',pnum];
18732            }
18733
18734            if(cookie_keepsh.length > 0) $.cookie('keep-shopping-'+sid, cookie_keepsh.toString(), { path : '/', expires: new Date(Date.now() + 1000*60*60*3) });
18735        },
18736    }
18737
18738    $.products = {
18739        init : function() {
18740            $.category.init();
18741            var isMainImageClick = false, idx = -1, replace = false;
18742            $(document)
18743            .off('click', '.cl-p-modal')
18744            .on('click', '.cl-p-modal', function(e) {
18745                if($('#prod-category-lists').css('display') == 'block') {
18746                    $('.category-lists').slideUp(200, function() {
18747                        $('.category-wrap').removeClass('open');    
18748                    });
18749                }
18750                $('.option-price-status-select').slideUp(200, function() {
18751                    $('.option-price-status-str').removeClass('open');    
18752                });
18753                if($('.gallery-menus-wrap').css('display') == 'block') {
18754                    $('.choose-gallery').removeClass('open');
18755                    $('.gallery-menus-wrap').hide();
18756                }
18757            });
18758
18759            $(document)
18760            .off('click','.form-label.textarea')
18761            .on('click','.form-label.textarea', function() { $('#prod-desc').focus(); });
18762            $(document)
18763            .off('click','.prod-modal .modal-close')
18764            .on('click','.prod-modal .modal-close', function() { $.products.close(); });
18765
18766            $(document)
18767            .off('keydown, keyup', '#prod-desc')
18768            .on('keydown, keyup', '#prod-desc', function(){
18769                $('#prod-desc')[0].style.height = 'auto';
18770                var descHeight = $('#prod-desc').prop('scrollHeight');
18771                if(descHeight > 55) {
18772                    $('#prod-desc').css('height', descHeight+'px');
18773                }
18774
18775                //size check
18776                var value = $(this).val();        
18777                if(value.length > 255){
18778                    $(this).val(value.substr(0,255).trim());
18779                }
18780            });
18781
18782            $(document)
18783            .off('change','.switch-product')
18784            .on('change','.switch-product', function() {
18785                $('.switch-product + label').removeClass('active');
18786                if($(this).val() == 'off') {
18787                    $('#status-append').fadeOut(0);
18788                    $('#sale-calendar').hide();
18789                } else {
18790                    var check = $('input[name="product_state"]:checked').val();
18791                    var a = 0;
18792
18793                    if ($('#none-option-file').length > 0) {
18794                        var fileBoxCnt = $('.file-box-list').length;
18795                        $('.file-box-list').each(function (idx, v) {
18796                            var downloadCnt = $(v).find('.file-name').length;
18797                            if (fileBoxCnt > 1) {
18798                                if (a == 0) a++;
18799                                else {
18800                                    if (check == 'D' && downloadCnt == 0) {
18801                                        alert('다운로드 상품일 경우 파일이 1개 이상 등록되어 있어야 합니다.');
18802                                        $('.switch-product[value="off"]').prop('checked', true);
18803                                        $('#status-append').fadeOut(0);
18804                                        $('#sale-calendar').hide();
18805                                        a++;
18806                                        return false;
18807                                    }
18808                                }
18809                            } else {
18810                                if (check == 'D' && downloadCnt == 0) {
18811                                    alert('다운로드 상품일 경우 파일이 1개 이상 등록되어 있어야 합니다.');
18812                                    $('.switch-product[value="off"]').prop('checked', true);
18813                                    $('#status-append').fadeOut(0);
18814                                    $('#sale-calendar').hide();
18815                                    a += 2;
18816                                    return false;
18817                                }
18818                            }
18819                        });
18820                        if (a <= 1) {
18821                            $(this).prop('checked', true);
18822                        }
18823                    } else {
18824                        $(this).prop('checked', true);
18825                    }
18826
18827                    if(a <= 1) {
18828                        if($(this).val() == 'lim') {
18829                            $('#status-append').fadeIn(0);
18830                            $('#sale-calendar').show();
18831                        } else {
18832                            $('#status-append').fadeOut(0);
18833                            $('#sale-calendar').hide();
18834                        }
18835                    }
18836                }
18837            });
18838            $(document)
18839            .off('change','.switch-quantity')
18840            .on('change','.switch-quantity', function() { //재고관리 on
18841                switchQuantity();
18842            });
18843            $(document)
18844            .off('input.productQuantityLimit', '#prod-quantity')
18845            .on('input.productQuantityLimit', '#prod-quantity', function() {
18846                var quantity = Number(removeCommas($(this).val()));
18847                if(quantity > 9999) {
18848                    alert('최대 입력 수량은 9,999 입니다.');
18849                    $(this).val(addCommas('9999'));
18850                }
18851            })
18852            .off('keydown.productQuantityLimit', '#prod-quantity')
18853            .on('keydown.productQuantityLimit', '#prod-quantity', function(e) {
18854                var is_number_key = (e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 96 && e.keyCode <= 105);
18855                var value = String(removeCommas($(this).val()));
18856                var has_selection = this.selectionStart !== this.selectionEnd;
18857
18858                if(is_number_key && !e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey && value.length >= 4 && !has_selection) {
18859                    e.preventDefault();
18860                    alert('최대 입력 수량은 9,999 입니다.');
18861                    $(this).val(addCommas('9999'));
18862                }
18863            })
18864            .off('paste.productQuantityLimit', '#prod-quantity')
18865            .on('paste.productQuantityLimit', '#prod-quantity', function(e) {
18866                var clipboard = e.originalEvent && e.originalEvent.clipboardData;
18867                var value = clipboard ? clipboard.getData('text').replace(/[^0-9]/g, '') 
18867: '';
18868                var current_value = String(removeCommas($(this).val()));
18869                var selected_value = $(this).val().substring(this.selectionStart, this.selectionEnd).replace(/[^0-9]/g, '');
18870                var result_length = current_value.length - selected_value.length + value.length;
18871
18872                if(value !== '' && result_length > 4) {
18873                    e.preventDefault();
18874                    alert('최대 입력 수량은 9,999 입니다.');
18875                    $(this).val(addCommas('9999'));
18876                }
18877            });
18878            $(document)
18879            .off('click','.switch-category')
18880            .on('click','.switch-category', function() {
18881                if($(this).is(':checked')) {
18882                    $(this).parents('.form-wrap').removeClass('disabled');
18883                    $(this).parents('.form-wrap').find('.category-text').removeClass('hide');
18884                } else {
18885                    $(this).parents('.form-wrap').addClass('disabled');
18886                    $(this).parents('.form-wrap').find('.category-text').addClass('hide');
18887                    $('.category-lists').slideUp(200, function() {
18888                        $('.category-wrap').removeClass('open');    
18889                    });                    
18890                }
18891            });
18892            $(document)
18893            .off('change','.switch-text-option')
18894            .on('change','.switch-text-option', function() {
18895                if($(this).is(':checked')) {
18896                    $(this).parents('.form-wrap').removeClass('disabled');
18897                    $(this).parents('.form-wrap').find('#text-option-name').removeClass('hide');
18898                } else {
18899                    $(this).parents('.form-wrap').addClass('disabled');
18900                    $(this).parents('.form-wrap').find('#text-option-name').addClass('hide');
18901                }
18902            });
18903
18904            $(document)
18905            .off('click','.switch-prod-info')
18906            .on('click','.switch-prod-info', function() {
18907                if($(this).is(':checked')) {
18908                    $(this).parents('.form-wrap').removeClass('disabled');
18909                    $(this).parents('.form-wrap').find('.info-selected').removeClass('hide');
18910                } else {
18911                    $(this).parents('.form-wrap').addClass('disabled');
18912                    $(this).parents('.form-wrap').find('.info-selected').addClass('hide');
18913
18914                }
18915            });
18916
18917            $(document)
18918            .off('click','.switch-mngprd')
18919            .on('click','.switch-mngprd', function() {
18920                if($(this).is(':checked')) {
18921                    $('#mng-prd-info').removeClass('disabled');
18922                    $(this).parents('.mng-prd-wrap').find('.mng-prd-info-toggle').removeClass('hide');
18923                } else {
18924                    $('#mng-prd-info').addClass('disabled');
18925                    $(this).parents('.mng-prd-wrap').find('.mng-prd-info-toggle').addClass('hide');
18926                }
18927            });
18928
18929            $(document)
18930            .off('click', '.prod-discount-unit-select:not(.disabled)')
18931            .on('click', '.prod-discount-unit-select:not(.disabled)', function(e) {
18932                $(this).find('.discount-unit-select').toggle();
18933            });
18934
18935            $(document)
18936            .off('click', '.discount-unit-select > div')
18937            .on('click','.discount-unit-select > div', function(e) {
18938                var val = $(this).attr('data-value');
18939                var unitStr = $(this).text();
18940
18941                $('#prod-discount-unit').attr('data-value', val).text(unitStr);
18942
18943                if(val == 'P') {
18944                    var discountRate = Number($('#prod-discount-rate').val().replace(/,/g, ''));
18945                    if(discountRate > 100) discountRate = 100;
18946                    $('#prod-discount-rate').val(discountRate);
18947                    // $('#price-cut-btn').removeClass('hide');
18948                } else {
18949                    var discountRate = removeCommas($('#prod-discount-rate').val());
18950                    $('#prod-discount-rate').val(number_format(discountRate));
18951                    // $('#price-cut-btn').addClass('hide');
18952                }
18953
18954                calDiscount($('#prod-discount-rate'));
18955            });
18956
18957            $(document)
18958            .off('click','.switch-pccc, .switch-require-navershop')
18959            .on('click','.switch-pccc, .switch-require-navershop', function(e) {
18960                if($(this).closest('.input-switch').hasClass('editor-upgrade-popup')) {
18961                    e.preventDefault();
18962                    return false;
18963                }
18964
18965                // 네이버쇼핑 off 시 안내팝업
18966                if($(this).hasClass('switch-require-navershop') && $(this).closest('.form-wrap').hasClass('use-nshop-setting')) {
18967                    var modal_description = 'DBURL 기능을 사용하고 있지 않습니다.<br>DBURL 기능을 사용으로 설정 후 이용할 수 있습니다.';
18968                    var link = (uadmin == 'um' ? '/_admin' : '') + '/shopping/setting/T';
18969                    var btnstr = '<div class="btn-box">\
18970                        <a href="' + link + '" target="_blank" style="line-height:2;">DBURL 설정하러 가기</a>\
18971                        <button type="button" class="btn btn-default btn-sm close-button-dialog" data-dismiss="modal">' + $.lang[LANG]['config.close'] + '</button>\
18972                    </div>\
18973                    ';
18974                    
18975                    var str = '\
18976                        <div class="site-upgrade-notice">\
18977                            <p><span class="text-centermodal">' + modal_description + '</span></p>\
18978                            ' + btnstr +
18979                        '</div>\
18980                    ';
18981                    $(this).showModalFlat('안내', str, false, false, '', '', '', 'cl-cmmodal cl-s-btn w560 cl-p0');
18982                    e.preventDefault();
18983                    return false;
18984                }
18985
18986                if($(this).is(':checked')) {
18987                    $(this).parents('.form-wrap').removeClass('disabled');
18988                } else {
18989                    $(this).parents('.form-wrap').addClass('disabled');
18990                }
18991            });
18992            
18993            $(document)
18994            .off('click','.check-sale > .checkbox > label')
18995            .on('click','.check-sale > .checkbox > label', function() {
18996                if($(this).prev('input').is(':disabled')) {
18997                    alert('0원인 상품은 할인을 할 수 없습니다.');
18998                    return false;
18999                }
19000            });
19001
19002            $(document)
19003            .off('click','.grade-sale > .checkbox > label')
19004            .on('click','.grade-sale > .checkbox > label', function() {
19005                if($(this).prev('input').is(':disabled')) {
19006                    alert('0원인 상품은 등급가를 사용 할 수 없습니다.');
19007                    return false;
19008                }
19009            });
19010
19011            $(document)
19012            .off('click','#prod-sale-check')
19013            .on('click','#prod-sale-check', function() {
19014                if($(this).parents('.check-sale').hasClass('disabled')) {
19015                    alert('가격이 연동이 활성화 되어있습니다.\n가격연동을 먼저 해제하세요');
19016                    return false;
19017                }
19018                
19019                $('.form-group.discount-append + .error-msg').remove();
19020                if($(this).is(':checked')) {
19021                    var prod_price = ($('#prod-price').val()) ? $('#prod-price').val() : 0;
19022                    $('#prod-sale').addClass('strike');
19023                    $('#prod-sale').text(prod_price);
19024                    $('#prod-sale').show();
19025                    $('.discount-append').removeClass('hide');
19026                    // $('#prod-price').val('').attr('placeholder','할인 가격을 입력하세요').focus();
19027                    $('#prod-price').prop('readonly', true);
19028                    $('#prod-price').addClass('sale-on');
19029                    $('#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"/>');
19030                    $('.check-sale').removeClass('unchecked').addClass('checked');
19031                    calDiscount($('#prod-discount-rate'));
19032                } else {
19033                    var prod_price = ($('#prod-sale').text()) ? $('#prod-sale').text() : '';
19034                    $('#prod-price').val(prod_price);
19035                    $('#prod-price').prop('readonly', false);
19036                    $('#prod-price').removeClass('sale-on').focus();
19037                    // $('#prod-price').removeClass('sale-on').attr('placeholder','가격을 입력하세요').focus();
19038                    $('#prod-sale').removeClass('strike');
19039                    $('#prod-sale').hide();
19040                    $('.discount-append').addClass('hide');
19041                    $('#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"/>');
19042                    $('.check-sale').removeClass('checked').addClass('unchecked');
19043                    calInputWidth($('#prod-price'));
19044                }
19045            });
19046
19047            $(document)
19048            .off('click','#grade-sale-check')
19049            .on('click','#grade-sale-check', function() {
19050                $('.form-group.discount-append + .error-msg').remove();
19051                if($(this).is(':checked')) {
19052                    $('#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"/>');
19053                    $('.grade-sale').removeClass('unchecked').addClass('checked');
19054                    $('#shopping-grade').val('ON');
19055                    // calDiscount($('#prod-discount-rate'));
19056                } else {
19057                    $('#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"/>');
19058                    $('.grade-sale').removeClass('checked').addClass('unchecked');
19059                    $('#shopping-grade').val('OFF');
19060                    // calInputWidth($('#prod-price'));
19061                }
19062            });
19063
19064            $(document)
19065            .off('click','#price-cut-btn')
19066            .on('click','#price-cut-btn', function() {
19067                if($(this).hasClass('disabled')) {
19068                    $(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() {
19069                        $(document).on('keydown', function(e) {
19070                            if(e.keyCode == 27) modal.modal('hide');
19071                        });
19072                    });
19073                    return false;
19074                }
19075                if($('#prod-discount-unit').attr('data-value') == 'P') {
19076                    var orgPrice = Number(removeCommas($('#prod-sale').text()));
19077                    var discountRate = Number($('#prod-discount-rate').val());
19078                    var discountPrice = orgPrice * (discountRate / 100);
19079                    var price = ($('#prod-price').val()) ? Number(removeCommas($('#prod-price').val())) : 0;
19080
19081                    price = Math.floor(price / 10) * 10;
19082                    discountRate = Math.round(((orgPrice - price) / orgPrice) * 100);
19083
19084                    $('#prod-price').val(number_format(price));
19085                    $('#prod-discount-rate').val(discountRate);
19086
19087                    $(this).addClass('disabled');
19088                }
19089            });
19090
19091            $(document)
19092            .off('input', '#prod-price')
19093            .on('input', '#prod-price', function () {
19094                var price = $(this).val().replace(/[\u3131-\u318E\uAC00-\uD7A3]/g, '');
19095                price = removeCommas(price);
19096                price = price * 1;
19097                var nPrice = Number(price);
19098
19099                if(!nPrice || nPrice == 0) {
19100                    $('#prod-sale-check').prop('disabled', true);
19101                    $('#prod-grade-check').prop('disabled', true);
19102                } else {
19103                    $('#prod-sale-check').prop('disabled', false);
19104                    $('#grade-sale-check').prop('disabled', false);
19105                }
19106
19107                if(nPrice > 1000000000) {
19108                    $(this).val('1,000,000,000');
19109                }
19110
19111                calInputWidth($(this));
19112            });
19113
19114            $(document)
19115            .off('focusout', '#prod-price')
19116            .on('focusout', '#prod-price', function () {
19117                if($(this).prop('readonly') == true) return false;
19118                
19119                var price = $(this).val().replace(/[\u3131-\u318E\uAC00-\uD7A3]/g, '');
19120                price = removeCommas(price);
19121                price = price * 1;
19122
19123                var nPrice = Number(price),
19124                    submit = true;
19125
19126                if(nPrice > 1000000000) price = 1000000000;
19127
19128                // 옵션 가격 검색
19129                $.each($('.prod-option-price'), function(i,v) {
19130                    var oPrice = $(this).attr('data-option-price');
19131                    if(i > 0) {
19132                        if(nPrice + Number(oPrice) < 0) {
19133                            $(this).click();
19134                            $(this).parents('li').addClass('err');
19135                            submit = false;
19136                        }
19137                    }
19138                });
19139
19140                if(submit) {                   
19141                    price = addCommas(price);
19142                    $(this).val(price);
19143                } else {
19144                    alert('판매가가 0원 아래로 적용될 수 있는 옵션 가격이 존재하여 변경할 수 없습니다.');
19145                    $(this).val(price);
19146                }
19147
19148                if(!nPrice || nPrice == 0) {
19149                    $('#prod-sale-check').prop('disabled', true);
19150                    $('#grade-sale-check').prop('disabled', true);
19151                } else {
19152                    $('#prod-sale-check').prop('disabled', false);
19153                    $('#grade-sale-check').prop('disabled', false);
19154                }
19155
19156                calInputWidth($(this));
19157            });
19158
19159            $(document)
19160            .off('input', '#prod-discount-rate')
19161            .on('input', '#prod-discount-rate', function(){
19162                calDiscount($(this));
19163            });
19164
19165            $(document)
19166            .off('focusout', '#prod-discount-rate')
19167            .on('focusout', '#prod-discount-rate', function(){
19168                var discountUnit = $('#prod-discount-unit').attr('data-value');
19169                var discountRate = $(this).val();
19170                $(this).removeClass('empty');
19171                $('.form-group.discount-append + .error-msg').remove();
19172                
19173                if(discountRate) {
19174                    if(discountUnit == 'P') {
19175                        var percentVal = Number((Math.floor(discountRate * 100) / 100).toFixed(2));
19176                        $(this).val(percentVal);
19177                    }
19178                } else {
19179                    $(this).val(0);
19180                }
19181
19182                if($(this).val() == 0) {
19183                    var error_str = '<svg viewBox="0 0 13 13" width="13" height="13">
19183<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>\
19184                    1 이상 입력해 주세요.';
19185                    $('.form-group.discount-append').after('<div class="error-msg c-red">'+error_str+'</div>');
19186                    $(this).addClass('empty');
19187                }
19188            });
19189
19190            $(document)
19191            .off('click','.prod-item-image-add,.prod-item-image')
19192            .on('click','.prod-item-image-add,.prod-item-image',function(e) {
19193                idx = -1;
19194                isMainImageClick = ($(this).hasClass('prod-item-image')) ? true : false;
19195                replace = (isMainImageClick && $('.prod-item-image .preview-img').length) ? true : false;
19196                if($(this).hasClass('.prod-item-image-add')) {
19197                    $('img').removeClass('replace');
19198                }
19199                if($(this).hasClass('.prod-item-image')) $(this).find('.preview-img').addClass('replace');
19200                $.resource.open();
19201            });
19202
19203            $(document)
19204            .off('click','.prod-item-thumb img:not(.guide-img)')
19205            .on('click','.prod-item-thumb img:not(.guide-img)',function(e) {
19206                isMainImageClick = false;
19207                idx = $(this).parent().index();
19208                replace = true;
19209                $(this).addClass('replace');
19210                $(this).attr('data-idx',idx);
19211                $.resource.open();
19212            });
19213
19214            $(document)
19215            .off('hover', '.prod-item-thumb li')
19216            .on('hover', '.prod-item-thumb li',function(e) {
19217                e.stopPropagation();
19218                $('.img-delete').hide();
19219                $(this).find('.img-delete').show();
19220            });
19221
19222            $(document)
19223            .off('click','.img-delete')
19224            .on('click','.img-delete',function(e) {
19225                $(this).parent().remove();
19226                if($('.prod-item-thumb li').length < 11) $('.prod-item-image-add').removeClass('hide');
19227                if($(this).index() == 1) {
19228                    var src = $('.prod-item-thumb li:not(.prod-item-image-add):eq(0)').find('img:not(.guide-img)').attr('src');
19229                    if(typeof src != 'undefined') {
19230                        src = src.replace('/250/','/800/');
19231                        $('.prod-item-image .preview-img').css('background-image', 'url("'+ src +'")');
19232                    } else {
19233                        $('.prod-item-image').removeClass('active').find('.preview-img').remove();
19234                    }
19235                }
19236            });
19237
19238            $(document)
19239            .off('click','.resource-useit')
19240            .on('click','.resource-useit',function(e) {
19241                if($('.prod-modal').length == 0) return;
19242
19243                var isLink = $(this).attr('data-property');
19244                if(typeof flinkChange !== 'function' && isLink == 'flink-change') {
19245                    setFileLink();
19246                    return false;
19247                }
19248
19249                var useitResourceTab = $(this).closest('.tab-pane.active');
19250                var useitResourceSelected = useitResourceTab.find('.resource-selected-ul');
19251                var useitResourceBtn = $(this);
19252                var rmode = useitResourceTab.attr('id').replace(/storage$/gi,'');
19253
19254                if(useitResourceSelected.children('li').length == 0) {
19255                    var z_idx = ($('.flink-fileupload').length) ? 'z-1044' : 'z-1042';
19256                    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() {
19257                        useitResourceBtn.removeClass('clicked');
19258                    });
19259                    error_modal.closest('.flat-modal').addClass(z_idx);
19260                    return;
19261                }
19262
19263                var imgs = $.resource.selected(),
19264                    empty = ($('.prod-item-image').find('.preview-img').length) ? false : true;
19265
19266                var url = (typeof RESOURCE == 'undefined') ? property.RESOURCE : RESOURCE,
19267                    site = (typeof SID == 'undefined') ? property.SID : SID,
19268                    folder = '', f = '';
19269
19270                var thumbs = $('.prod-item-thumb li:not(.prod-item-image-add)').length,
19271                    remain = 10-thumbs;
19272
19273                replace = ($('.replace').length) ? true : false;
19274                if(imgs.length > remain && !replace) imgs.length = remain;
19275                if(replace) imgs.length = 1;
19276                if(replace && imgs.length > 1) {
19277                    $(this).showModalFlat('INFORMATION', $.lang[LANG]['editor.resource.choose.count.1'], true, false, '', 'ok');
19278                    useitResourceBtn.removeClass('clicked');
19279                    return false;
19280                }
19281                if(rmode == 'free' && useitResourceSelected.children('li').length > 0) {
19282                    $.processON('Image upload to storage...');
19283                    var frUpload = frStorageUpload(imgs.join('|'),800);
19284
19285                    frUpload.then(function(data) {
19286                        $.each(data.u, function(i,v) {
19287                            if(empty && i == 0) {
19288                                folder = 800;
19289                                f = v.path + folder + '/' + v.file;
19290                                var thumb = v.path + '250/' + v.file,
19291                                    img_src = (v.magic) ? v.magic : v.file,
19292                                    src_s800 = getServeImage(img_src,'800',v.path),
19293                                    src_s250 = getServeImage(img_src,'250',v.path);
19294
19295                                $('.prod-item-image').append('<div class="preview-img" style="background-image: url(' + src_s800 + ')">').addClass('active');
19296                                $('.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>');
19297                            } else {
19298                                if(isMainImageClick && i == 0) {
19299                                    folder = 800;
19300                                    f = v.path + folder + '/' + v.file;
19301                                    var thumb = v.path + '250/' + v.file,
19302                                        img_src = (v.magic) ? v.magic : v.file,
19303                                        src_s800 = getServeImage(img_src,'800',v.path),
19304                                        src_s250 = getServeImage(img_src,'250',v.path);
19305
19306                                    $('.prod-item-image').addClass('active').find('.preview-img').css('background-image','url("'+ src_s800 +'")');
19307                                    if($('.prod-item-thumb .prod-item-image-add').before().hasClass('.prod-item-image-add')) {
19308                                        $('.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>');
19309                                    } else {
19310                                        $('.prod-item-thumb li:eq(0) img').replaceWith('<img src="' + src_s250 + '">');   
19311                                    }
19312                                } else {
19313                                    folder = 250;
19314                                    f = v.path + folder + '/' + v.file;
19315                                    var thumb = v.path + '250/' + v.file,
19316                                        img_src = (v.magic) ? v.magic : v.file,
19317                                        src_s800 = getServeImage(img_src,'800',v.path),
19318                                        src_s250 = getServeImage(img_src,'250',v.path);
19319
19320                                    if(idx > -1) {
19321                                        if(idx == 0) $('.prod-item-image .preview-img').css('background-image', 'url("' + src_s800 + '")');
19322                                        $('.prod-item-thumb li:eq(' + idx +') img').replaceWith('<img src="' + src_s250 + '">');
19323                                    } else {
19324                                        $('.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>');
19325                                    }
19326                                }
19327                            }
19328                            if(imgs.length) $('.prod-item-image').removeClass('empty');
19329                            if($('.prod-item-thumb li').length > 10) $('.prod-item-image-add').addClass('hide');
19330                        });
19331                        $('#el-fileupload').modal('hide');
19332                    });
19333                } else {
19334                    $.each(imgs, function(i,v) {
19335                        if(empty && i == 0) {
19336                            p = url + '/' + site + '/';
19337                            var thumb = p + '250/' + v,
19338                                src_s800 = getServeImage(v,"800",p),
19339                                src_s250 = getServeImage(v,"250",p);
19340                            $('.prod-item-image').append('<div class="preview-img" style="background-image: url(' + src_s800 + ');">').addClass('active');
19341                            $('.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>');
19342                        } else {
19343                            if(isMainImageClick && i == 0) {
19344                                p = url + '/' + site + '/';
19345                                var thumb = p + '250/' + v,
19346                                    src_s800 = getServeImage(v,"800",p),
19347                                    src_s250 = getServeImage(v,"250",p);
19348                                $('.prod-item-image').addClass('active').find('.preview-img').css('background-image','url("'+ src_s800 +'")');
19349                                $('.prod-item-thumb li:eq(0) img').replaceWith('<img src="' + src_s250 + '">');
19350                            } else {
19351                                p = url + '/' + site + '/';
19352                                var thumb = p + '250/' + v,
19353                                    src_s800 = getServeImage(v,"800",p),
19354                                    src_s250 = getServeImage(v,"250",p);
19355                                if(idx > -1) {
19356                                    if(idx == 0) $('.prod-item-image .preview-img').css('background-image', 'url("' + src_s800 + '")');
19357                                    $('.prod-item-thumb li:eq(' + idx +') img').replaceWith('<img src="' + src_s250 + '">');
19358                                } else {
19359                                    $('.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>');
19360                                }
19361                            }
19362                        }
19363                    });
19364                }
19365                if(imgs.length) $('.prod-item-image').removeClass('empty');
19366                if($('.prod-item-thumb li').length > 10) $('.prod-item-image-add').addClass('hide');
19367                $('#el-fileupload').modal('hide');
19368                useitResourceBtn.removeClass('clicked');
19369            });
19370            
19371            $(document)
19372            .off('keyup', '.option-price-number')
19373            .on('keyup', '.option-price-number', function(e) {
19374                var key = e.keyCode || e.which;
19375                    txt = $(this).val();
19376                var match;
19377
19378                if($(this).closest('.prod-option').attr('data-option_mode') == 'additional') {
19379                    match = txt.match(/[0-9]+/g);
19380                } else {
19381                    match = txt.match(/[0-9,\-\+]+/g);
19382                }
19383                
19384                $(this).val(match);
19385                var price = removeCommas($('#prod-price').val()),
19386                    input = (match == null) ? 0 : removeCommas(match[0]);
19387
19388                if(parseInt(price) + parseInt(input) < 0) {
19389                    alert('판매가가 0원 아래로 적용될 수 있는 옵션 가격입니다.');
19390                    $(this).val('0').focus();
19391                }
19392            });
19393
19394            $(document)
19395            .off('keyup', '#brand')
19396            .on('keyup', '#brand', function (e) {
19397                var key = e.keyCode || e.which;
19398                    txt = $(this).val();
19399                var match = txt.match(/[a-zA-Zㄱ-ㅎㅏ-ㅣ가-힣0-9-_/:&+() ]/g);
19400                if (match != null) {
19401                    $(this).val(match.join(''));
19402                } else {
19403                    $(this).val('');
19404                }
19405            });
19406
19407            $(document)
19408            .off('click','.choose-gallery')
19409            .on('click','.choose-gallery', function(e) {
19410                e.stopPropagation();
19411                var pid = $('#prod-pid').val();
19412                $(this).toggleClass('open');
19413                $('.gallery-menus-wrap').toggle();
19414                $('.gallery-menus-wrap .gallery-menus li').removeClass('active');
19415                $('.gallery-menus-wrap .gallery-menus li.gallery-name[data-gallery-id="' + pid + '"]').addClass('active');
19416            });
19417
19418            $(document)
19419            .off('click','.gallery-menus-wrap .gallery-menus li')
19420            .on('click','.gallery-menus-wrap .gallery-menus li', function(e) {
19421                e.stopPropagation();
19422                if($(this).hasClass('gallery-name')) {
19423                    var pid = $(this).attr('data-gallery-id'),
19424                        name = $(this).html();
19425                    if(typeof pid == 'undefined' || pid == '') {
19426                        alert('블럭 오류 입니다. 관리자
19426에게 문의하세요');
19427                        $('.gallery-menus-wrap').hide();
19428                        return false;
19429                    }
19430                    $('#prod-pid').val(pid);
19431                    $('.product-gallery-name').html(name);
19432                    $(this).parents('.form-wrap').removeClass('empty');
19433                    $('.choose-gallery').removeClass('open');
19434                    $('.gallery-menus-wrap').hide();
19435                }
19436            });
19437        },
19438        add : function(id,gpos,gcate) {
19439            if($('.prod-modal.cl-p-modal').length > 0) return false;
19440
19441            var site = (typeof SID == 'undefined') ? property.SID : SID,
19442                page = ($.gallery.item_of_page) ? $.gallery.item_of_page : '',
19443                pid = (typeof selectID == 'undefined') ? null : selectID;
19444            
19445            if(page == '') page = $('.gallery-modal').attr('data-page');
19446            if(typeof page == 'undefined' || page == '')
19447                page = (typeof PAGE == 'undefined') ? ((typeof property == 'undefined') ? '' : property.PAGE) : PAGE;
19448
19449            if(typeof page == 'undefined' || page == '') {
19450                alert('Undefined page!!!');
19451                return false;
19452            }
19453            if(typeof $.gallery.block_id != 'undefined' && $.gallery.block_id) pid = $.gallery.block_id;
19454            // 상품 옵션
19455            product_options = {};
19456            fileUpdateCnt = 0;
19457            //     pid = $('.gallery-add-items').attr('data-pid');
19458            // if(typeof pid == 'undefined' || pid == null) pid = $('.config-image-edit').attr('data-pid');
19459            // if(typeof pid == 'undefined' || pid == null) { pid = (typeof PARENT == 'undefined') ? property.PARENT.pid : PARENT.pid }
19460            // if(typeof pid == 'undefined' || pid == null) pid = (typeof selectID == 'string') ? selectID : null;
19461            // console.log(site,page,pid);
19462            // return false;
19463
19464            if(pid.toString().toLowerCase().match(/^cl-s-product-detail,/g) !== null) {
19465                pid = PARENT.pid;
19466            }
19467
19468            page = (page.indexOf(',') > -1) ? page_split(page) : page;
19469            if(!site || !pid || typeof pid == 'undefined' || pid == null) {
19470                alert('Undefined gallery'); 
19471                return false;
19472            }
19473
19474            if($('.table-item[data-seq="' + id + '"]').length) pid = $('.table-item[data-seq="' + id + '"]').attr('data-pid');
19475
19476            var parentDocument = $(window.parent.document),
19477                $detail_modal = parentDocument.find('.product-detail-modal');
19478            if($detail_modal.length) $detail_modal.addClass('overlap');
19479            
19480            var params = ($('.gallery-modal').length) ? getProductParams() : getSearchURL();
19481            $.processON();
19482            $.ajax({
19483                url: '/template/products',
19484                data: { type:'get', sid:site, id:id, pid:pid, params:params },
19485                dataType: 'json',
19486                type: 'POST',
19487                async: true,
19488                cache: false,
19489                success: function (data) {
19490                    $.processOFF();
19491                    if(data.error != 'undefined' && data.error) {
19492                        alert(data.error);
19493                        return false;
19494                    }
19495                    var i = data.item,
19496                        plan = i.valid_plan;
19497
19498                    closeProductNumber = i.no;
19499                    product_options = i.prod_options_settings;
19500                    var prod_quantity = parseInt(i.quantity),
19501                        category = '';
19502                    if(id == -1 && $.gallery.category) {
19503                        category = $.gallery.category;
19504                    }
19505                    if(typeof gcate != 'undefined' && gcate) category = gcate;
19506                    if(!category) category = i.category;
19507
19508                    if(prod_quantity < 0 || isNaN(prod_quantity)) i.quantity = 0;
19509                    if(!i.price) i.price = 0;
19510
19511                    $m = $(data.r).hide();
19512                    $('body').append($m);
19513                    $('#sid').val(i.sid);
19514                    $('#prod-page').val(page);
19515                    $('#prod-pid').val(i.pid);
19516                    $('#prod-no').val(i.no);
19517                    $('#prod-title').val(i.title);
19518                    $('#prod-desc').val(i.desc);
19519                    $('#prod-price').val(i.price);
19520                    $('#prod-sale').text(i.sale);
19521                    $('#lux-product').val(i.lux_product);
19522                    
19523                    if(!LUX) {
19524                        if(i.discount_unit == 'P') {
19525                            $('#prod-discount-rate').val(i.discount_rate);
19526                            // $('#price-cut-btn').removeClass('hide');
19527                        } else {
19528                            $('#prod-discount-rate').val(number_format(i.discount_rate));
19529                        }
19530                    }
19531
19532                    if(typeof i.discount_rate == 'undefined' || i.discount_rate == 0) i.discount_unit = 'W';
19533                    $('#prod-discount-unit').attr('data-value', i.discount_unit);
19534                    $('#prod-discount-unit').text($('.discount-unit-select > div[data-value="'+i.discount_unit+'"]').text());
19535                    
19536                    // 상품 세일가 hidden
19537                    $('#retail-price').val(i.retail_price);
19538                    $('#prod-quantity').val(i.quantity);
19539                    if(typeof gpos != 'undefined' && gpos) $('#prod-gpos').val(gpos);
19540                    else $('#prod-gpos').val('');
19541                    $('#prod-category-text').text(category);
19542                    $('#prod-category-lists ul').empty();
19543                    $('#prod-category').attr('data-category',i.category_lists.toString());
19544
19545
19546                    if(plan.type == 'SM' && plan.valid_plan == true) {
19547                        $('.form-wrap.culture-benefit').removeClass('plan-upgrade');
19548                        if(i.use_naverpay == true) {
19549                            $('.form-wrap.culture-benefit').removeClass('not-support');
19550                            if(i.culture_benefit_yn == 'Y') {
19551                                $('.form-wrap.culture-benefit').removeClass('disabled');
19552                            }
19553                        }
19554
19555                        $('.form-wrap#pccc-yn, .form-wrap#require-navershop, .form-wrap#mng-prd-info').removeClass('plan-upgrade');
19556                        $('.form-wrap#pccc-yn,.form-wrap#require-navershop, .form-wrap#mng-prd-info').find('input-switch').removeClass('editor-upgrade-popup').removeAttr('data-mode');
19557                        
19558                        if(i.product_pccc_yn == 'Y') {
19559                            $('.form-wrap#pccc-yn').removeClass('disabled');
19560                        }
19561
19562                        if(i.nshop_setting == 'Y') {
19563                            if(LUX && i.require_navershop == 'T') {
19564                                $('.form-wrap#require-navershop').removeClass('disabled');
19565                                $('.form-wrap#require-navershop').find('input').prop('checked', true);
19566                            }
19567                        } else {
19568                            $('.form-wrap#require-navershop').addClass('use-nshop-setting not-support');
19569                        }
19570                        if(i.mng_product_info_use == 'on') {
19571                            $('.form-wrap#mng-prd-info').removeClass('disabled');
19572                        }
19573                    }
19574
19575                    if(i.culture_benefit_yn == 'Y') {
19576                        $('.form-wrap.culture-benefit').find('input').prop('checked', true);
19577                    }
19578                    if(i.product_pccc_yn == 'Y') {
19579                        $('.form-wrap#pccc-yn').find('input').prop('checked', true);
19580                    }
19581
19582                    if(parseFloat(i.total_unit_value)) {
19583                        $('.form-wrap.unit-pricing').find('input').prop('checked', true).change();
19584                        $('input[name="total_unit_value"]').val(number_format(parseFloat(i.total_unit_value)));
19585                        $('select[name="total_unit"]').val(i.total_unit).selectpicker('render');
19586                        $('input[name="total_unit_bundle"]').val(number_format(i.total_unit_bundle));
19587                        $('select[name="total_unit"]').change();
19588                        $('select[name="basic_unit"]').val(i.basic_unit).selectpicker('render');
19589                        $('input[name="basic_unit_value"]').val(number_format(parseFloat(i.basic_unit_value))).change();
19590                    } else {
19591                        $('select[name="total_unit"]').change();
19592                    }
19593
19594
19595                    var delivery_template_str = '';
19596                    if(i.delivery_template) {
19597                        $.each(i.delivery_template, function(k, v) {
19598                            var template_desc = '';
19599                            template_desc += '(';
19600                            template_desc += $.lang[LANG]['shopping.delivery.template.mix_yn.' + v.mix_yn.toLowerCase()];
19601                            var delivery_type_arr = v.delivery_type.split(',');
19602                            var delivery_type_str = '';
19603                            $.each(delivery_type_arr, function(idx, delivery_type) {
19604                                if(delivery_type_str) delivery_type_str += ', ';
19605                                delivery_type_str += $.lang[LANG]['shopping.delivery.template.delivery_type.' + delivery_type.toLowerCase()];
19606                            });
19607                            if(delivery_type_str) 
19608                                template_desc += ' / ' + delivery_type_str;
19609                            
19610                            if(delivery_type_arr.indexOf('DELIVERY') > -1) {
19611                                template_desc += ' / ' + $.lang[LANG]['shopping.delivery.' + v.delivery_company.toLowerCase()];
19612                            }
19613
19614                            template_desc += ' / ' + $.lang[LANG]['shopping.delivery.template.price_type.' + v.price_type.toLowerCase()];
19615
19616                            if(v.price_type == 'FIX') {
19617                                template_desc += '(' + number_format(v.delivery_fee) + '원)';
19618                            } else if(v.price_type == 'QUANTITY' || v.price_type == 'WEIGHT') {
19619                                var price_type_detail = v.price_type_detail ? JSON.parse(v.price_type_detail) : {};
19620                                
19621                                if(price_type_detail.method == 'DIFFERENTIAL') {
19622                                    var detail = '';
19623                                    if(price_type_detail.detail) {
19624                                        $.each(price_type_detail.detail, function(i, j) {
19625                                            var value = Object.keys(j);
19626                                            var price = Object.values(j);
19627
19628                                            if(v.price_type == 'QUANTITY') {
19629                                                // if(i < 2) {
19630                                                    if(detail) detail += ', ';
19631                                                    detail += value + '개 이상(' + number_format(price) + '원)';
19632                                                // }
19633                                            } else if(v.price_type == 'WEIGHT') {
19634                                                // if(i < 2) {
19635                                                    if(detail) detail += ', ';
19636                                                    detail += value + 'Kg 이상(' + number_format(price) + '원)';
19637                                                // }
19638                                            }
19639                                        });
19640                                    }
19641                                    if(template_desc) {
19642                                        detail = '(차등 / ' + detail + ')';
19643                                        template_desc += detail;
19644                                    }
19645                                } else if(price_type_detail.method == 'REPEAT') {
19646                                    var detail = '';
19647                                    var value = Object.keys(price_type_detail.detail);
19648                                    var price = Object.values(price_type_detail.detail);
19649
19650                                    if(v.price_type == 'QUANTITY') {
19651                                        detail += value + '개 구매시마다 ' + number_format(price) + '원 반복 부과';
19652                                    } else if(v.price_type == 'WEIGHT') {
19653                                        detail += value + 'Kg마다 ' + number_format(price) + '원 반복 부과';
19654                                    }
19655
19656                                    if(detail) {
19657                                        detail = '(반복 / ' + detail + ')';
19658                                        template_desc += detail;
19659                                    }
19660                                }
19661                            }
19662
19663                            if(v.additional_yn == 'Y') {
19664                                template_desc += ' / 도서산간 지역 추가 배송비 (제주 ' + number_format(v.additional_jeju_price) + '원, 제주 외 도서산간 ' + number_format(v.additional_land_price) + '원)';
19665                            }
19666
19667                            template_desc += ' / ' + $.lang[LANG]['shopping.delivery.template.pay_type.' + v.pay_type.toLowerCase()];
19668
19669                            if(v.free_condition_yn == 'Y') {
19670                                template_desc += ' / ' + number_format(v.free_condition) + '원 이상 무료 배송';
19671                            }
19672
19673                            if(v.make_to_order_yn == 'Y') {
19674                                template_desc += ' / 주문 확인 후 ' + v.due_date + '일 후 배송 예정';
19675                            }
19676                            if(v.install_fee_yn == 'Y') {
19677                                template_desc += ' / 별도 설치비 있음';
19678                            }
19679                            template_desc += ')';
19680
19681                            delivery_template_str += '\
19682                            <li data-val="' + v.seq + '" data-weight="' + (v.price_type == 'WEIGHT' ? 'true' : 'false') + '">\
19683                                <input type="radio" id="delivery_template_seq_' + v.seq + '" name="delivery_template_seq" value="' + v.seq + '" />\
19684                                <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>\
19685                                <label for="delivery_template_seq_' + v.seq + '">\
19686                                    <span class="template-name">' + v.name + '</span>\
19687                                    <span class="template-desc">' + template_desc + '</span>\
19688                                </label>\
19689                            </li>';
19690                        });
19691                    }
19692
19693                    $('.option-delivery-template-select').html(delivery_template_str);
19694
19695                    if(typeof i.delivery_template_seq != 'undefined' && i.delivery_template_seq) {
19696                        $('.option-delivery-template-select input[name="delivery_template_seq"][value="' + i.delivery_template_seq + '"]').prop('checked', true);
19697
19698                        $('.option-delivery-template-str').html($('.option-delivery-template-select li[data-val="' + i.delivery_template_seq + '"] label').html());
19699
19700                        if($('.option-delivery-template-select li[data-val="' + i.delivery_template_seq + '"]').data('weight') == false) {
19701                            $('.product-weight').hide();
19702                            $('#product_weight').val('');
19703                        } else {
19704                            $('#product_weight').val(number_format(i.p.product_weight) + 'kg');
19705                        }
19706                    } else {
19707                        $('.option-delivery-template-select input[name="delivery_template_seq"]:first').prop('checked', true).change();
19708                    }
19709                    uadmin = i.uadmin;
19710                    var etcAry = [];
19711                    if (i.etc_info) etcAry = i.etc_info.split('||');
19712                    $('.cl_etc_state_check').removeClass('active');
19713                    switch(etcAry[0]) {
19714                        case 'Y':
19715                        case 'T':
19716                            $('#cl_etc_state_'+etcAry[0].toLowerCase()).addClass('active');
19717                            
19718                            if(etcAry[0] == 'Y') {
19719                                $('.etc-setting').not('.time-setting').removeClass('hide');
19720                            } else {
19721                                $('.etc-setting').removeClass('hide');
19722                            }
19723
19724                            if (etcAry[1] == 'S') {
19725                                $('#cl_etc_status_s').addClass('active');
19726                                $('#cl_etc_status_p').removeClass('active');
19727                            } else {
19728                                $('#cl_etc_status_s').removeClass('active');
19729                                $('#cl_etc_status_p').addClass('active');
19730                            }
19731                            $('#etc-date-state').val(etcAry[0]);
19732                            $('#etc-date-status').val(etcAry[1]);
19733                            $('#etc-week').val(etcAry[2]);
19734                            $('#etc-start-date').val(etcAry[3]);
19735                            $('#etc-end-date').val(etcAry[4]);
19736                            $('#etc-date-time').val(etcAry[5]);
19737                            $('#etc-exclude-date').val(etcAry[6]);
19738                            $('#etc-term').val(etcAry[7]);
19739                            $('#etc-time').val(etcAry[8]);
19740                            break;
19741                        default:
19742                            $('#etc-term').val(etcAry[7]);
19743                            $('#etc-time').val(etcAry[8]);
19744                            $('#cl_etc_state_n').addClass('active');
19745                            break;
19746                    }
19747
19748                    
19749                    if(LUX) {
19750                        if(!id || id < 1 || id == '0' || id >= 1000000000) {
19751                            $('.prod-price-sync').removeClass('active').hide();
19752                            $('.margin-config').addClass('disabled');
19753                            $('#prod-price').removeAttr('readonly');
19754                            $('.check-sale').removeClass('disabled');
19755                        } else if(i.price_sync == 'F') {
19756                            $('.prod-price-sync').removeClass('active');
19757                            $('.margin-config').addClass('disabled');
19758                            $('#prod-price').removeAttr('readonly');
19759                            $('.check-sale').removeClass('disabled');
19760                        }
19761
19762                        if(i.prod_status) {
19763                            $('.prod-status').removeClass('active');
19764                            $('.prod-status[data-val="' + i.prod_status + '"]').addClass('active');
19765                        }
19766                    }
19767
19768                    var cate = (category) ? category.split(', ') : [];
19769                    $.each(i.category_lists, function(i,v) {
19770                        $li = $('<li>' + v + '</li>');
19771                        if($.inArray(v.trim(),cate) > -1) $li.addClass('active');
19772                        $('#prod-category-lists ul').append($li);
19773                    });
19774
19775                    $('input#product_weight').on('focus', function() {
19776                        $(this).val($.trim($(this).val()).replace('kg', ''));
19777                    }).on('blur', function() {
19778                        $(this).val($.trim($(this).val()).replace('kg', '') + ($.trim($(this).val()).replace('kg', '') ? 'kg' : ''));
19779                    });
19780                    
19781                    if(LUX) {
19782                        $.each(i.footer, function(idx,v) {
19783                            if (idx == 1) return true;
19784                            if(idx <= 3 && v == 'true') {
19785                                if (idx == 2) {
19786                                    $('.page-options input:eq(1)').prop('checked',true);
19787                                } else if (idx == 3) { //photo
19788                                    if (v == 'true') {
19789                                        $('.photo-review-tab #photo-review').prop('checked',true);
19790                                    } else {
19791                                        $('.photo-review-tab #photo-review').prop('checked',fal
19791se);
19792                                    }
19793                                } else {
19794                                    $('.page-options input:eq(' + idx + ')').prop('checked',true);
19795                                }
19796                            }
19797                        });
19798                    } else {
19799                        // $.each(i.footer, function(idx,v) {
19800                        //     if(idx <= 3 && v == 'true') {
19801                        //         if (idx == 3) { //photo
19802                        //             if (v == 'true') {
19803                        //                 $('.photo-review-tab #photo-review').prop('checked',true);
19804                        //             } else {
19805                        //                 $('.photo-review-tab #photo-review').prop('checked',false);
19806                        //             }
19807                        //         } else {
19808                        //             $('.page-options input:eq(' + idx + ')').prop('checked',true);
19809                        //         }
19810                        //     }
19811                        //     if (idx == 1) { //review
19812                        //         if (v == 'true') {
19813                        //             $('.photo-review-tab').removeClass('hide');
19814                        //         } else {
19815                        //             $('.photo-review-tab').addClass('hide');
19816                        //         }
19817                        //     }
19818                        // });
19819
19820                        if(i.footer[1] == 'true') { //review
19821                            $('#review-checkbox').closest('.form-wrap').removeClass('disabled');
19822                            $('#review-checkbox').prop('checked',true);
19823                            $('.photo-review-tab').removeClass('hide');
19824                        } else {
19825                            $('#review-checkbox').closest('.form-wrap').addClass('disabled');
19826                            $('#review-checkbox').prop('checked',false);
19827                            $('.photo-review-tab').addClass('hide');
19828                        }
19829
19830                        if(i.footer[2] == 'true') { //qna
19831                            $('#qna-checkbox').closest('.form-wrap').removeClass('disabled');
19832                            $('#qna-checkbox').prop('checked',true);
19833                        } else {
19834                            $('#qna-checkbox').closest('.form-wrap').addClass('disabled');
19835                            $('#qna-checkbox').prop('checked',false);
19836                        }
19837
19838                        if(i.footer[3] == 'true') { //top photo review
19839                            $('.photo-review-tab #photo-review').prop('checked',true);
19840                        } else {
19841                            $('.photo-review-tab #photo-review').prop('checked',false);
19842                        }
19843                        // if(i.footer.length > 0 && i.footer[1] == 'true' && typeof i.footer[7] == 'undefined') {
19844                        //     $('.photo-review-top-view').removeClass('hide');
19845                        //     $('.photo-review-tab #use-review-img-upload').prop('checked',true);
19846                        // }
19847                        if (i.use_review_img_upload != 'false') {
19848                            $('.photo-review-top-view').removeClass('hide');
19849                            $('.photo-review-tab #use-review-img-upload').prop('checked',true);
19850                        } else {
19851                            $('.photo-review-top-view').addClass('hide');
19852                            $('.photo-review-tab #use-review-img-upload').prop('checked',false);
19853                            $('.photo-review-tab #photo-review').prop('checked',false);
19854                        }
19855                    }
19856
19857                    if(i.imgs.length > 10) $('.prod-item-image-add').addClass('hide');
19858                    $.each(i.imgs, function(idx,img) {
19859                        if(idx > 10) return true;
19860                        if(img) {
19861                            (idx == 0) ? $('.prod-item-image').addClass('active').append('<div class="preview-img" style="background-image: url(' + img + ');">') :
19862                                         $('.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>');
19863                        }
19864                    });
19865
19866                    $('.prod-option').each(function(){
19867                        if($(this).data('option_mode') == 'normal' && i.options.length == 0) {
19868                            i.options[0] = { 
19869                                'seq' : '',
19870                                'option_name' : 'noneOption',
19871                                'option_price' : 0
19872                            } 
19873                        }
19874                    });
19875
19876                    if(i.quantity_on == 'on') {
19877                        $('.switch-quantity').prop('checked','checked').parents('.form-wrap').removeClass('disabled');
19878                    }
19879
19880                    setOptionlist(i.options);
19881                    i.footer[4] = (i.footer[4] == '' || i.footer[4] == undefined)? 'true':i.footer[4];
19882                    $('#normal-option').prop('checked', true);
19883
19884                    $('.prod-option-tab').addClass('hide');
19885                    $('#normal-option').prop('checked', false);
19886                    $('#text-option').prop('checked', false);
19887                    $('#additional-option').prop('checked', false);
19888                    $('.prod-option-tab .prod-option').addClass('hide');
19889                    if(i.footer[4]=='true' && $('.prod-option[data-option_mode="normal"] .prod-option-list>li').length > 1) {
19890                        $('#normal-option').prop('checked', true);
19891                        $('.prod-option-tab').removeClass('hide');
19892                        $('.prod-option[data-option_mode="normal"]').removeClass('hide');
19893                        $('.prod-option[data-option_mode="normal"] .plus-price').removeClass('hide');
19894                        $('.prod-option[data-option_mode="normal"] .plus-status').removeClass('hide');
19895                        if(i.quantity_on == 'on') {
19896                            $('.prod-option[data-option_mode="normal"] .plus-quantity').removeClass('hide');
19897                        }
19898                    }
19899                    if(i.footer[5]=='true' && $('.prod-option[data-option_mode="text"] .prod-option-list>li').length > 0) {   
19900                        $('#text-option').prop('checked', true);
19901                        $('.prod-option-tab').removeClass('hide');
19902                        $('.prod-option[data-option_mode="text"]').removeClass('hide');
19903                        $('.prod-option[data-option_mode="text"] .plus-price').removeClass('hide');
19904                        $('.prod-option[data-option_mode="text"] .plus-status').removeClass('hide');
19905                        if(i.quantity_on == 'on') {
19906                            $('.prod-option[data-option_mode="text"] .plus-quantity').removeClass('hide');
19907                        }
19908                        if($('.prod-option[data-option_mode="text"] .prod-option-list>li').length >= 7) { //입력옵션 7개이상 추가X
19909                            $('.prod-option[data-option_mode="text"] > .prod-option-add').addClass('disabled');
19910                        }
19911                    }
19912                    if(i.footer[6]=='true' && $('.prod-option[data-option_mode="additional"] .prod-option-list>li').length > 0) {
19913                        $('#additional-option').prop('checked', true);
19914                        $('.prod-option-tab').removeClass('hide');
19915                        $('.prod-option[data-option_mode="additional"]').removeClass('hide');
19916                        $('.prod-option[data-option_mode="additional"] .plus-price').removeClass('hide');
19917                        $('.prod-option[data-option_mode="additional"] .plus-status').removeClass('hide');
19918                        if(i.quantity_on == 'on') {
19919                            $('.prod-option[data-option_mode="additional"] .plus-quantity').removeClass('hide');
19920                        }
19921                    }
19922
19923                    if(i.prod_info_on == 'on') {
19924                        $('.switch-prod-info').prop('checked','checked').parents('.form-wrap').removeClass('disabled');
19925                        $('.prod-info-toggle').addClass('open');
19926                        $('.info-selected').removeClass('hide');
19927                    } else {
19928                        $('.switch-prod-info').prop('checked', '').parents('.form-wrap').addClass('disabled');
19929                        $('.prod-info-toggle').removeClass('open');
19930                        $('.info-selected').addClass('hide');
19931                    }
19932
19933                    if(i.product_on) {
19934                        $('.switch-product[value="'+i.product_on+'"]').prop('checked', true);
19935                        $('.switch-product[value="'+i.product_on+'"] + label').addClass('active');
19936
19937                        if(i.product_on == 'lim') {
19938                            $('#status-append').fadeIn(0);
19939                            $('#sale-calendar').show();
19940                        } else {
19941                            $('#status-append').hide();
19942                            $('#sale-calendar').hide();
19943                        }
19944                    } else {
19945                        $('.switch-product[value="on"]').prop('checked', true);
19946                        $('.switch-product[value="on"] + label').addClass('active');
19947                    }
19948
19949                    if(i.sales_start && i.sales_end) {
19950                        $('#sale-start-datetime').val(i.sales_start);
19951                        $('#sale-end-datetime').val(i.sales_end);
19952                        var startDateTimeArr = i.sales_start.split(' ');
19953                        var endDateTimeArr = i.sales_end.split(' ');
19954                        var startTime = convertTime12(startDateTimeArr[1]);
19955                        var endTime = convertTime12(endDateTimeArr[1]);
19956                        $('.sale-setting .setting-text .content-start').text(startDateTimeArr[0].replace(/-/g, '.') + '. ' + startTime);
19957                        $('.sale-setting .setting-text .content-end').text(endDateTimeArr[0].replace(/-/g, '.') + '. ' + endTime);
19958                    }
19959                    
19960                    if(i.quantity_on == 'on') {
19961                        $('.switch-quantity').prop('checked','checked').parents('.form-wrap').removeClass('disabled');
19962                        if($('#normal-option').is(':checked') === true) {
19963                        // $('#prod-quantity').attr('readonly','true').removeClass('hide').attr('placeholder','옵션에서 재고 관리');
19964                            $('.quantity-label').addClass('on');
19965                            $('.plus-quantity').removeClass('hide');
19966                        } else if($('#normal-option').is(':checked') === false && $('#additional-option').is(':checked') === true) {
19967                            $('.quantity-label').removeClass('on');
19968                            $('#prod-quantity').removeAttr('readonly').removeClass('hide');
19969                            $('.plus-quantity').removeClass('hide');
19970                        } else {
19971                            $('.quantity-label').removeClass('on');
19972                            $('#prod-quantity').removeAttr('readonly').removeClass('hide');
19973                            $('.plus-quantity').addClass('hide');
19974                        }
19975                    } else {
19976                        $('.prod-option-quantity, .edit-option-quantity').hide();
19977                        $('.plus-quantity').addClass('hide');
19978                    }
19979
19980                    if(!i.sale && i.price == 0) {
19981                        $('#prod-sale-check').prop('disabled', true);
19982                        $('#grade-sale-check').prop('disabled', true);
19983                    } else {
19984                        $('#prod-sale-check').prop('disabled', false);
19985                        $('#grade-sale-check').prop('disabled', false);
19986                    }
19987
19988                    if(i.sale) {
19989                        $('#prod-price').addClass('sale-on');
19990                        $('#prod-price').prop('readonly', true);
19991                        $('#prod-sale').show().addClass('strike');
19992                        $('.discount-append').removeClass('hide');
19993                        $('#prod-sale-check').prop('checked',true);
19994                        $('#grade-sale-check').prop('checked',true);
19995                        $('#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"/>');
19996                        $('.check-sale').addClass('checked');
19997
19998                        // if (Number(removeCommas(i.price)) % 10 == 0 || Number(removeCommas(i.price)) == 0) $('#price-cut-btn').addClass('disabled');
19999                        // else $('#price-cut-btn').removeClass('disabled');
20000                    }
20001
20002                    if(i.grade_onoff == 'ON') {
20003                        $('#grade-sale-check').prop('checked', true);
20004                        $('#shopping-grade').val('ON');
20005                        $('#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"/>');
20006                        $('.grade-sale').addClass('checked');
20007                    } else {
20008                        $('#grade-sale-check').prop('checked', false);
20009                        $('#shopping-grade').val('OFF');
20010                    }
20011
20012                    calInputWidth($('#prod-price'));                    
20013
20014                    $('.prod-option').each(function(){
20015                        if($(this).data('option_mode') == 'normal' && i.options.length == 0) {
20016                            i.options[0] = { 
20017                                'seq' : '',
20018                                'option_name' : 'noneOption',
20019                                'option_price' : 0
20020                            } 
20021                        }
20022                    });
20023                              
20024                    $m.fadeIn(300);
20025                    $('.prod-option-list').sortable({
20026                       handle : ".prod-option-move",
20027                       refreshPositions: true
20028                    });
20029
20030                    if (i.product_state == 'download') {
20031                        $('#download-product').attr('checked', true);
20032                        $('.cl_product_state_check').each(function () {
20033                            if ($(this).attr('for') == 'download-product') {
20034                                $(this).find('.cl-icon').removeClass('cl_icon_check02_off').removeClass('cl_icon_check02_on').addClass('cl_icon_check02_on');
20035                                $(this).click();
20036                                $('#download-date').val(i.download_date);
20037                                $('#download-count').val(i.download_count);
20038                            } else {
20039                                $(this).find('.cl-icon').removeClass('cl_icon_check02_off').removeClass('cl_icon_check02_on').addClass('cl_icon_check02_off');
20040                            }
20041                        });
20042                        $('.delivery-template, .product-weight, .brand, .culture-benefit').hide();
20043                    }
20044
20045                    if (i.product_state == 'normal') {
20046                        $('#normal-product').attr('checked', true);
20047                        $('.cl_product_state_check').each(function () {
20048                            if ($(this).attr('for') == 'normal-product') {
20049                                $(this).find('.cl-icon').removeClass('cl_icon_check02_off').removeClass('cl_icon_check02_on').addClass('cl_icon_check02_on');
20050                                $(this).click();
20051                            } else {
20052                                $(this).find('.cl-icon').removeClass('cl_icon_check02_off').removeClass('cl_icon_check02_on').addClass('cl_icon_check02_off');
20053                            }
20054                        });
20055
20056                        if(!$('.delivery-template-list').find('[data-val]').find('input[name="delivery_template_seq"]:checked').length) {
20057                            $('.delivery-template-list').find('[data-val]:first').find('input[name="delivery_template_seq"]').prop('checked', true).change();
20058                        }
20059
20060                        $('.delivery-template').show();
20061                    }
20062
20063                    if (i.product_state == 'etc') {
20064                        $('#etc-product').attr('checked', true);
20065                        $('.cl_product_state_check').each(function () {
20066                            if ($(this).attr('for') == 'etc-product') {
20067                                $(this).find('.cl-icon').removeClass('cl_icon_check02_off').removeClass('cl_icon_check02_on').addClass('cl_icon_check02_on');
20068                                $(this).click();
20069                            } else {
20070                                $(this).find('.cl-icon').removeClass('cl_icon_check02_off').removeClass('cl_icon_check02_on').addClass('cl_icon_check02_off');
20071                            }
20072                        });
20073                        $('.delivery-template, .product-weight, .brand, .culture-benefit').hide();
20074                    }
20075
20076                    if(typeof updateNpayButtonSettingState == 'function') {
20077                        var npayProductState = i.product_state == 'normal' ? 'normal-product' : (i.product_state == 'download' ? 'download-product' : 'etc-product');
20078                        updateNpayButtonSettingState(npayProductState);
20079                    }
20080
20081                    taxUse = i.tax_use;
20082                    if (i.tax_use == 'TG03') {
20083                        $('#state-append').fadeIn(0);
20084                        $('#normal-product-state').fadeIn(0);
20085                        if (i.tax == 'TG01') {
20086                            $('#tax').attr('data-val', 'TG01');
20087                            $('#tax').html('과세');
20088                        }
20089
20090                        if (i.tax == 'TG02') {
20091                            $('#tax').attr('data-val', 'TG02');
20092                            $('#tax').html('비과세');
20093                        }
20094                        $('#tax').attr('data-total-tax', 'TG03');
20095                    } else {
20096                        if (i.product_state == 'normal') $('#state-append').fadeOut(0);
20097                        $('#normal-product-state').fadeOut(0);
20098                        $('#tax').attr('data-val', 'TG01');
20099                        $('#tax').html('과세');
20100                    }
20101                    setAdvancedMode(product_options.advanced);
20102
20103                    var descHeight = $('#prod-desc').prop('scrollHeight');
20104                    if(descHeight > 55) {
20105                        $('#prod-desc').css('height', descHeight+'px');
20106                    } else {
20107                        $('#prod-desc').removeAttr('style');
20108                    }
20109                },
20110                error : function(xhr, status, error) {
20111                    var parentDocument = $(window.parent.document),
20112                        $detail_modal = parentDocument.find('.product-detail-modal');
20113                    if($detail_modal.length) $detail_modal.removeClass('overlap');
20114
20115                    $.processOFF();
20116                    alert("Error " + xhr.status);
20117                }            
20118            });
20119        },
20120        review : function(id,page) {
20121            var site = (typeof SID == 'undefined') ? property.SID : SID;
20122
20123            $.ajax({
20124                url: '/template/products/',
20125                data: { type:'review', sid:site, id:id, page:page },
20126                dataType: 'json',
20127                type: 'POST',
20128                async: false,
20129                cache: false,
20130                success: function (data) {
20131                    if(data.error != 'undefined' && data.error) {
20132                        alert(data.error);
20133                        return false;
20134                    }
20135                    var $review = $(data.r).hide();
20136                    if(typeof property == "undefined") {
20137                        $lastEl = ($('.el-footer_ctrl').length) ? $('.el-footer_ctrl') : $('.add-footer-information');
20138                        if($('.page-bottomlist').length) $lastEl = $('.page-bottomlist');
20139                        if($('.fnav').length) $lastEl = $('.fnav');
20140                        $lastEl.before($review);
20141                        $review.show();
20142                    } else {
20143                        if(typeof property.ISLOCK != 'undefined' && property.ISLOCK == 'true') {
20144                            $review.addClass('hide');
20145                        }
20146                        if($('.el-footer').length) {
20147                            $lastEl = ($('.page-bottomlist').length) ? $('.page-bottomlist') : $('.el-footer');
20148                            if($('.fnav').length) $lastEl = $('.fnav');
20149                            $lastEl.before($review);
20150                            $review.show();
20151
20152                            var reviewArr = new Array();
20153
20154                            $('.s-table-review .review-content>div').each(function(idx, item){
20155                                reviewArr[idx] = $(this).html();
20156                            });
20157
20158                            truncateReviewTitle(reviewArr);
20159
20160                            $(window).on('resize', function(){
20161                                truncateReviewTitle(reviewArr)
20162                            });
20163                        } else {
20164                            $('.dsgn-body').append($review);
20165                            $review.show();
20166                        }
20167                    }
20168                    var cnt = ($('.review-wrap h4 > span').text()=="") ? 0 : $('.review-wrap h4 > span').text();
20169                    $('.review-count').text(' ' + cnt);
20170                }
20171            });
20172        },
20173        qna : function(id,page) {
20174            var site = (typeof SID == 'undefined') ? property.SID : SID;
20175
20176            $.ajax({
20177                url: '/template/products/',
20178                data: { type:'qna', sid:site, id:id, page:page },
20179                dataType: 'json',
20180                type: 'POST',
20181                async: false,
20182                cache: false,
20183                success: function (data) {
20184                    if(data.error != 'undefined' && data.error) {
20185                        alert(data.error);
20186                        return false;
20187                    }
20188                    var $qna = $(data.r).hide();
20189                    if(typeof property == "undefined") {
20190                        $lastEl = ($('.el-footer_ctrl').length) ? $('.el-footer_ctrl') : $('.add-footer-information');
20191                        if($('.page-bottomlist').length) $lastEl = $('.page-bottomlist');
20192                        if($('.fnav').length) $lastEl = $('.fnav');
20193                        $lastEl.before($qna);
20194                        $qna.show();
20195                    } else {
20196                        if(typeof property.ISLOCK != 'undefined' && property.ISLOCK == 'true') {
20197                            $qna.addClass('hide');
20198                        }
20199                        if($('.el-footer').length) {
20200                            $lastEl = ($('.page-bottomlist').length) ? $('.page-bottomlist') : $('.el-footer');
20201                            if($('.fnav').length) $lastEl = $('.fnav');
20202                            $lastEl.before($qna);
20203                            $qna.show();
20204                        } else {
20205                            $('.dsgn-body').append($qna);
20206                            $qna.show();
20207                        }
20208                    }
20209                    var cnt = ($('.qna-wrap h4 > span').text()=="") ? 0 : $('.qna-wrap h4 > span').text();
20210                    $('.qna-count').text(' ' + cnt);
20211                }
20212            });
20213        },
20214        list : function(id, page, view, page_num, sfl, stx, scate) {
20215        },
20216        save : function(go) {
20217            var before_prod = {};
20218            $('.product-wrap form input[name="before_prod[]"]').each(function() {
20219                var bd_key = $(this).attr('data-key'),
20220                    bd_val = $(this).val();
20221                
20222                before_prod[bd_key] = bd_val;
20223            });
20224
20225            var seq = $('#prod-no').val(),
20226                page = $('#prod-page').val(),
20227                pid = $('#prod-pid').val(),
20228                gpos = $('#prod-gpos').val(),
20229                s_grade = $('#shopping-grade').val(),
20230                $title = $('#prod-title'),
20231                $price = $('#prod-price'),
20232                $sale = $('#prod-sale'),
20233                $quantity = $('#prod-quantity'),
20234                $img = $('.prod-item-image'),
20235                $desc = $('#prod-desc'),
20236                $category = $('#prod-category-text'),
20237                $brand = $('#brand'),
20238                discountRate = ($('#prod-sale-check').is(':checked'))? $('#prod-discount-rate').val().trim().replace(/,/gi, '') : 0,
20239                discountUnit = ($('#prod-sale-check').is(':checked'))? $('#prod-discount-unit').attr('data-value') : 'W',
20240                // checkSaleCut = ($('#price-cut-btn').is(':checked'))? 'Y':'N',
20241                quantity_on = ($('.switch-quantity').is(":checked") == true) ? 'on' : 'off',
20242                product_on =  $('input[name="product_status"]:checked').val(),
20243                category_on = ($('.switch-category').is(":checked") == true) ? 'ON' : 'OFF',
20244                product_info_on = ($('.switch-prod-info').is(":checked") == true) ? 'on' : 'off',
20245                mng_product_info_use = ($('.switch-mngprd').is(":checked") == true) ? 'on' : 'off',
20246                mng_product_name = $('#mng-prd-name').val(),
20247                mng_product_code = $('#mng-prd-code').val(),
20248                submit = true,
20249                downloadDate = $('#download-date').val(),
20250                downloadCount = $('#download-count').val(),
20251                submit = true,
20252                productState = '',
20253                taxState = $('#tax').attr('data-val'),
20254                etcDateState = '',
20255                etcDateStatus = '', etcDateWeek = '',
20256                salesStart = '', salesEnd = '', open_out_datetime_yn = 'N',
20257                delete_options = $('#options-delete-list').val(),
20258                deliveryTemplateSeq = $('input[name="delivery_template_seq"]:checked').val(),
20259                productWeight = $('#product_weight').val().replace(/kg|,/gi, ''),
20260                culture_benefit_yn = $('.switch-culture-benefit').is(':checked') ? 'Y' : 'N',
20261                npay_button = $('.switch-npay-button').is(':checked') ? 'Y' : 'N',
20262                product_pccc_yn = $('.switch-pccc').is(':checked') ? 'Y' : 'N',
20263                require_navershop = $('.switch-require-navershop').is(':checked') ? 'T' : 'F',
20264                startDate = '', endDate = '', etcDate = '', exceptDate = '', termData = '', timeData = '',
20265                dayCheck = false, dayCheckLan = $('#etc-date-time').val();
20266                prod_info = getProductInfoList(),
20267                lux_product = ($('#lux-product').val() == "true") ? true : false,
20268                unit_use_yn = $('.switch-unit-pricing').prop('checked') ? 'Y' : 'N',
20269                total_unit_value = $('input[name="total_unit_value"]').val().replace(/,/g, ''),
20270                total_unit = $('select[name="total_unit"]').val(),
20271                total_unit_bundle = $('input[name="total_unit_bundle"]').val().replace(/,/g, ''),
20272                basic_unit_value = $('input[name="basic_unit_value"]').val().replace(/,/g, ''),
20273                basic_unit = $('select[name="basic_unit"]').val();
20274
20275            var price = $price.val();
20276            price = removeCommas(price);
20277            price = price * 1;
20278
20279            var nPrice = Number(price),
20280                submit = true;
20281
20282            // 옵션 가격 검색
20283            $.each($('.prod-option-price'), function(i,v) {
20284                var oPrice = $(v).attr('data-option-price');
20285                if(i > 0) {
20286                    if(nPrice + Number(oPrice) < 0) {
20287                        $(v).parents('li').addClass('err');
20288                        submit = false;
20289                    }
20290                }
20291            });
20292            if(submit == false) {
20293                // alert('옵션 가격이 올바르지 않습니다.');
20294                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() {
20295                    $(document).on('keydown', function(e) {
20296                        if(e.keyCode == 27) modal.modal('hide');
20297                    });
20298                });
20299                return false;
20300            }
20301
20302            if(product_on == 'lim') {
20303                if($('#sale-start-datetime').val() && $('#sale-end-datetime').val()) {
20304                    salesStart = $('#sale-start-datetime').val();
20305                    salesEnd = $('#sale-end-datetime').val();
20306                    open_out_datetime_yn = $('input[name="open_out_datetime_yn"]:checked').val();
20307                } else {
20308                    submit = false;
20309                    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() {
20310                        $(document).on('keydown', function(e) {
20311                            if(e.keyCode == 27) modal.modal('hide');
20312                        });
20313                    });
20314                    return false;
20315                }
20316
20317            }
20318
20319            if ($('#download-product').is(":checked") == true) productState = 'download';
20320            if ($('#normal-product').is(":checked") == true) productState = 'normal';
20321            if ($('#etc-product').is(":checked") == true) {
20322                productState = 'etc';
20323                etcDateState = $('#etc-date-state').val();
20324                if (etcDateState == 'Y' || etcDateState == 'T') {
20325                    etcDateStatus = $('#etc-date-status').val();
20326                    etcDateWeek = $('#etc-week').val();
20327                    startDate = $('#etc-start-date').val();
20328                    endDate = $('#etc-end-date').val();
20329                    exceptDate = $('#etc-exclude-date').val();
20330                    termData = $('#etc-term').val();
20331                    timeData = $('#etc-time').val();
20332                    
20333                    // var checkStartDate = startDate.split('.');
20334                    // var checkEndDate = endDate.split('.');
20335                    // var checkStart = new Date(checkStartDate[0], (checkStartDate[1] * 1) - 1, checkStartDate[2]);
20336                    // var checkEnd = new Date(checkEndDate[0], (checkEndDate[1] * 1) - 1, checkEndDate[2]);
20337                    // if (checkStart.getTime() > checkEnd.getTime()) {
20338                    //     alert('시작일이 종료일보다 큽니다.');
20339                    //     return false;
20340                    // }
20341                    if($('input.select-terms:checked').val() == 'Y' && (!startDate || !endDate)) {
20342                        alert('날짜 기간을 선택해주세요.');
20343                        return false;
20344                    }
20345                }
20346
20347                etcDate = etcDateState+'||'+etcDateStatus+'||'+etcDateWeek+'||'+startDate+'||'+endDate;
20348                etcDate += (dayCheckLan)? '||' + dayCheckLan : '||';
20349                etcDate += (exceptDate)? '||' + exceptDate : '||';
20350                etcDate += (termData)? '||' + termData : '||';
20351                etcDate += (timeData)? '||' + timeData : '||';
20352            }
20353            // 빈 갤러리 처리
20354            if(pid == '-1') {
20355                $('.choose-gallery').parent().addClass('empty');
20356                submit = false;                
20357            } else $('.choose-gallery').parent().removeClass('empty');
20358
20359            if($img.find('.preview-img').length == 0) {
20360                $img.addClass('empty');
20361                submit = false;
20362            } else $img.removeClass('.empty');
20363
20364            if(!$title.val().trim()) {
20365                $title.focus().parents('.form-wrap').addClass('empty');
20366                submit = false;
20367            } else $title.parents('.form-wrap').removeClass('empty');
20368            if(!$price.val().trim()) {
20369                $price.focus().parents('.form-wrap').addClass('empty');
20370                submit = false;
20371            } else $price.parents('.form-wrap').removeClass('empty');
20372
20373            var item_quantity = (typeof $quantity.val() == 'undefined') ? 0 : parseInt($quantity.val().trim().replace(/\,/g, ''), 10),
20374                item_price = ($price.val().trim()) ? parseInt($price.val().trim().replace(/\,/g, ''), 10) : 0;
20375            if(item_quantity > 9999) {
20376                alert('최대 입력 수량은 9,999 입니다.');
20377                item_quantity = 9999;
20378                $quantity.val(addCommas('9999')).parents('.form-wrap').removeClass('empty');
20379            }
20380            if(item_price > 1000000000) {
20381                $price.focus().parents('.form-wrap').addClass('empty');
20382                alert('최대상품가격은 10억입니다');
20383                return false;
20384            }
20385
20386            if($('#prod-sale-check').is(':checked') && discountRate == 0) {
20387                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>\
20388                1 이상 입력해 주세요.';
20389                $('.form-group.discount-append + .error-msg').remove();
20390                $('.form-group.discount-append').after('<div class="error-msg c-red">'+error_str+'</div>');
20391                $('#prod-discount-rate').addClass('empty');
20392                submit = false;
20393            } else {
20394                $('.form-group.discount-append + .error-msg').remove();
20395                $('#prod-discount-rate').removeClass('empty');
20396            }
20397
20398            // if(!empty(seq)) {
20399            //     if($('#grade-sale-check').is(':checked')) {
20400            //         $.post('/template/gallery/grade', { s: seq, view: visible, mode: 'ON' }, function (data) {
20401            //             checkError(data);
20402            //         },'json');
20403            //     } else {
20404            //         $.post('/template/gallery/grade', { s: seq, view: visible, mode: 'OFF' }, function (data) {
20405            //             checkError(data);
20406            //         },'json');
20407            //     }
20408            // }
20409
20410            $('.unit-pricing').removeClass('empty');
20411            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) {
20412                $('.unit-pricing').addClass('empty');
20413                $('.unit-pricing').find('input').filter(function() { return $.trim(this.value) == '' || $.trim(this.value) == '0'})[0].focus();
20414                return false;
20415            }
20416
20417            var delivery_template_weight = $('input[name="delivery_template_seq"]:checked').parent().data('weight');
20418            var product_weight = $.trim($('#product_weight').val()).replace(/kg/gi, '');
20419            if((lux_product || $('#normal-product').is(":checked") == true) && delivery_template_weight == true && (product_weight == '' || product_weight == 0)) {
20420                $('#product_weight').closest('.form-wrap.product-weight').addClass('empty');
20421                alert('상품 무게를 입력해 주세요.');
20422                return false;
20423            } else {
20424                $('#product_weight').closest('.form-wrap.product-weight').removeClass('empty');
20425            }
20426
20427            var emptyval ='\
20428                <div class="value-empty">\
20429                    <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>필수 입력 항목 입니다.\
20430                </div>\
20431            ';
20432
20433            if(product_info_on=='on') {
20434                if(prod_info.cate_null) {
20435                    $('.prod-info-notice').addClass('empty');
20436                    return false;
20437                }
20438                if(prod_info.input_empty) {
20439                    $('.value-empty').remove();
20440                    $('.prod-info-notice').css('border','3px solid #ee445f');
20441                    var offset_idx = 0;                    
20442
20443                    $.each(prod_null, function(i,v) {
20444                        $('.prod-input-value:eq(' + v + ')').parent('div').append(emptyval);
20445                        if(i==0) offset_idx = v;
20446                    });
20447                    prod_null.offset_idx = offset_idx;
20448                    var input_height = $('.prod-input-value:eq(' + prod_null.offset_idx + ')').offset().top;
20449                    if($('.prod.empty').length==0) $('.prod-modal').animate({ scrollTop: input_height*0.8 }, 500, 'easeInOutQuart');
20450                    return false;
20451                }
20452            }
20453
20454            if(productState != 'normal') npay_button = 'N';
20455
20456            if(mng_product_info_use=='on') {
20457                $('.value-empty').remove();
20458                $('.mng-prd-info-toggle').removeClass('err');
20459                if(mng_product_code.trim()=='') {
20460                    var mng_prd_empty_val = (mng_product_name.trim()=='') ? 'name' : 'code';
20461                    if (mng_product_code.trim()=='') $('.form-mng-prd-code').after(emptyval);
20462                    $('.mng-prd-info-toggle').addClass('err');
20463                    
20464                    return false;
20465                }
20466            }
20467            
20468            if(lux_product) {
20469                if(!$('.prod-type.active').length) {
20470                    alert('상품유형을 선택해주세요.');
20471                    return false;
20472                }
20473
20474                if(!$('#lux-category-text').find('ul').length) {
20475                    alert('카테고리를 하나 이상 추가해주세요.');
20476                    return false;
20477                }
20478
20479                var selected_brand = $('.prod-input.prod-brand').val();
20480                if(selected_brand == '') {
20481                    alert('브랜드를 검색 후 항목에서 선택해주세요.');
20482                    $('#brand').focus();
20483                    return false;
20484                }
20485
20486                var brand_check = brand_list.indexOf(selected_brand) > -1 ? true : false;
20487
20488                if(!brand_check) {
20489                    alert('브랜드 목록에 없는 브랜드명입니다.\n브랜드를 검색 후 목록에서 선택해주세요.');
20490                    $('#brand').focus();
20491                    return false;
20492                }
20493            }
20494
20495            if($('.prod-option-list > li').hasClass('err') == true) {
20496                alert('옵션 항목을 모두 작성해주세요.')
20497                return false;
20498            }
20499
20500            var options = $('.prod-option-list > li').map(function(i,v) {
20501                if($(this).find('.prod-option-title').text().trim()) {
20502                    var quantity = $(this).find('.prod-option-quantity').text().trim(),
20503                        status = $(this).find('.option-price-status-str').attr('data-val'),
20504                        type = '';
20505                    if ($(this).closest('.prod-option').data('option_mode') == 'additional') type = 'A';
20506                    else if ($(this).closest('.prod-option').data('option_mode') == 'text') type = 'T';
20507                    
20508                    if(quantity == '') quantity = '0';
20509                    if(quantity == '0' && quantity_on == 'on') status = 'O'; 
20510
20511                    var fileUrl = [],
20512                        fileSize = [],
20513                        fileStrName = [],
20514                        fileName = [];
20515
20516                    var fileUrlCheck = $(this).find('.file-url'),
20517                        fileSizeCheck = $(this).find('.file-size'),
20518                        fileStrNameCheck = $(this).find('.file-name-detail'),
20519                        fileNameCheck = $(this).find('.real-file-name');
20520
20521                    if (fileUrlCheck.length > 0) $(this).find('.file-url').each(function () { fileUrl.push($(this).text()); });
20522                    else fileUrl.push('');
20523                    if (fileUrlCheck.length > 0) $(this).find('.file-size').each(function () { fileSize.push($(this).text()); });
20524                    else fileUrl.push('');
20525                    if (fileUrlCheck.length > 0) $(this).find('.file-name-detail').each(function () { fileStrName.push($(this).text()); });
20526                    else fileUrl.push('');
20527                    if (fileUrlCheck.length > 0) $(this).find('.real-file-name').each(function () { fileName.push($(this).text()); });
20528                    else fileUrl.push('');
20529
20530                    var strFileUrl = fileUrl.join('||'),
20531                        strFileSize = fileSize.join('||'),
20532                        strFileStrName = fileStrName.join('||'),
20533                        strFileName = fileName.join('||');
20534
20535                    if(type == 'T' || type == 'A') {
20536                        strFileStrName = "";
20537                        strFileSize = "";
20538                        strFileName = "";
20539                        strFileUrl="";
20540                    }
20541
20542                    var optionTitle = '';
20543                    if(product_options.advanced == 'true') {
20544                        if(i == 0 || type == 'T') {
20545                            optionTitle = $(this).find('.prod-option-title').text().trim();
20546                        } else {
20547                            var $val = $(this).find('.prod-option-title > label.owidth');
20548                            optionTitle = $val.map(function() {
20549                                return $(this).text();
20550                            }).get().join(' / ');
20551
20552                        }
20553                    } else {
20554                        optionTitle = $(this).find('.prod-option-title').text().trim();
20555                    }
20556
20557                    var optionPrice = (type != 'T')? $(this).find('.prod-option-price').attr('data-option-price').trim() : 0;
20558                    var optionGroup = '', m2 = '', m3 = '';
20559                    var arrTitle = optionTitle.split(" / ");
20560                    switch(arrTitle.length) {
20561                        case 1: optionTitle = arrTitle[0]; break;
20562                        case 2: optionTitle = arrTitle[1]; m2 = arrTitle[0]; break;
20563                        case 3: optionTitle = arrTitle[2]; m2 = arrTitle[0]; m3 = arrTitle[1]; break;
20564                    }
20565
20566                    if(type == 'T') {
20567                        status = 'S';
20568                        type = 'T';
20569                        optionPrice = "0";
20570                    } else if(type == 'A') {
20571                        optionGroup = m2;
20572                        m2 = '';
20573                    } else if(type == '') {
20574                        if(product_options.type == "1") {
20575                            optionGroup = m2;
20576                            m2 = "";
20577                        }
20578                    }
20579                    // if(product_options.advanced == false && optionTitle != 'noneOption') {
20580                    //     switch(type) {
20581                    //         case ""  : product_options.config1[0].title = '옵션선택'; break;
20582                    //         case "A" : product_options.config3[0].title = '추가옵션'; break;
20583                    //     }                        
20584                    // }
20585                    return { 
20586                        s : $(this).find('.prod-option-title').attr('data-seq'),
20587                        m2 : m2,
20588                        m3 : m3,
20589                        o : optionTitle, 
20590                        v : optionPrice,
20591                        fn : strFileName,
20592                        fdn : strFileStrName,
20593                        fs : strFileSize,
20594                        fu : strFileUrl,
20595                        q : quantity,
20596                        t : status,
20597                        g : optionGroup,
20598                        a : i,
20599                        ty: type
20600                    }
20601                 }
20602            }).get();
20603
20604            var options_changed = true;
20605            if(seq && !lux_product && productState == 'normal' && before_prod.option_list && !delete_options) {
20606                try {
20607                    var before_options = JSON.parse(before_prod.option_list);
20608                    options_changed = (Object.keys(before_options).length != options.length);
20609
20610                    if(!options_changed) {
20611                        $.each(options, function(i, option) {
20612                            var before_option = before_options[option.s];
20613                            if(
20614                                !before_option
20615                                || option.fn || option.fdn || option.fs || String(option.fu || '').replace(/\|/g, '')
20616                                || String(before_option.option_mix2 || '') != String(option.m2 || '')
20617                                || String(before_option.option_mix3 || '') != String(option.m3 || '')
20618                                || String(before_option.option_group || '') != String(option.g || '')
20619                                || String(before_option.option_name || '') != String(option.o || '')
20620                                || Number(before_option.option_price || 0) != Number(option.v || 0
20620)
20621                                || Number(before_option.option_quantity || 0) != Number(removeCommas(option.q || 0))
20622                                || String(before_option.option_status || '') != String(option.t || '')
20623                                || String(before_option.option_type || '') != String(option.ty || '')
20624                                || Number(before_option.idx || 0) != Number(option.a || 0)
20625                            ) {
20626                                options_changed = true;
20627                                return false;
20628                            }
20629                        });
20630                    }
20631
20632                    if(!options_changed) {
20633                        var before_options_config = JSON.parse(before_prod.option_settings || '{}');
20634                        options_changed = (
20635                            JSON.stringify(before_options_config) != JSON.stringify(product_options)
20636                            || String(before_prod.option_normal) != String($('#normal-option').is(':checked'))
20637                            || String(before_prod.option_text) != String($('#text-option').is(':checked'))
20638                            || String(before_prod.option_additional) != String($('#additional-option').is(':checked'))
20639                        );
20640                    }
20641                } catch(e) {
20642                    options_changed = true;
20643                }
20644            }
20645
20646            if(options.length==0 && $('.prod-option-tab .prod-option.hide').length < 3) {
20647                $('.prod-option-add').addClass('empty');
20648                submit = false;
20649            }
20650
20651            var optionsAry = options_changed ? division(options, 300) : [[]];
20652            // console.log(optionsAry);
20653            var price1 = removeCommas($price.val().trim()), //할인가
20654                price2 = removeCommas($sale.text().trim()); //정가
20655
20656            if($sale.css('display') == 'none') {
20657                $sale.text('');
20658                price2 = 0;
20659            }
20660            
20661            if(lux_product == false) {
20662                if($('#prod-sale-check').is(':checked') && (parseInt(price1) - parseInt(price2) >= 0)) {
20663                // alert('할인 가격은 정가보다 높거나 동일할 수 없습니다');
20664                    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() {
20665                        $(document).on('keydown', function(e) {
20666                            if(e.keyCode == 27) modal.modal('hide');
20667                        });
20668                    });
20669                    if(price2 == 0) $price.val('');
20670                    submit = false;
20671                    return;
20672                }
20673            } else {
20674                if($('#prod-sale-check').is(':checked') && (parseInt(price1) - parseInt(price2) > 0)) {
20675                    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() {
20676                        $(document).on('keydown', function(e) {
20677                            if(e.keyCode == 27) modal.modal('hide');
20678                        });
20679                    });
20680                    if(price2 == 0) $price.val('');
20681                    submit = false;
20682                    return;
20683                }
20684            }
20685/*
20686            if(nPrice > 0 && nPrice < 10) {
20687                $('#prod-price').focus();
20688                $('.prod-item-price1').addClass('err')
20689                // alert('상품 가격을 10원 이상 입력해주세요.');
20690                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() {
20691                    $(document).on('keydown', function(e) {
20692                        if(e.keyCode == 27) modal.modal('hide');
20693                    });
20694                });
20695                submit = false;
20696            } else {
20697                $('.prod-item-price1').removeClass('err');
20698            }
20699*/
20700            var imgs = [];
20701            if(submit) {
20702                $('.prod-item-thumb li').each(function(i,v) {
20703                    var s = $(this).find('img:not(.guide-img)').attr('src');
20704                    if($(this).hasClass('prod-item-image-add')) return true;
20705                    imgs.push(s);
20706                });
20707
20708                
20709                $.processON('상품을 등록중입니다...');
20710                
20711                var func = new Array();
20712                func[0] = true;
20713                func[1] = $('#review-checkbox').is(":checked"); // 리뷰사용
20714                func[2] = $('#qna-checkbox').is(":checked"); // QNA 사용
20715                func[3] = $('#photo-review').is(":checked"); // 상단 포토리뷰 표시
20716                 
20717                func[4] = ($('#normal-option').is(':checked'))? true : false; //일반옵션 활성화
20718                func[5] = ($('#text-option').is(':checked'))? true : false; //입력옵션 활성화
20719                func[6] = ($('#additional-option').is(':checked'))? true : false; //추가옵션 활성화
20720
20721                var useReviewImgUpload = $('#use-review-img-upload').is(":checked"); // 후기 사진업로드 사용여부
20722                
20723                var cate = ($category.text().trim()) ? $category.text().trim().split(',') : '',
20724                    brand = ($brand.val().trim())? $brand.val().trim():'',
20725                    //재고수량
20726                    quantity_val = (func[4] == 'true' || func[6] == 'true')? 0 : item_quantity,
20727                    options_config = $.extend(true, {}, product_options);
20728
20729                delete options_config.options1;
20730                delete options_config.options2;
20731                delete options_config.options3;
20732
20733                var prod_user_margin = (typeof $('.prod-user-margin').val() == 'undefined') ? 0 : $('.prod-user-margin').val().trim(),
20734                    prod_user_price = (typeof $('.prod-user-price').val() == 'undefined') ? 0 : $('.prod-user-price').val().trim(),
20735                    prod_price_sync = ($('.prod-price-sync').hasClass('active')) ? 'T' : 'F',
20736                    prod_status = $('.prod-status.active').attr('data-val'),
20737                    prod_type = $('.prod-type.active').attr('data-val'),
20738                    prod_brand = $('.prod-brand').val(),
20739                    prod_category = [];
20740                
20741                if(lux_product) {
20742                    if(seq < 1 || seq >= 1000000000) {
20743                        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) {
20744                            prod_status = 'F';
20745                        } 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) {
20746                            prod_status = 'F';
20747                        }
20748                        var invenCheck = false;
20749                        
20750                        $.each(optionsAry[0], function(idx, v) {
20751                            if(prod_status != 'T' || (idx > 0 && v.t != 'O')) {
20752                                invenCheck = true;
20753                            }
20754                        });
20755
20756                        if(!invenCheck) prod_status = 'F';
20757                    }
20758                }
20759
20760                if($('#lux-category-text').length) {
20761                    $.each($('#lux-category-text ul'),function(i,v) { 
20762                        prod_category[i] = {
20763                          'sid' : $(this).attr('data-sid'),
20764                          'no' : $(this).attr('data-no'),
20765                          'category' : [],
20766                          'category_name' : [],
20767                          'update' : []
20768                        }
20769                        $.each($(this).find('li'),function(a,b) {
20770                            prod_category[i]['category'].push($(this).attr('data-category-no'));
20771                            var seq = (typeof $(this).attr('data-seq') != 'undefined' && $(this).attr('data-seq') != '') ? $(this).attr('data-seq') : '';
20772                            prod_category[i]['update'].push(seq);
20773                            prod_category[i]['category_name'].push($(this).text().trim());
20774                        });
20775                    });
20776                }
20777
20778                setTimeout(function() {
20779                    var optionRequestCompleteCount = 0;
20780                    for (var optionCnt=0;optionCnt<optionsAry.length;
20780optionCnt++) {
20781                        var prod = {
20782                            'seq' : seq,
20783                            'page' : page,
20784                            'pid' : pid,
20785                            'gpos'  : gpos,
20786                            's_grade' : s_grade,
20787                            'title' : $title.val().trim(),
20788                            'price' : $price.val().trim(),
20789                            'sale' : $sale.text().trim(),
20790                            'discount_rate' : discountRate,
20791                            'discount_unit' : discountUnit,
20792                            // 'check_sale_cut' : checkSaleCut,
20793                            'product_on' : product_on,
20794                            'product_info_on' : product_info_on,
20795                            'mng_product_info_use' : mng_product_info_use,
20796                            'mng_product_name' : mng_product_name,
20797                            'mng_product_code' : mng_product_code,
20798                            'quantity' : quantity_val,
20799                            'quantity_on' : quantity_on,
20800                            'desc' : $desc.val().trim(),
20801                            'category' : cate,
20802                            'category_on' : category_on,
20803                            'brand' : brand,
20804                            'imgs' : imgs,
20805                            'func' : func,
20806                            'product_state' : productState,
20807                            'tax' : taxState,
20808                            'download_date' : downloadDate,
20809                            'download_count' : downloadCount,
20810                            'etc_data' : etcDate,
20811                            'options' : JSON.stringify(optionsAry[optionCnt]),
20812                            'options_changed' : options_changed ? 'Y' : 'N',
20813                            'prod_info' : prod_info,
20814                            'options_config' : options_changed ? options_config : {},
20815                            'delete_options' : delete_options,
20816                            'before_prod' : JSON.stringify(before_prod),
20817                            'delivery_template_seq' : deliveryTemplateSeq,
20818                            'product_weight' : productWeight,
20819                            'culture_benefit_yn' : culture_benefit_yn,
20820                            'npay_button' : npay_button,
20821                            'lux' : lux_product,
20822                            'prod_user_margin' : prod_user_margin,
20823                            'prod_user_price' : prod_user_price,
20824                            'prod_price_sync' : prod_price_sync,
20825                            'prod_status' : prod_status,
20826                            'prod_type' : prod_type,
20827                            'prod_category' : prod_category,
20828                            'prod_brand' : prod_brand,
20829                            'category_deleted' : ($('#category-deleted').length) ? $('#category-deleted').val() : '',
20830                            'product_pccc_yn' : product_pccc_yn,
20831                            'require_navershop' : require_navershop,
20832                            'sales_start': salesStart,
20833                            'sales_end': salesEnd,
20834                            'open_out_datetime_yn': open_out_datetime_yn,
20835                            'unit_use_yn': unit_use_yn,
20836                            'total_unit_value' : total_unit_value,
20837                            'total_unit' : total_unit,
20838                            'total_unit_bundle' : total_unit_bundle,
20839                            'basic_unit_value' : basic_unit_value,
20840                            'basic_unit' : basic_unit,
20841                            'use_review_img_upload' : useReviewImgUpload
20842                        }
20843
20844                        $.post('/template/products', { sid: SID, type : 'add', s: prod, lux : lux_product }, function (data) {
20845                            // checkError(data);
20846                            if(data.error) {
20847                                $.processOFF();
20848                                if(data.price) $('#prod-price').val('');
20849                                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() {
20850                                    $(document).on('keydown', function(e) {
20851                                        if(e.keyCode == 27) modal.modal('hide');
20852                                    });
20853                                });
20854                                return false;
20855                            }
20856
20857                            optionRequestCompleteCount++;
20858                            // control panel
20859                            if (optionsAry.length == optionRequestCompleteCount) {
20860                                $('img.galleryItemEdit[data-seq="' + data.r.id + '"]').attr('src',data.r.imgs[0].path+'/60/'+data.r.imgs[0].file);
20861                                $('.image-title.galleryItemEdit[data-seq="' + data.r.id + '"]').text(data.r.title);
20862
20863                                PRODINFO = (product_info_on=='on') ? prod_info : '';
20864                                PRODSETTING = 'on';
20865
20866                                    // dashboard
20867                                    if(typeof MODE == 'undefined') {
20868                                        $.processOFF();
20869                                        $.products.close();
20870                                        if($('.gallery-modal').length) {
20871                                            var now_page = getStorageItem('gallery-product-page');
20872                                            $.gallery.show($.gallery.block_id,now_page,$.gallery.category);
20873                                        }
20874
20875                                    } else {
20876                                        if(go) {
20877                                            var block = ($('.el_1').length) ? '.el_1' : '.default_project_contents',
20878                                                menuPage = PAGE.split(',');
20879                                            if(LUX) menuPage[0] = '_product';
20880                                            $.cookie('product-detail', true, { expires: 60*60, path : '/' });
20881                                            location.href = '/'+CONFIG_URL+'config/page/'+menuPage[0]+'/view/'+data.r.id;
20882
20883                                        } else {
20884                                            var $emptyShoppingGallery = $('.element[data-id="' + pid + '"][data-type="gallery"][data-mode="shopping"].emptyGallery');
20885                                            if(seq < 1 && $emptyShoppingGallery.length > 0) {
20886                                                $.cookie('block-add', '.element[data-id="' + pid + '"]', { path: '/' });
20887                                            }
20888                                            showPageCallback(showPage);
20889                                            $.processOFF();
20890                                            $.products.close();
20891                                            if($('.gallery-modal').length) {
20892                                                var now_page = getStorageItem('gallery-product-page');
20893                                                $.gallery.show($.gallery.block_id,now_page,$.gallery.category);
20894                                            }
20895                                        }
20896                                    }
20897                            }
20898                        }, 'json').fail(function() {
20899                            $.processOFF();
20900                            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() {
20901                                $(document).on('keydown', function(e) {
20902                                    if(e.keyCode == 27) modal.modal('hide');
20903                                });
20904                            });
20905                        });
20906                    }
20907                });
20908            }
20909        },
20910        display_info : function() {
20911            var prodObj = (typeof property == "undefined") ? PRODINFO : property.PRODINFO;
20912            var s = '\
20913            <div class="cl-s-product-info-notice element el_000">\
20914                <div class="container">\
20915                <span class="prod-info-notice">상품정보 제공고시</span>\
20916                <table>\
20917                    <colgroup>\
20918                        <col width="">\
20919                        <col width="*">\
20920                    </colgroup>\
20921                    <tbody>\
20922            ';
20923
20924            $.each(prodObj.content, function(i,v) {
20925                s = s + '\
20926                    <tr>\
20927                        <td class="prod-info-title">' + v.title + '</td>\
20928                        <td>' + v.content + '</td>\
20929                    </tr>\
20930                    ';
20931            });
20932            s = s + '\
20933                    </tbody>\
20934                </table>\
20935                </div>\
20936            </div>\
20937            ';
20938
20939            if(typeof property == "undefined") {
20940                $lastEl = ($('.el-footer_ctrl').length) ? $('.el-footer_ctrl') : $('.add-footer-information');
20941                if($('.page-bottomlist').length) $lastEl = $('.page-bottomlist');
20942                if($('.fnav').length) $lastEl = $('.fnav');
20943                $lastEl.before(s);
20944            } else {
20945                if($('.el-footer').length) {
20946                    $lastEl = ($('.page-bottomlist').length) ? $('.page-bottomlist') : $('.el-footer');
20947                    if($('.fnav').length) $lastEl = $('.fnav');
20948                    $lastEl.before(s);
20949                } else {
20950                    $('.dsgn-body').append($s);
20951                }
20952            }
20953        },
20954        close : function() {
20955            var parentDocument = $(window.parent.document),
20956                $detail_modal = parentDocument.find('.product-detail-modal');
20957            if($detail_modal.length) $detail_modal.removeClass('overlap');
20958
20959            if($('.prod-modal').length) {
20960                $('.prod-modal').fadeOut(300, function() {
20961                    $(this).remove();
20962                });
20963            }
20964        }
20965    }
20966
20967    var clicking = false;
20968    $.gallery = {
20969        mode : '',
20970        SMENU : '',
20971        SFOLDER : '',
20972        valid_plan : '',
20973        valid_type : '',
20974        service : '',
20975        one : '',
20976        block_id : '',
20977        block_name : '',
20978        block_el : '',
20979        blocks : [],
20980        pages : [],
20981        seqs : [],
20982        copy : [],
20983        move : [],
20984        delete : [],
20985        ex_id : [],
20986        view_item : 30,
20987        update : false,
20988        unlink : false,
20989        category : '',
20990        cates : '',
20991        drag : '',
20992        last : '',
20993        site_settings : '',
20994        item_of_page : '',
20995        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>',
20996        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>',
20997        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>',
20998        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>',
20999        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>',
21000        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>',
21001        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>',
21002        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개 이하
21002입니다"><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>',
21003        reset : function() { $.gallery.move = []; $.gallery.copy = []; $.gallery.seqs = []; },
21004        init : function() {
21005            var clearLocalStorage = function() {
21006                window.localStorage.removeItem('gallery-product-page');
21007                window.localStorage.removeItem('gallery-product-name');
21008                window.localStorage.removeItem('gallery-product-filter');
21009                window.localStorage.removeItem('gallery-product-sort');
21010                window.localStorage.removeItem('gallery-product-by');
21011            }
21012            clearLocalStorage();
21013            var galleryMoveItem = function(block_id,seq,page,callback) {
21014                if(CANCEL) return true;
21015                var seqs = [];
21016                seqs.push(seq);
21017                $.ajax({
21018                    url: '/template/gallery/move',
21019                    data: { s: seqs, sid : SID, page : page, block_id : block_id },
21020                    dataType: 'json',
21021                    type: 'POST',
21022                    async: true,
21023                    cache: false,
21024                    success: function(data) {
21025                        checkError(data);
21026                        if(typeof callback == 'function') {
21027                            callback();
21028                        }
21029                    }
21030                });
21031            }
21032            var reloadItems = function(items) {
21033
21034            }
21035            var updateItem = function(item) {
21036            
21037            }
21038            var getSearchProduct = function(product_name) {
21039                if(typeof product_name == 'undefined' || (product_name.length > 0 && product_name.length < 2)) {
21040                    alert('최소 2자이상 검색어를 입력하세요');
21041                    $('.gallery-list-search-text').focus();
21042                    return false;
21043                }
21044                window.localStorage.setItem('gallery-product-name',product_name);
21045                $.gallery.show($.gallery.block_id,1,$.gallery.category);
21046            }
21047            var setQuantity = function(seqs) {
21048                if(typeof seqs == 'undefined') {
21049                    var product_number_arr = $('[name="item_check[]"]:checked').map(function() { return $(this).closest('.table-item').attr('data-seq'); }).toArray();    
21050                } else {
21051                    var product_number_arr = seqs;
21052                }
21053                var route = (CONFIG_URL) ? '/_admin' : '';
21054                $.ajax({
21055                    url: route + '/shopping/stock_use_check',
21056                    type:'post',
21057                    dataType:'json',
21058                    async: true,
21059                    data:{
21060                        'sid' : SID,
21061                        'product_number' : product_number_arr
21062                    },
21063                    success:function(data) {
21064                        var valid_data = data.filter(function(v){ if(v.product_quantity_on == 'on') return v; });
21065                        var invalid_data = data.filter(function(v){ if(v.product_quantity_on != 'on') return v; });
21066                        if(valid_data.length > 0 && valid_data.length <= product_number_arr.length) {
21067                            var invalid_products = invalid_data.map(function(v) { return v.title; }).join('<br>');
21068                            var showProductList = function() {
21069                                $.ajax({
21070                                    url: route + '/shopping/batch_stock_list',
21071                                    type:'post',
21072                                    dataType:'html',
21073                                    data: {
21074                                        'sid' : SID,
21075                                        'product_number' : valid_data.map(function(v) { return v.product_number; })
21076                                    },
21077                                    success:function(data) {
21078                                        var modal = $(this).showModalFlat($.lang[LANG]['editor.block.gallery.product.stock'] + $.lang[LANG]['editor.block.gallery.product.price'], data, false, true, function() { //confirm
21079
21080                                            var dataSet = [];
21081
21082                                            modal.find('.setting_product_list [data-product_number]').each(function() {
21083                                                var product_number = $(this).attr('data-product_number');
21084                                                var option_seq = $(this).attr('data-option_seq');
21085                                                var pre_quantity = Number(removeC
21085ommas($(this).find('.input-stock[data-quantity]').attr('data-pre_quantity')));
21086                                                var quantity = Number(removeCommas($(this).find('.input-stock[data-quantity]').attr('data-quantity')));
21087                                                var option_status = $(this).find('.input-stock[data-quantity]').attr('data-option_status');
21088                                                var product_name = $(this).find('.product_title').text();
21089                                                var option_name = $(this).find('.option_name').text();
21090                                                var option_value = $(this).find('.option_value').text();
21091                                                var option_type = $(this).find('.input-stock[data-quantity]').attr('data-option_type');
21092
21093                                                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 };
21094                                                dataSet.push(arr);
21095                                            });
21096
21097                                            $.ajax({
21098                                                url : route + '/shopping/batch_stock_set',
21099                                                type:'post',
21100                                                dataType:'json',
21101                                                data: {
21102                                                    'sid' : SID,
21103                                                    'datalist' : dataSet
21104                                                },
21105                                                success: function(data) {
21106                                                    // if(data.result == true) $.gallery.show($.gallery.block_id);
21107                                                }, error: function() {
21108
21109                                                }, complete: function() {
21110                                                    // showPageCallback(showPage)
21111                                                    var page = getStorageItem('gallery-product-page');
21112                                                    $.gallery.show($.gallery.block_id,page,$.gallery.category);
21113                                                }
21114                                            });
21115
21116                                            modal.modal('hide');
21117                                        } ,'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
21118                                        }, function(){ //hide
21119                                        },true);
21120                                    }
21121                                });
21122
21123                            };
21124                            if(!invalid_products) {
21125                                showProductList();
21126                                return false;
21127                            }
21128
21129                            $(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() {
21130                                // ok callback
21131                                // showProductList();
21132                            }, 'ok', '', 'cl-cmmodal cl-s-btn w700 cl-p70 cl-t80 cl-close-btn cover cover-inner-scroll', false, function() {
21133                                // close callback
21134                                // showProductList();
21135                            }, function() {
21136                                // show callback
21137                            }, function() {
21138                                // hide callback
21139                                showProductList();
21140                            });
21141                        } else if(valid_data.length == 0) {
21142                            var modal = $(this).showModalFlat('안내', '<div>재고 일괄 관리는 상품정보 <span style="color:#4789e7;">설정페이지 &gt; 재고관리 옵션</span>이<br><span style="color:#4789e7;">사용</span>으로 설정된 상품만 가능합니다.</div>', true, false, function() {
21143                                // ok callback
21144                                modal.modal('hide');
21145                            }, 'ok', '', 'cl-cmmodal cl-s-btn w700 cl-p70 cl-t80 cl-close-btn', false, function() {
21146                                // close callback
21147                            }, function() {
21148                                // show callback
21149                            }, function() {
21150                                // hide callback
21151                            });
21152                        }
21153                    }
21154                });
21155            }
21156            var checkUserEdit = function(v,type) {
21157                console.log(v,type);
21158                switch(type) {
21159                    case 'sale':
21160                        if(!isNaN(parseFloat(v)) && isFinite(v) && parseFloat(v) >= 0 && parseFloat(v) <= 1000000000) return true;
21161                        break;
21162                    case 'org':
21163                        if(!isNaN(parseFloat(v)) && isFinite(v) && parseFloat(v) >= 0 && parseFloat(v) <= 1000000000) return true;
21164                        break;
21165                    case 'disc':
21166                        if(!isNaN(parseFloat(v)) && isFinite(v) && parseFloat(v) <= 100) return true;
21167                        break;
21168                    case 'quantity':
21169                        if(!isNaN(parseFloat(v)) && isFinite(v) && parseFloat(v) < 10000) return true;
21170                        break;
21171                    default: return false;
21172                }
21173
21174                return false;
21175            }
21176            var getEditType = function($o) {
21177                var type = '';
21178                if($o.parent().hasClass('td-orig-price')) type = 'org';
21179                if($o.parent().hasClass('td-price')) type = 'sale';
21180                if($o.parent().hasClass('td-discount')) type = 'disc';
21181                if($o.parent().hasClass('td-quantity')) type = 'quantity';
21182                if(type == '') {
21183                    alert('Invalid type');
21184                    return false;
21185                }
21186                return type;
21187            }
21188            $(document).on('click','.gallery-modal .gallery-block-select', function(e) {
21189                $('.gallery-modal .gallery-blocks.mobile').toggle();
21190            })
21191            $(document).on('click','.item-header .product-sort, .table-toolbar li .product-sort',function(e) {
21192                var sort = $(this).attr('data-sort'),
21193                    by = $(this).attr('data-by');
21194
21195                if(by == '') by = 'desc';
21196                else {
21197                    by = (by == 'desc') ? 'asc' : 'desc';
21198                }
21199                window.localStorage.setItem('gallery-product-sort',sort);
21200                window.localStorage.setItem('gallery-product-by',by);
21201                $.gallery.show($.gallery.block_id,1,$.gallery.category);
21202            });
21203            $(document).on('click','.item-header .product-sort-checked, .table-toolbar li .product-sort-checked',function(e) {
21204                window.localStorage.removeItem('gallery-product-sort');
21205                window.localStorage.removeItem('gallery-product-by');
21206                $.gallery.show($.gallery.block_id,1,$.gallery.category);
21207            });
21208            $(document).on('click','.gallery-blocks .all-items', function(e) {
21209                clearLocalStorage();
21210                $.gallery.show('',1);
21211            });
21212            $(document).on('click','.table-item .td-status', function(e) {
21213                var is_product = $(this).parent().attr('data-product');
21214                if(typeof is_product == 'undefined' || is_product == 'false') {
21215                    $(this).showModalFlat($.lang[LANG]["config.information"], '상품 정보를 입력한 후에 이용 가능합니다.<br>상품 설정을 완료해주세요', true, false, '', 'ok','','cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
21216                    return false;
21217                }
21218                e.stopPropagation();
21219                if($(this).hasClass('open')) {
21220                    $(this).removeClass('open').find('.table-item-status').hide();
21221                    return false;
21222                }
21223                $(this).toggleClass('open');
21224                $('.table-item-status').hide();
21225                var $status = $(this).find('.table-item-status');
21226                ($(this).hasClass('open')) ? $status.show() : $status.hide().removeClass('open');
21227            });
21228            $(document).on('click','.table-item .table-item-status li', function(e) {
21229                e.preventDefault();
21230                var product_number = $(this).parent().attr('data-seq'),
21231                    status = $(this).attr('data-val');
21232                $(this).parent().find('li').removeClass('active');
21233                $(this).addClass('active');
21234
21235                $.processON();
21236                var route = (CONFIG_URL) ? '/_admin' : '';
21237                $.ajax({
21238                    url: route + '/shopping/setProductStatus',
21239                    type: 'post',
21240                    data: { sid : SID, product_number : product_number, status : status },
21241                    async: true,
21242                    cache: false,
21243                    dataType: 'json',
21244                    success: function(data) {
21245                        $.processOFF();
21246                        if(typeof data.error != 'undefined' && data.error) {
21247                            $p.find('.prev-value').text(t);
21248                            alert(data.error);
21249                            return false;
21250                        }
21251                        var page = getStorageItem('gallery-product-page');
21252                        $.gallery.show($.gallery.block_id,page,$.gallery.category);
21253                        $.gallery.update = true;
21254                        $.gallery.reset();
21255                    },
21256                    error: function(request,status,error) {
21257                        $.processOFF();
21258                        alert('code:'+request.status+'\n'+'message:'+request.responseText+'\n'+'error:'+error);
21259                        return false;
21260                    }
21261                });
21262            });
21263            $(document).on('keyup','.gallery-list-search-text', function(e) {
21264                var product_name = $(this).val().trim();
21265                // if(product_name.length == 0) return false;
21266                if(e.key === 'Enter') {
21267                    getSearchProduct(product_name);
21268                }
21269            });
21270            $(document).on('click','.gallery-list-search-submit', function(e) {
21271                var product_name = $('.gallery-list-search-text').val().trim();
21272                // if(product_name.length == 0) return false;
21273                getSearchProduct(product_name);
21274            });
21275            $(document).on('click','.gallery-list-search-cancel',function(e) {
21276                // $(this).hide();
21277                $('.gallery-list-search-submit').show();
21278                $('.gallery-list-search-text').val('');
21279                window.localStorage.removeItem('gallery-product-name');
21280                $.gallery.show($.gallery.block_id,1,$.gallery.category);
21281            });
21282            $(document).on('click','.gallery-list-filter ul li', function(e) {
21283                $('.gallery-list-filter ul li').removeClass('active');
21284                $(this).addClass('active');
21285                var filter = $(this).attr('data-val');
21286                window.localStorage.setItem('gallery-product-filter',filter);
21287                $.gallery.show($.gallery.block_id,1,$.gallery.category);
21288            });
21289            var isClose = false;
21290            $(document).on('click','.table-item .edit-button',function(e) {
21291                isClose = false;
21292                if($(this).hasClass('conf')) {
21293                    var $parent = $(this).parents('.table-item'),
21294                        seq = $parent.attr('data-seq'),
21295                        seqs = [seq];
21296                    setQuantity(seqs);
21297                    return false;
21298                }
21299                var s = $(this).parent().find('.prev-value').text(),
21300                    type = getEditType($(this));
21301                $('#user-edit').remove();
21302                $('.close-button').hide();
21303                $(this).parents('.table-item').find('.edit-button').show();
21304                $(this).hide();
21305                if($(this).parent().find('input').length == 0) {
21306                    $(this).parent().append('<input type="text" class="' + type + '" id="user-edit" value="' + s + '" numberOnly>');
21307                    $('#user-edit').focus();
21308                    $(this).parent().find('.close-button').show();
21309                    $('.edit-button').hide();
21310                }
21311            });
21312            $(document).on('mousedown','.close-button',function(e) {
21313                e.preventDefault();
21314            });
21315            $(document).on('click','.close-button', function(e) { 
21316                var s = $(this).attr('data-val'),
21317                    $this = $(this);
21318                isClose = true;
21319                $(this).removeClass('err not').hide();
21320                $(this).parent().find('.prev-value').text(s);
21321                $(this).parent().find('input').remove();
21322                $(this).parents('.table-item').find('.edit-button').show();
21323            });
21324            $(document).on('blur','#user-edit',function(e) {
21325                if(isClose) return false;
21326                var s = $(this).val().trim(),
21327                    $p = $(this).parent(),
21328                    $this = $(this),
21329                    type = getEditType($(this)),
21330                    $parent = $this.parents('.table-item'),
21331                    pid = $parent.attr('data-pid'),
21332                    seq = $parent.attr('data-seq'),
21333                    t = $this.parent().find('.prev-value').text(),
21334                    p_orig = $parent.find('.td-orig-price').find('.prev-value').text(),
21335                    p_price = $parent.find('.td-price').find('.prev-value').text(),
21336                    p_discount = $parent.find('.td-discount').find('.prev-value').text(),
21337                    p_quantity = $parent.find('.td-quantity').find('.prev-value').text();
21338
21339                if(type == 'quantity' && Number(uncomma(s)) > 9999) {
21340                    alert('최대 입력 수량은 9,999 입니다.');
21341                    s = addCommas('9999');
21342                    $this.val(s);
21343                }
21344
21345                $this.parents('.table-item').find('.close-button').removeClass('err not');
21346                if(!checkUserEdit(uncomma(s),type) || s.length == 0) {
21347                    $this.parent().find('.close-button').show().addClass('err');
21348                    // setTimeout(function() { $this.focus(); },0);
21349                    return false;
21350                }
21351                var submit = false;
21352                if(type == 'org' || type == 'sale') {
21353                    var orig = (type == 'org') ? parseFloat(uncomma(s)) : parseFloat(uncomma(p_orig)),
21354                        price = (type == 'org') ? parseFloat(uncomma(p_price)) : parseFloat(uncomma(s));
21355                    if(orig < price) {
21356                        $this.parent().find('.close-button').show().addClass('err not');
21357                        // setTimeout(function() { $this.focus(); },0);
21358                        return false;
21359                    }
21360                }
21361
21362                $('.close-button').hide();
21363                $this.parent().find('.close-button').attr('data-val',s).removeClass('err not').hide();
21364                $this.parent().find('.prev-value').text(s); 
21365                $this.parents('.table-item').find('.edit-button').show();
21366                $this.remove();
21367
21368                if(s == t) return false;
21369                $.processON();
21370
21371                var paramData = { sid : SID, pid : pid, seqs : [seq], type : type, mark : 'change', v : s, p : t, fx : 'disc', c : 's'};
21372                if(type == 'quantity') paramData['t'] = $parent.find('.item-title-str').text();
21373                
21374                var route = (CONFIG_URL) ? '/_admin' : '';
21375                $.ajax({
21376                    url: route + '/shopping/setProduct',
21377                    type: 'post',
21378                    data: paramData,
21379                    async: true,
21380                    cache: false,
21381                    dataType: 'json',
21382                    success: function(data) {
21383                        $.processOFF();
21384                        if(typeof data.error != 'undefined' && data.error) {
21385                            $p.find('.prev-value').text(t);
21386                            alert(data.error);
21387                            return false;
21388                        }
21389                        var page = getStorageItem('gallery-product-page');
21390                        $.gallery.show($.gallery.block_id,page,$.gallery.category);
21391                        $.gallery.update = true;
21392                        $.gallery.reset();
21393                        var cmd = '';
21394                        switch(type) {
21395                            case "org":     cmd = "org-price"; break;
21396                            case "sale":    cmd = "sale-price"; break;
21397                            case "disc":    cmd = "disc-price"; break;
21398                        }
21399                        if(cmd) setLogs('ELEM','product.'+cmd +'.modify','modify','ELEM','product-manager','el');
21400                    },
21401                    error: function(request,status,error) {
21402                        $.processOFF();
21403                        alert('code:'+request.status+'\n'+'message:'+request.responseText+'\n'+'error:'+error);
21404                        return false;
21405                    }
21406                });
21407            });
21408            $(document).on('keyup','#user-edit',function(e) {
21409                if(e.key === 'Enter') {
21410                    $(this).parents('.table-item').find('.close-button').removeClass('err not');
21411                    $(this).blur(); 
21412                }
21413            });
21414            $(document).on('click','#section-top-menu .product-manager', function(e) { 
21415                clearLocalStorage();
21416                $.gallery.show('',1);
21417            });
21418            $(window).resize(function(e) { 
21419                if($('.gallery-items').length == 0) return;
21420                shoppingGalleryResize();
21421                // resizeGalleryModal();
21422            });
21423            $(document).on('click','.product-gallery-list-toggle',function(e) {
21424                var $list = $('.product-gallery-list'),
21425                    $category = $('.gallery-category'),
21426                    $more = $('.gallery-items-loadmore'),
21427                    $items = $('.gallery-items'),
21428                    $toggle = $('.product-gallery-list-toggle'),
21429                    $pagination = $('.pagination-wrap'),
21430                    $filter = $('.gallery-list-filter'),
21431                    $name = $('.selected-gallery-name'),
21432                    $lux_filter = $('.shop-filter-header'),
21433                    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>',
21434                    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>';
21435                $toggle.toggleClass('open');
21436                $list.toggleClass('open');
21437                $category.toggleClass('open');
21438                $more.toggleClass('open');
21439                $items.toggleClass('open');
21440                $pagination.toggleClass('open');
21441                $filter.toggleClass('open');
21442                $name.toggleClass('open');
21443                $lux_filter.toggleClass('open');
21444                if($toggle.hasClass('open')) {
21445                    $toggle.html(svg_open);
21446                } else {
21447                    $toggle.html(svg_close);
21448                }
21449
21450                ($('.product-gallery-list-toggle').hasClass('open')) ? 
21451                    window.localStorage.setItem('product-gallery-closed',fal
21451se):
21452                    window.localStorage.setItem('product-gallery-closed',true);
21453            });
21454            $(document).bind('cut', '.gallery-modal', function(e) {
21455                if($('.cl-change-badge-design').length > 0) return;
21456                $.gallery.move = $.gallery.seqs;
21457                $.gallery.seqs = [];
21458                $.each($.gallery.move, function(i,v) {
21459                    $('.gallery-items .item[data-seq="' + v + '"]').removeClass('copy').addClass('move');
21460                    $('.gallery-toolbar.mod-gallery').remove();
21461                });
21462            });
21463            $(document).bind('copy', '.gallery-modal', function(e) {
21464                if($.gallery.block_id == -1 || $('.cl-common-modal').length) return;
21465                if($('.cl-change-badge-design').length > 0) return;
21466                $.gallery.copy = $.gallery.seqs;
21467                $.gallery.seqs = [];
21468                $.each($.gallery.copy, function(i,v) {
21469                    $('.gallery-items .item[data-seq="' + v + '"]').removeClass('move').addClass('copy');
21470                    $('.gallery-toolbar.mod-gallery').remove();
21471
21472                    $('.table-item .td-check input[type="checkbox"]').prop('checked',false); 
21473                    $('.table-item').removeClass('ui-selected return');
21474                    $('.table-toolbar .toolbar-cmd').addClass('hide');
21475                    $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq','');
21476                    $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink','').attr('data-glink-target','');
21477                    $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible','0').text($.lang[LANG]['editor.gallery.icon.visible.off']);
21478                    $('.gallery-toolbar').removeClass('hide_col');
21479                    $('.gallery-toolbar').addClass('hide');
21480                    $('.gallery-items .item-header').removeClass('hide');
21481                    $('.check-all').prop('checked',false);
21482                    $.toast({'title' : ($.gallery.copy).length + '개의 데이터가 복사 되었습니다'});
21483                });
21484            });
21485            $(document).bind('paste', '.gallery-modal', function(e) {
21486                if($('.gallery-modal').length == 0 || $('.galleryController').length || $('.prod-modal').length || $('.cl-product-setting').length) return;
21487                if($('.edit-link-Content').length) return;
21488                if($('.cl-change-badge-design').length > 0) return;
21489
21490                if(($.gallery.copy).length) $.gallery.cp();
21491                if(($.gallery.move).length) $.gallery.mv();
21492            });
21493            $(document).bind('keydown', 'ctrl+a', function(e) {
21494                if( e.ctrlKey && 
21495                    !$(e.target).is('input:not([type="checkbox"])') &&
21496                    !$(e.target).is('textarea') &&
21497                    !$(e.target).is('.pace-disable.modal-open') &&
21498                    $('.prod-modal').length == 0 && 
21499                    $('.galleryController').length == 0 && 
21500                    $('.cl-category-modal.category-modal').length == 0
21501                ) {
21502                    if(e.keyCode == 65 || e.keyCode == 85) {
21503                        $.gallery.seqs = [];
21504
21505                        var item_selector = ($('.table-item').length) ? '.table-item' : '.gallery-items .item',
21506                            visible_button = false;
21507                        $(item_selector).find('.td-check input[type="checkbox"]').prop('checked',true);
21508                        $(item_selector).addClass('ui-selected');
21509                        $.each($(item_selector), function(i,v) {
21510                            $.gallery.seqs.push($(this).attr('data-seq'));
21511                            if($(this).attr('data-out-datetime') == "1") visible_button = true;
21512                        });
21513
21514                        if(item_selector == '.table-item') {
21515                            var firstItem = $('.gallery-items '+item_selector+'.ui-selected').eq(0),
21516                                first_seq = firstItem.attr('data-seq'),
21517                                link = firstItem.attr('data-link'),
21518                                target = firstItem.attr('data-target'),
21519                                visible = firstItem.attr('data-visible'),
21520                                grade = firstItem.attr('data-grade'),
21521                                vstr = (visible == '1') ? $.lang[LANG]['editor.gallery.icon.visible.on'] : $.lang[LANG]['editor.gallery.icon.visible.off'],
21522                                gstr = (grade == 'ON') ? $.lang[LANG]['editor.gallery.icon.grade.off'] : $.lang[LANG]['editor.gallery.icon.grade.on'];
21523
21524                            if(visible_button) {
21525                                $('.table-toolbar .toolbar-cmd.toolbar-visible').addClass('disabled');
21526                            } else $('.table-toolbar .toolbar-cmd.toolbar-visible').removeClass('disabled');
21527                            if($.gallery.block_id == -1) {
21528                                $('.table-toolbar .toolbar-cmd.toolbar-copy').addClass('disabled');
21529                            }
21530                            $('.table-toolbar .toolbar-cmd').removeClass('hide');
21531                            $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq',first_seq);
21532                            $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink',link).attr('data-glink-target',target);
21533                            $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible',visible).text(vstr);
21534                            $('.table-toolbar .toolbar-cmd i[data-cmd="grade"]').attr('data-grade',grade).text(gstr);
21535                            $('.gallery-toolbar').addClass('hide_col');
21536                            $('.check-all').prop('checked',true);
21537                            $.gallery.setNumber();
21538                            $('.gallery-toolbar').removeClass('hide');
21539                            $('.gallery-items .item-header').addClass('hide');
21540                            stickyToolbar();
21541                        } else {
21542                            $.gallery.toolbar();
21543                            stickyToolbar();
21544                        }
21545                    }
21546                }
21547            });
21548            $(document).on('click','.gallery-category > .category-text', function(e) {
21549                var s = $(this).text().trim(),
21550                    pid = $('.gallery-modal').attr('data-pid');
21551                $.gallery.show(pid,1,s);
21552            });
21553            $(document).on('click', '.gallery-modal', function(e) {
21554                $('.table-item-status').hide();
21555                $('.status-change').removeClass('open');
21556                $(this).find('.gallery-toolbar.mod-gallery').remove();
21557                if($.gallery.mode == 'shopping') {
21558                    if(typeof e.target.className != 'object') {
21559                        if(e.target.className.indexOf('ui-selectable') === -1) {
21560                            $.gallery.seqs = [];
21561                            $('.gallery-items .table-item > div').removeClass('hide-text');
21562                            $('.gallery-items .table-item input').prop('checked',fal
21562se);
21563                            $('.gallery-items .check-all').prop('checked',false);
21564                            $('.gallery-items .table-item').removeClass('ui-selected return');
21565                            $('.table-toolbar > li').removeClass('open');
21566                            $('.table-toolbar .toolbar-cmd').addClass('hide');
21567                            $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq','');
21568                            $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink','').attr('data-glink-target','');
21569                            $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible','0').text($.lang[LANG]['editor.gallery.icon.visible.off']);
21570                            $('.gallery-toolbar').removeClass('hide_col');
21571                            $('.col-check > input[type="checkbox"]').prop('checked',false);
21572                            $('.gallery-toolbar').addClass('hide');   
21573                            $('.gallery-items .item-header').removeClass('hide');
21574                        }
21575                    }
21576                } else {
21577                    if(typeof e.target.className == 'string' && e.target.className.indexOf('item') === -1) { 
21578                        $.gallery.seqs = [];
21579                        $('.gallery-items .item').removeClass('ui-selected return');    
21580                        $('.gallery-toolbar').empty();
21581                    } else {
21582                    }
21583                }
21584                $('.toolbar-sort').removeClass('open');
21585                $('.gallery-view-count').removeClass('open').find('.view-submenu').hide();
21586                // $('.table-toolbar > li').addClass('disabled').removeClass('open');
21587                $('.gallery-blocks .btn-group').removeClass('open');
21588            });
21589            $(document).on('mousemove', '.gallery-modal', function(e) {
21590                if($(".item-title").is(':focus') || clicking === false) return;
21591                if($('.gallery-modal .clone-item').length) {
21592                    $('.gallery-modal .clone-item').css({
21593                        'left' : e.pageX+10,
21594                        'top' : e.pageY+10
21595                    }).attr('data-count',($.gallery.seqs).length).find('input').remove();
21596                    if(($.gallery.seqs).length >1) $('.gallery-modal .clone-item').addClass('multi');
21597                    $('.gallery-items .table-item').removeClass('prev last');
21598                    if(window.innerHeight-80 < e.pageY) $('.gallery-modal').scrollTop($('.gallery-modal').scrollTop() + 30);
21599                    if(e.pageY < 80) $('.gallery-modal').scrollTop($('.gallery-modal').scrollTop() - 30);
21600                }
21601                if($('.ui-selectable-helper').length == 0) return;
21602                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)/)) { 
21603                    $('.gallery-modal, .gallery-items-loadmore, .gallery-category, .gallery-category li, .checkbox label, .gallery-toolbar .toolbar li, .btn, .gallery-button li').removeClass('not-allowed');
21604                } else { 
21605                    $('.gallery-modal, .gallery-items-loadmore, .gallery-category, .gallery-category li, .checkbox label, .gallery-toolbar .toolbar li, .btn, .gallery-button li').addClass('not-allowed');
21606                }
21607            }).on('mouseup', function(e) {
21608                if($('.gallery-modal .clone-item').length) {
21609                    $('.gallery-modal .clone-item').remove();
21610                    $('.gallery-items .item').removeClass('prev last drag');
21611                    $('.gallery-items .table-item').removeClass('prev last drag');
21612                    clicking = false;
21613                }
21614                // $('.gallery-items').selectable('enable');
21615                $('.gallery-modal, .gallery-items-loadmore, .gallery-category, .gallery-category li, .checkbox label, .gallery-toolbar .toolbar li, .btn, .gallery-button li').removeClass('not-allowed');
21616                stickyToolbar();
21617            });
21618            $(document).on('mousedown','.gallery-items',function(e) {
21619                if(typeof e.target.className == 'string' && typeof e.target.className != 'undefined' && e.target.className.indexOf('gallery-items') > -1) {
21620                    $.each($('.item-title'), function(i,v) {
21621                        if($(this).is(':focus')) {
21622                            $(this).blur();
21623                        }
21624                    });
21625                }
21626            });
21627            $(document).on('mouseup','.gallery-items',function(e) {
21628                $('.table-item-status').hide();
21629                $('.status-change').removeClass('open');
21630                var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item';
21631                if($(group + '.ui-selected').length == 0 && $(group).length) {
21632                    if($.gallery.mode == 'shopping') {
21633                        $('.gallery-items .table-item').removeClass('ui-selected return');
21634                        $('.table-toolbar > li').removeClass('open').find('.item-submenu').hide();
21635                        $('.gallery-view-count').removeClass('open').find('.view-submenu').hide();
21636                        $('.gallery-items .table-item > div').removeClass('hide-text');
21637                        $('.gallery-items .table-item input').prop('checked',fal
21637se);
21638                        $('.table-toolbar .toolbar-cmd').addClass('hide');
21639                        $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq','');
21640                        $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink','').attr('data-glink-target','');
21641                        $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible','0').text($.lang[LANG]['editor.gallery.icon.visible.off']);
21642                        $('.gallery-toolbar').removeClass('hide_col');
21643                        $('.col-check > input[type="checkbox"]').prop('checked',false);
21644                        $('.gallery-toolbar').addClass('hide'); 
21645                        $('.gallery-items .item-header').removeClass('hide');
21646                    } else {
21647                        $.gallery.seqs = [];
21648                        $('.gallery-items .item').removeClass('ui-selected return');    
21649                        $('.gallery-toolbar').empty();
21650                        $('.gallery-toolbar').addClass('hide');
21651                        $('.gallery-items .item-header').removeClass('hide');
21652                    }
21653                }
21654                $('.ui-selectable-helper').removeClass('hide');
21655                // $(".gallery-items").selectable("enable");
21656                if($.gallery.seqs.length && ($('.gallery-items .item').hasClass('prev') || $('.gallery-items .item').hasClass('last'))) {
21657                    if($('.gallery-items .item.last').length) {
21658                        if($('.gallery-items .item.last').next().length) {
21659                            $.gallery.drag = $('.gallery-items .item.last').next().attr('data-seq');
21660                        } else {
21661                            $.gallery.drag = $('.gallery-items .item.last').attr('data-seq');
21662                            $.gallery.last = '-1';
21663                        }
21664                    } else if($('.gallery-items .item.prev').length) {
21665                        $.gallery.drag = $('.gallery-items .item.prev').attr('data-seq');
21666                    }
21667                    $('.gallery-modal .clone-item').remove();
21668                    $('.gallery-items .item').removeClass('prev drag last');
21669
21670                    $.gallery.move = $.gallery.seqs;
21671                    $.gallery.mv();
21672                }
21673                if(typeof e.target.className == 'string' && e.target.className.indexOf('gallery-items') > -1) {
21674                    $.each($('.item-title'), function(i,v) {
21675                        if($(this).is(':focus')) {
21676                            $(this).blur();
21677                        }
21678                    });
21679                }
21680            });
21681            var isDragging = false;
21682            var startingPos = [];
21683            $(document).on('mousedown','.gallery-items .table-item',function(e) {
21684                isDragging = false;
21685                clicking = true;
21686                startingPos = [e.pageX, e.pageY];
21687                if(e.shiftKey) {
21688                    var seq_start = $('.gallery-items .table-item[data-seq="' + $.gallery.seqs[0] + '"]').index(),
21689                        seq_end = $(this).index();
21690                    $.gallery.seqs = [];
21691                    $('.gallery-items .item').removeClass('ui-selected return');
21692
21693                    // header, sticky 요소 추가로 -2
21694                    seq_start = seq_start - 2;
21695                    seq_end = seq_end - 2;
21696                    var start = 0, end = 0;
21697                    if(seq_start<seq_end) {
21698                        for(var i=seq_start; i<=seq_end; i++) {
21699                            var $shifted_item = $('.gallery-items .table-item');
21700                            $shifted_item.eq(i).addClass('ui-selected');
21701                            // $.gallery.seqs.push($shifted_item.eq(i).attr('data-seq'));
21702                        }
21703                    } else {
21704                        for(var i=seq_start; i>=seq_end; i--) {
21705                            var $shifted_item = $('.gallery-items .table-item');
21706                            $shifted_item.eq(i).addClass('ui-selected');
21707                            // $.gallery.seqs.push($shifted_item.eq(i).attr('data-seq'));
21708                        }
21709                    }
21710                    $('.gallery-toolbar').removeClass('hide');
21711                    $('.gallery-items .item-header').addClass('hide');
21712                    stickyToolbar();
21713                }
21714            });
21715            $(document).on('mousedown','.gallery-items .item',function(e) {
21716                if($('.item-title').is(':focus')) return;
21717                isDragging = false;
21718                clicking = true;
21719                startingPos = [e.pageX, e.pageY];
21720                $('.gallery-modal .clone-item').remove();
21721                if(e.target.className.indexOf('item') === 0) {
21722                    $(".ui-selectable-helper").addClass('hide');
21723                    $(".gallery-items").selectable("disable");
21724                }
21725
21726                $('.gallery-blocks .btn-group').removeClass('open');
21727                var key = e.keyCode || e.which,
21728                    seq = $(this).attr('data-seq'),
21729                    seq_idx = ($.gallery.seqs).indexOf(seq);
21730
21731                if(e.ctrlKey) {
21732                    if(seq_idx > -1) {
21733                        $(this).removeClass('ui-selected return');
21734                        // ($.gallery.seqs).splice(seq_idx,1);
21735                    } else {
21736                        $(this).addClass('ui-selected');
21737                        // $.gallery.seqs.push(seq);
21738                    }
21739                    $.gallery.selected();
21740                    stickyToolbar();
21741                } else if(e.shiftKey) {
21742                    if(($.gallery.seqs).length > 0) {
21743                        var seq_start = $('.gallery-items .item[data-seq="' + $.gallery.seqs[0] + '"]').index(),
21744                            seq_end = $(this).index();
21745                        $.gallery.seqs = [];
21746                        $('.gallery-items .item').removeClass('ui-selected return');
21747                        // console.log(seq_start,seq_end);
21748                        // header, sticky 요소 추가로 -2
21749                        seq_start = seq_start - 1;
21750                        seq_end = seq_end - 1;
21751                            var start = 0, end = 0;
21752                        if(seq_start<seq_end) {
21753                            for(var i=seq_start; i<=seq_end; i++) {
21754                                var $shifted_item = $('.gallery-items .item');
21755                                $shifted_item.eq(i).addClass('ui-selected');
21756                                // $.gallery.seqs.push($shifted_item.eq(i).attr('data-seq'));
21757                            }
21758                        } else {
21759                            for(var i=seq_start; i>=seq_end; i--) {
21760                                var $shifted_item = $('.gallery-items .item');
21761                                $shifted_item.eq(i).addClass('ui-selected');
21762                                // $.gallery.seqs.push($shifted_item.eq(i).attr('data-seq'));
21763                            }
21764                        }
21765                        $.gallery.selected();
21766                        stickyToolbar();
21767                    }
21768                } else {
21769                    if(!$(this).hasClass('ui-selected')) {
21770                        $.gallery.seqs = []; 
21771                        $.gallery.seqs.push(seq);
21772                        $('.gallery-items .item').removeClass('ui-selected return');
21773                        // $(this).parent().removeClass('move').removeClass('copy');
21774                        $(this).addClass('ui-selected');
21775                        stickyToolbar();
21776
21777                        // cut, copy remove
21778                        var i = ($.gallery.copy).indexOf(seq);
21779                        if(i !== -1) ($.gallery.copy).splice(i,1);
21780
21781                        var i = ($.gallery.move).indexOf(seq);
21782                        if(i !== -1) ($.gallery.move).splice(i,1);
21783                    }
21784                }
21785            });
21786            $(document).on('mousedown','.gallery-items .td-handle',function(e) {
21787                // if($('.gallery-items .table-item.ui-selected').length == 0) {
21788                if($(this).parent().hasClass('ui-selected') == false) {
21789                    $(this).parent().addClass('ui-selected').find('.td-check input[type="checkbox"]').prop('checked',true);
21790                    $.gallery.seqs.push($(this).parent().attr('data-seq'));
21791                }
21792            });
21793            $(document).on('mousemove','.gallery-items .table-item',function(e) {
21794                if(clicking === false) return;
21795                $('.gallery-items .table-item').removeClass('prev');
21796
21797                if($('.gallery-modal .clone-item').length) {
21798                    var $clone = $('.gallery-modal .clone-item');
21799                    $clone.css({
21800                        'position' : 'fixed',
21801                        'cursor' : 'move',
21802                        'z-index' : '1090'
21803                    });
21804                    $clone.css({
21805                        'left' : e.pageX+5,
21806                        'top' : e.pageY-25
21807                    }).attr('data-count',($.gallery.seqs).length).find('input').remove();
21808                    if(($.gallery.seqs).length >1) $clone.addClass('multi');
21809
21810                    var this_top = e.pageY - $(this).offset().top;
21811                    if($(this).is(':last-child') && this_top > 45) {
21812                        $(this).removeClass('prev').addClass('last');
21813                    } else $(this).removeClass('last').addClass('prev');
21814                    if(window.innerHeight-80 < e.pageY) $('.gallery-modal').scrollTop($('.gallery-modal').scrollTop() + 30);
21815                    if(e.pageY < 80) $('.gallery-modal').scrollTop($('.gallery-modal').scrollTop() - 30);
21816                    e.stopPropagation();
21817                } 
21818            });
21819            $(document).on('mouseenter','.gallery-items .table-item',function(e) {
21820                if($('#user-edit').length == 0) { 
21821                    $('.edit-button').hide();
21822                    if($(this).hasClass('yet')) return;
21823                    $(this).find('.edit-button').show();
21824                } else $('.edit-button').hide();
21825            }).on('mouseleave','.gallery-items .table-item',function(e) {
21826                $('.edit-button').hide();
21827            });
21828            $(document).on('mouseenter','.gallery-items .td-category', function(e) {
21829                var cate_arr = $(this).text().trim().split(',');
21830                if(cate_arr.length < 2) return;
21831
21832                var cate_str = '';
21833                $.each(cate_arr, function(i,v) {
21834                    cate_str += '<li>' + v.trim() + '</li>';
21835                });
21836
21837                var gcate_tooltip_place = ($('.gallery-modal').height() <= $(this).closest('.table-item').offset().top + $(this).closest('.table-item').outerHeight()) ? 'top' : 'bottom'; 
21838                var gcate_tooltip_css = (gcate_tooltip_place == 'to
21838p') ? {
21839                    'top': (Math.floor($('.gallery-modal').scrollTop() + $(this).offset().top - (100 + ((cate_arr.length-2) * 20)))) + 'px',
21840                    'left': (Math.floor($(this).offset().left) -30) + 'px',
21841                } : {
21842                    'top': (Math.floor($('.gallery-modal').scrollTop() + $(this).offset().top + $(this).outerHeight()) - 7) + 'px',
21843                    'left': (Math.floor($(this).offset().left) -30) + 'px',
21844                }
21845
21846                $('.gcategory-tooltip ul').empty().html(cate_str);
21847                $('.gcategory-tooltip').attr('data-place',gcate_tooltip_place).css(gcate_tooltip_css).show();
21848            });
21849            $(document).on('mouseleave', '.gallery-items .td-category', function(e) {
21850                if($('.gcategory-tooltip').css('display') === 'none') return;
21851                $('.gcategory-tooltip').hide().removeAttr('style');
21852                $('.gcategory-tooltip ul').empty();
21853            });
21854            $(document).on('mousemove','.gallery-items .td-handle',function(e) {
21855                if($('.gallery-modal').attr('data-pid') == undefined) {
21856                    return false;
21857                }
21858                if(clicking === false || $('.gallery-items .table-item.ui-selected').length == 0) return;
21859                $('.td-edit .item-edit').css('display','none');
21860                if ((e.pageX  < startingPos[0]-10 || e.pageX  > startingPos[0]+10) ||
21861                    (e.pageY  < startingPos[1]-10 || e.pageY  > startingPos[1]+10)) {
21862                    $('.gallery-items .table-item.ui-selected').addClass('drag');
21863                    if($('.gallery-modal .clone-item').length == 0 && !LUX) {
21864                        var $clone = $(this).parent().clone();
21865                        $clone.css({
21866                            'position' : 'fixed',
21867                            'cursor' : 'move',
21868                            'z-index' : '1090'
21869                        }).addClass('clone-item').attr('data-count',($.gallery.seqs).length).find('input').remove();
21870                        $('.gallery-modal').append($clone);
21871
21872                        $clone.css({
21873                            'left' : e.pageX+10,
21874                            'top' : e.pageY+10
21875                        });
21876                        if(($.gallery.seqs).length >1) $clone.addClass('multi');
21877                    } 
21878                    isDragging = true;
21879                    // var parentOffset = $(this).parent().offset(); 
21880                    // var relX = e.pageX - parentOffset.left;
21881                    // var relY = e.pageY - parentOffset.top;
21882                    // $('.gallery-items .item').removeClass('prev last');
21883                    // var this_top = $(this).position().top,
21884                    //     next_top = ($(this).next().length) ? $(this).next().position() : -1;
21885                    // console.log(parentOffset);
21886                    // if(this_top == next_top) {
21887                    //     (relX - $(this).position().left < 62) ? $(this).addClass('prev') : $(this).next().addClass('prev');
21888                    // } else {
21889                    //     (relX - $(this).position().left < 62) ? $(this).addClass('prev') : $(this).addClass('last');
21890                    // }
21891                }
21892            });
21893            $(document).on('mousemove','.gallery-items .item',function(e) {
21894                if(clicking === false || $('.item-title').is(':focus')) return;
21895                if ((e.pageX  < startingPos[0]-10 || e.pageX  > startingPos[0]+10) ||
21896                    (e.pageY  < startingPos[1]-10 || e.pageY  > startingPos[1]+10)) {
21897                    $('.gallery-items .item.ui-selected').addClass('drag');
21898                    if($('.gallery-modal .clone-item').length == 0 && !LUX) {
21899                        var $clone = $(this).clone();
21900                        $clone.css({
21901                            'position' : 'fixed'
21902                        }).addClass('clone-item').attr('data-count',($.gallery.seqs).length).find('input').remove();
21903                        $('.gallery-modal').append($clone);
21904                        if(($.gallery.seqs).length >1) $clone.addClass('multi');
21905                    } 
21906                    isDragging = true;
21907                    var parentOffset = $(this).parent().offset(); 
21908                    var relX = e.pageX - parentOffset.left;
21909                    var relY = e.pageY - parentOffset.top;
21910                    $('.gallery-items .item').removeClass('prev last');
21911                    var this_top = $(this).position().top,
21912                        next_top = ($(this).next().length) ? $(this).next().position() : -1;
21913                    if(this_top == next_top) {
21914                        (relX - $(this).position().left < 62) ? $(this).addClass('prev') : $(this).next().addClass('prev');
21915                    } else {
21916                        (relX - $(this).position().left < 62) ? $(this).addClass('prev') : $(this).addClass('last');
21917                    }
21918                }
21919            });
21920            $(document).on('mouseup','.gallery-items .table-item',function(e) {
21921                clicking = false;
21922                if (isDragging) {
21923                    if($.gallery.seqs.length && $('.gallery-modal .clone-item').length) {
21924                        if($('.gallery-items .table-item.last').length) {
21925                            if($('.gallery-items .table-item.last').next().length) {
21926                                $.gallery.drag = $('.gallery-items .table-item.last').next().attr('data-seq');
21927                            } else {
21928                                $.gallery.drag = $('.gallery-items .table-item.last').attr('data-seq');
21929                                $.gallery.last = '-1';
21930                            }
21931                        } else if($('.gallery-items .table-item.prev').length) {
21932                            $.gallery.drag = $('.gallery-items .table-item.prev').attr('data-seq');
21933                        }
21934                        $('.gallery-modal .clone-table-item').remove();
21935                        $('.gallery-items .table-item').removeClass('prev drag last');
21936
21937                        $.gallery.move = $.gallery.seqs;
21938                        $.gallery.mv();
21939                    }
21940                } else {
21941                    $('.gallery-items .table-item.ui-selecting').removeClass('active').addClass('ui-selected');
21942                    $('.check-all').prop('checked',false);
21943                    stickyToolbar();
21944                }
21945                isDragging = false;
21946                startingPos = [];
21947
21948                var l = ($(this).index()%7 > 3) ? 'right' : '',
21949                    mode = $('.gallery-add-items').attr('data-mode');
21950
21951                if(typeof mode == 'undefined' || !mode) {
21952                    alert('Undefined gallery mode');
21953                    return false;
21954                }                        
21955                $.gallery.setNumber();     
21956                $('.ui-selectable-helper').removeClass('hide');
21957                if($('.gallery-modal').attr('data-pid') != undefined) {
21958                    $('.gallery-items').selectable('enable');    
21959                }
21960            });
21961            $(document).on('mouseup','.gallery-items .item',function(e) {
21962                e.preventDefault();
21963                clicking = false;
21964                if (isDragging) {
21965                    if($.gallery.seqs.length && $('.gallery-modal .clone-item').length) {
21966                        if($('.gallery-items .item.last').length) {
21967                            if($('.gallery-items .item.last').next().length) {
21968                                $.gallery.drag = $('.gallery-items .item.last').next().attr('data-seq');
21969                            } else {
21970                                $.gallery.drag = $('.gallery-items .item.last').attr('data-seq');
21971                                $.gallery.last = '-1';
21972                            }
21973                        } else if($('.gallery-items .item.prev').length) {
21974                            $.gallery.drag = $('.gallery-items .item.prev').attr('data-seq');
21975                        }
21976                        $('.gallery-modal .clone-item').remove();
21977                        $('.gallery-items .item').removeClass('prev drag last');
21978
21979                        $.gallery.move = $.gallery.seqs;
21980                        $.gallery.mv();
21981                    }
21982                } else {
21983                    var parentOffset = $(this).parent().offset(),
21984                        relX = e.pageX - parentOffset.left,
21985                        relY = e.pageY - parentOffset.top;
21986                    $('.gallery-items .item.ui-selecting').removeClass('active').addClass('ui-selected');
21987                    stickyToolbar();
21988                }
21989                isDragging = false;
21990                startingPos = [];
21991
21992                var l = ($(this).index()%7 > 3) ? 'right' : '',
21993                    mode = $('.gallery-add-items').attr('data-mode');
21994
21995                if(typeof mode == 'undefined' || !mode) {
21996                    alert('Undefined gallery mode');
21997                    return false;
21998                }                        
21999                // $.gallery.toolbar();
22000                
22001                $.gallery.setNumber();     
22002                $('.ui-selectable-helper').removeClass('hide');
22003                $('.gallery-items').selectable('enable');
22004            });
22005            $(document).on('click','.toolbar-cmd.null', function(e) {
22006                e.stopPropagation();
22007                $.gallery.seqs = [];
22008                $('.gallery-toolbar').addClass('hide');   
22009                $('.gallery-items .item-header').removeClass('hide');
22010                setTimeout(()=> {
22011                    $('.gallery-items .table-item input').prop('checked',fal
22011se);
22012                    $('.gallery-items .table-item').removeClass('ui-selected ui-selecting');
22013                },100);
22014            }); 
22015            $(document).on('click','.gallery-controller',function(e) { 
22016                $.gallery.show($.gallery.block_id);
22017            });
22018            $(document).on('click','.gallery-all',function(e) { 
22019                $.gallery.show($.gallery.block_id);
22020            });
22021            $(document).on('click','.gallery-button .modal-close', function(e) {
22022                $.gallery.close();
22023            });
22024            $(document).on('click','.gallery-button .modal-save', function(e) {
22025                $.gallery.save();
22026            });
22027            $(document).on('keyup','.item-title', function(e) {
22028                if(e.keyCode == 13) $('#empty-text').focus().blur();
22029            });
22030            $(document).on('focus','.item-title', function(e) {
22031                $.gallery.seqs = [];
22032                var seq = $(this).parent().attr('data-seq');
22033                $.gallery.seqs.push(seq);
22034                $('.gallery-items .item').removeClass('ui-selected');
22035                $(this).parent().addClass('ui-selected');
22036            });
22037            $(document).on('mouseenter', '.gallery-items .item > img', function(e) {
22038                // e.stopPropagation();
22039                $('.gallery-items .item .gallery-paste-icon').remove();
22040                var s = '<div class="item-ctrl"></div>',
22041                    $ctrl = $(s);
22042                if($(this).parent().find('.item-ctrl').length == 0)
22043                    $(this).parent().append($ctrl);
22044            });
22045            $(document).on('mouseleave', '.gallery-items .item', function(e) {
22046                $(this).find('.item-ctrl').remove();
22047                $('.gallery-paste-icon').remove();
22048            });
22049            $(document).on('click','.gallery-items .item .gallery-paste-icon', function(e) {
22050                e.stopPropagation();
22051                ($.gallery.seqs).push($(this).parents('.item').attr('data-seq'));
22052                if(($.gallery.copy).length) $.gallery.cp();
22053                if(($.gallery.move).length) $.gallery.mv();
22054            });
22055            $(document).on('click', '.gallery-items .item input', function(e) {
22056                e.stopPropagation();
22057                $('.gallery-toolbar.mod-gallery').remove();
22058            });
22059            $(document).on('keypress click', '.gallery-items .item .item-ctrl', function(e) {
22060                $('.gallery-blocks .btn-group').removeClass('open');
22061                var key = e.keyCode || e.which,
22062                    seq = $(this).parent().attr('data-seq'),
22063                    seq_idx = ($.gallery.seqs).indexOf(seq);
22064                if(e.ctrlKey) {
22065                    if(seq_idx > -1) {
22066                        $(this).parents().removeClass('ui-selected');
22067                        ($.gallery.seqs).splice(seq_idx,1);
22068                    } else {
22069                        $(this).parent().addClass('ui-selected');
22070                        $.gallery.seqs.push(seq);
22071                    }
22072                } else if(e.shiftKey) {
22073                    if(($.gallery.seqs).length > 0) {
22074                        var seq_start = $('.gallery-items .item[data-seq="' + $.gallery.seqs[0] + '"]').index(),
22075                            seq_end = $(this).parent().index();
22076                        $.gallery.seqs = [];
22077                        $('.gallery-items .item').removeClass('ui-selected');
22078                        // console.log(seq_start,seq_end);
22079                        var start = 0, end = 0;
22080                        if(seq_start<seq_end) {
22081                            for(var i=seq_start; i<=seq_end; i++) {
22082                                var $shifted_item = $('.gallery-items .item');
22083                                $shifted_item.eq(i).addClass('ui-selected');
22084                                $.gallery.seqs.push($shifted_item.eq(i).attr('data-seq'));
22085                            }
22086                        } else {
22087                            for(var i=seq_start; i>=seq_end; i--) {
22088                                var $shifted_item = $('.gallery-items .item');
22089                                $shifted_item.eq(i).addClass('ui-selected');
22090                                $.gallery.seqs.push($shifted_item.eq(i).attr('data-seq'));
22091                            }
22092                        }
22093                    }
22094                } else {
22095                    $.gallery.seqs = []; 
22096                    $.gallery.seqs.push(seq);
22097                    $('.gallery-items .item').removeClass('ui-selected return');
22098                    // $(this).parent().removeClass('move').removeClass('copy');
22099                    $(this).parent().addClass('ui-selected');
22100
22101                    // cut, copy remove
22102                    var i = ($.gallery.copy).indexOf(seq);
22103                    if(i !== -1) ($.gallery.copy).splice(i,1);
22104
22105                    var i = ($.gallery.move).indexOf(seq);
22106                    if(i !== -1) ($.gallery.move).splice(i,1);
22107                }
22108                var l = ($(this).index()%7 > 3) ? 'right' : '',
22109                    mode = $('.gallery-add-items').attr('data-mode');
22110
22111                if(typeof mode == 'undefined' || !mode) {
22112                    alert('Undefined gallery mode');
22113                    return false;
22114                }
22115                $(this).parents('.gallery-items').find('.toolbar.mod-gallery').remove();
22116                // var str = '', cmd = '';
22117                // if(($.gallery.move).length || ($.gallery.copy).length) {
22118                //     str = '붙여넣기'; cmd = 'paste';
22119                // } else {
22120                //     str = '잘라내기'; cmd = 'move';
22121                // }
22122
22123                var seq = $(this).parent().attr('data-seq'),
22124                    pid = $(this).parent().attr('data-pid'),
22125                    link = $(this).parent().attr('data-link'),
22126                    target = $(this).parent().attr('data-target'),
22127                    visible = $(this).parent().attr('data-visible');
22128
22129                var vstr = (visible == '1') ? $.lang[LANG]["editor.gallery.icon.visible.on"] : $.lang[LANG]["editor.gallery.icon.visible.off"],
22130                    vicon = (visible == '1') ? 'cl_icon_hide02' : 'cl_icon_show',
22131                    edit_name = ($.gallery.mode == 'gallery') ? $.lang[LANG]['editor.block.gallery.item.edit.image'] : $.lang[LANG]['editor.block.gallery.item.edit'];
22132                var outDatetime = $(this).parent().attr('data-out-datetime');
22133                if(outDatetime !== 'off') {
22134                    visible = outDatetime;
22135                    if(outDatetime == 1) vstr = $.lang[LANG]['editor.gallery.icon.visible.on'];
22136                }
22137                var s = '\
22138                    <ul>\
22139                        <li class="active gallery-item-edit">\
22140                            <i class="" data-glseq="' + seq + '" data-cmd="edit"></i>' + edit_name + '\
22141                        </li>\
22142                    ';
22143                s = s + '<li><i class="" data-glseq="' + seq + '" data-cmd="copy"></i>' + $.lang[LANG]['editor.gallery.icon.clone'] + '</li>';
22144
22145                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>\
22146                            <ul class="item-submenu">\
22147                                <li class="sort-top">' + $.lang[LANG]['editor.gallery.icon.order.front'] + '</li>\
22148                                <li class="sort-bottom">' + $.lang[LANG]['editor.gallery.icon.order.end'] + '</li>\
22149                            </ul>\
22150                        </li>';
22151                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>';
22152                s = s + '<ul class="item-submenu">' + $.gallery.cates + '</ul>';
22153                s = s + '</li>';
22154                
22155                s = s + '\
22156                        <li><i class="" data-glseq="' + seq + '" data-glink="' + link + '" data-glink-target="' + target + '" data-cmd="link"></i>' + $.lang[LANG]['editor.gallery.icon.link'] + '</li>\
22157                ';
22158                        
22159                s = s + '\
22160                        <li><i class="" data-glseq="' + seq + '" data-visible="' + visible + '" data-cmd="visible">' + vstr + '</i></li>\
22161                        <li><i class="" data-glseq="' + seq + '" data-cmd="delete"></i>' + $.lang[LANG]['editor.gallery.icon.delete'] + '</li>\
22162                    </ul>\
22163                ';
22164                var $tool_back = $('<div class="toolbar mod-gallery ' + l + '">' + s + '</div>');
22165                $(this).parents('.container').find('.gallery-toolbar').empty();
22166                $(this).parents('.container').find('.gallery-toolbar').append($tool_back);
22167                
22168                // $(this).parent().prev().append($tool_back);
22169                $.gallery.selected();
22170                stickyToolbar();
22171                $.gallery.setNumber();
22172            });
22173            $(document).on('click','.gallery-modal .check-all', function(e) {
22174                e.stopPropagation();
22175                var check = $(this).prop('checked'),
22176                    disabled = false,
22177                    visible_button = false;
22178                if(check) {
22179                    $('.table-item .td-check input[type="checkbox"]').prop('checked',true);
22180                    $('.table-item').addClass('ui-selected');
22181                    $.each($('.table-item'), function(i,v) {
22182                        if($.gallery.seqs.indexOf($(this).attr('data-seq')) == -1) $.gallery.seqs.push($(this).attr('data-seq'));
22183                    });
22184
22185                    $.each($('.gallery-items .table-item.ui-selected'), function(i,v) {
22186                        if($(this).attr('data-product') == "false") disabled = true;
22187                        if($(this).attr('data-out-datetime') == "1") visible_button = true;
22188                    });
22189                    var firstItem = $('.gallery-items .table-item.ui-selected').eq(0),
22190                        first_seq = firstItem.attr('data-seq'),
22191                        link = firstItem.attr('data-link'),
22192                        target = firstItem.attr('data-target'),
22193                        visible = firstItem.attr('data-visible'),
22194                        grade = firstItem.attr('data-grade'),
22195                        vstr = (visible == '1') ? $.lang[LANG]['editor.gallery.icon.visible.on'] : $.lang[LANG]['editor.gallery.icon.visible.off'],
22196                        gstr = (grade == 'ON') ? $.lang[LANG]['editor.gallery.icon.grade.off'] : $.lang[LANG]['editor.gallery.icon.grade.on'];
22197                    if(visible_button) {
22198                        $('.table-toolbar .toolbar-cmd.toolbar-visible').addClass('disabled');
22199                    } else $('.table-toolbar .toolbar-cmd.toolbar-visible').removeClass('disabled');
22200                    if($.gallery.block_id == -1) {
22201                        $('.table-toolbar .toolbar-cmd.toolbar-copy').addClass('disabled');
22202                    }
22203                    $('.table-toolbar .toolbar-cmd').removeClass('hide');
22204                    $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq',first_seq);
22205                    $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink',link).attr('data-glink-target',target);
22206                    $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible',visible).text(vstr);
22207                    $('.table-toolbar .toolbar-cmd i[data-cmd="grade"]').attr('data-grade',grade).text(gstr);
22208                    $('.gallery-toolbar').addClass('hide_col');
22209                    $('.gallery-toolbar').removeClass('hide');
22210                    $('.gallery-items .item-header').addClass('hide');
22211                    $('.checkbox-cmd .check-all').prop('checked',true);
22212                    stickyToolbar();
22213                } else {
22214                    $('.table-item .td-check input[type="checkbox"]').prop('checked',fal
22214se);   
22215                    $('.table-item').removeClass('ui-selected return');
22216                    $('.table-toolbar .toolbar-cmd').addClass('hide');
22217                    $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq','');
22218                    $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink','').attr('data-glink-target','');
22219                    $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible','0').text($.lang[LANG]['editor.gallery.icon.visible.off']);
22220                    $('.gallery-toolbar').removeClass('hide_col');
22221                    $('.gallery-toolbar').addClass('hide');
22222                    $('.gallery-items .item-header').removeClass('hide');
22223                    $('.check-all').prop('checked',false);
22224                    $.gallery.seqs = [];
22225                }
22226                (disabled) ? $('.product-cmd').addClass('disabled') : $('.product-cmd').removeClass('disabled');
22227                if($('.gallery-modal').attr('data-pid') == undefined) {
22228                    $('.toolbar-sort.item-sort').addClass('disabled');
22229                }
22230
22231                $.gallery.setNumber();
22232            });
22233            $(document).on('click','.gallery-view-count', function(e) {
22234                e.stopPropagation();
22235                $(this).toggleClass('open');
22236                if($(this).hasClass('open')) {
22237                    $(this).find('.view-submenu').show();
22238                } else $(this).find('.view-submenu').hide();
22239            });
22240            $(document).on('click','.gallery-view-count li', function(e) {
22241                $('.gallery-view-count li').removeClass('active');
22242                $(this).addClass('active');
22243            });
22244            $(document).on('click','.gallery-move:not(.disabled)', function(e) {
22245                $('.gallery-move-list').removeClass('not-selected');
22246                $('.move-alert').text('');
22247                $('.gallery-move').removeClass('active');
22248                $(this).toggleClass('active');
22249
22250                var block_id = $(this).attr('data-gallery-id'),
22251                    first_title = '';
22252                $.gallery.ex_id = [];
22253
22254                // 선택된 상품 같은 갤러리 이동시 처리
22255                $.each($.gallery.move, function(i,v) {
22256                    var $product = $('.table-item[data-seq="' + v + '"]'),
22257                        product_pid = $product.attr('data-pid'),
22258                        product_title = $product.find('.td-title .item-title-str').text();
22259                    if(block_id == product_pid) {
22260                        if(first_title == '') first_title = "'" + product_title + "'";
22261                        $.gallery.ex_id.push(v);
22262                    }
22263                });
22264                if($.gallery.ex_id.length) {
22265                    $('.move-alert').append('<p>' + first_title + (($.gallery.ex_id.length == 1) ? ' 상품은<br>이미 갤러리에 존재하여 이동에서 제외됩니다.' : ' 외 ' + $.gallery.ex_id.length + '개 상품들은<br>이미 갤러리에 존재하여 이동에서 제외됩니다.</p>'));
22266                }
22267                ($.gallery.ex_id.length == $.gallery.move.length) ?
22268                    $('.ok-button-dialog').addClass('disabled') :
22269                    $('.ok-button-dialog').removeClass('disabled');
22270            });
22271            $(document).on('click', '.gallery-modal .toolbar li', function(e) {
22272                var check_disabled = ($(this).hasClass('product-cmd') && ($(this).hasClass('disabled') || $(this).hasClass('no_price'))) ? true : false;
22273                        
22274                if(check_disabled) {
22275                    var modal_str = ($(this).hasClass('disabled')) ? '상품 정보를 입력한 후에 이용 가능합니다.<br>상품 설정을 완료해주세요.' : '정가가 1원 이상이어야만 [할인] 및 [판매가] 설정이 가능합니다';
22276                    $(this).showModalFlat($.lang[LANG]["config.information"], modal_str, true, false, '', 'ok','','cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
22277                    return false;
22278                }
22279
22280                if($(this).hasClass('toolbar-visible') && $(this).hasClass('disabled')) {
22281                    $(this).showModalFlat($.lang[LANG]["config.information"], '판매예정/판매종료인 기간한정판매 상품은 숨김/보이기 옵션을 이용할 수 없습니다.', true, false, '', 'ok','','cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
22282                    return false;
22283                }
22284
22285                if($(this).hasClass('toolbar-copy') && $(this).hasClass('disabled')) {
22286                    $(this).showModalFlat($.lang[LANG]["config.information"], '상품 복제는 화면 좌측의 갤러리 목록에서 갤러리 선택 후 사용 가능합니다.', true, false, '', 'ok','','cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
22287                    return false;
22288                }
22289
22290                if($(this).hasClass('toolbar-sort') && $(this).hasClass('disabled')) {
22291                    $(this).showModalFlat($.lang[LANG]["config.information"], '상품 순서 변경은 화면 좌측의 갤러리 목록에서 갤러리 선택 후 사용 가능합니다.', true, false, '', 'ok','','cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
22292                    return false;
22293                }
22294
22295                $('.ui-selectable-helper').remove();
22296                e.stopPropagation();
22297                var cmd = $(this).find('i').attr('data-cmd'),
22298                    mode = $('.gallery-add-items').attr('data-mode'),
22299                    seq = $(this).find('i').attr('data-glseq'),
22300                    sub = ($(this).parent().hasClass('item-submenu')) ? true : false,
22301                    $this = $(this);
22302
22303                if(typeof cmd == 'undefined' && sub == false && !$(this).hasClass('disabled')) {
22304                    $('.item-submenu').hide();
22305                    $('.submenu').removeClass('open');
22306                    var $submenu = $(this).find('.item-submenu'),
22307                        display = $submenu.css('display');
22308                    (display == 'none') ? $submenu.css('display','block') : $submenu.css('display','none');
22309                    return;
22310                }
22311                if($(this).hasClass('disabled')) {
22312                    if($(this).hasClass('gallery-item-edit')) {
22313                        $(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');
22314                    }
22315                    return false;
22316                }
22317                if(($.gallery.seqs).length == 0 && cmd != 'checkall') {
22318                    $(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');
22319                    return false;
22320                }
22321                switch(cmd) {
22322                    case "item-sort":
22323                        $(this).toggleClass('open');
22324                        $('.item-submenu').hide();
22325                        if($(this).hasClass('open')) {
22326                            $(this).find('.item-submenu').show();
22327                        }
22328                        $('.toolbar-category').removeClass('open');
22329                        $('.toolbar-category .item-submenu').hide();
22330                        break;
22331                    case "category":
22332                        $(this).toggleClass('open');
22333                        $('.item-submenu').hide();
22334                        $('.toolbar-category .item-submenu li').removeClass('active');
22335                        if($(this).hasClass('open')) {
22336                            $(this).find('.item-submenu').show();
22337                        }
22338                        $('.toolbar-sort').removeClass('open');
22339                        $('.toolbar-sort .item-submenu').hide();
22340                        if(($.gallery.seqs).length == 1) {
22341                            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');
22342                            if(s) {
22343                                $('.toolbar-category .item-submenu li').each(function() {
22344                                    if(s.includes(`|${$(this).text().trim()}|`)) $(this).addClass('active');
22345                                });
22346                            }
22347                        } else {
22348                            var category_active_text = $('.gallery-category-menu.active').text();
22349                            $('.toolbar-category .item-submenu li:contains("'+category_active_text+'")').addClass('active');
22350                        }
22351                        break;
22352                    case "checkall": 
22353                        var check = $(this).find('input').prop('checked');
22354                        if(check) {
22355                            $('.table-item input').prop('checked',true);
22356                            $('.table-item').addClass('ui-selected');
22357                            $.each($('.table-item'), function(i,v) {
22358                                $.gallery.seqs.push($(this).attr('data-seq'));
22359                            });
22360                            stickyToolbar();
22361                        } else {
22362                            $('.table-item input').prop('checked',fal
22362se);   
22363                            $('.table-item').removeClass('ui-selected return');
22364                            $.gallery.seqs = [];
22365                        }
22366                        break;
22367                    case "edit": 
22368                        ($.gallery.mode == 'shopping') ? $.products.add(seq) : galleryItemController(seq); break;
22369                    case "copy": 
22370                        $.gallery.copy = $.gallery.seqs; $.gallery.move = []; $.gallery.delete = []; // $.gallery.seqs = [];
22371                        $('.gallery-items .item').removeClass('move');
22372                        $('.gallery-toolbar.mod-gallery').remove();
22373                        $.gallery.cp();
22374                        break;
22375                    case "move":
22376                        $.gallery.move = $.gallery.seqs; $.gallery.copy = []; $.gallery.delete = []; $.gallery.seqs = []; $.gallery.ex_id = [];
22377                        $('.gallery-items .item').removeClass('copy');
22378                        $('.gallery-toolbar.mod-gallery').remove();
22379                        var content = '<ul class="gallery-move-list ui-sortable">',
22380                            gallery_count = 0;
22381
22382                        $.each($.gallery.blocks, function(i,v) {
22383                            $.each(v, function(m, s) {
22384                                if(s.length) {
22385                                    $.each(s, function(k,n) {
22386                                        if(n.id == $.gallery.block_id && s.length == 1) {
22387                                            return true;
22388                                        }
22389                                        if(k == 0) {
22390                                            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> ' + m + '</li>';
22391                                        }
22392                                        if(n.id != $.gallery.block_id) {
22393                                            switch(n.mode) {
22394                                                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;
22395                                                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;
22396                                                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;
22397                                            }
22398                                            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>';
22399                                            var move_disabled = (n.isActive) ? '' : 'disabled';
22400                                            if(LUX && n.mode == 'shopping') move_disabled = 'disabled';
22401                                            content+= '<li class="gallery-move ' + move_disabled + '" data-gallery-id="' + ((move_disabled == '') ? n.id : '') + '"><span class="gallery-block-name">' + 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>';
22402                                            gallery_count++;
22403                                        }
22404                                    });
22405                                }
22406                            });
22407                        });
22408                        if(gallery_count == 0) {
22409                            content+= "<li>" + $.lang[LANG]['editor.block.gallery.item.move.none'] + "</li>";
22410                        }
22411                        content+= "</ul><div class='move-alert error'></div>";
22412
22413                        if(gallery_count) {
22414                            content+= '\
22415                            <div class="gallery-confirm-str">' + $.lang[LANG]['editor.block.gallery.item.move.after'] + '</div>\
22416                            <div class="gallery-confirm-select">\
22417                                <div class="gallery-move-select radio">\
22418                                  <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>\
22419                                </div>\
22420                                <div class="gallery-move-select radio">\
22421                                  <label><input type="radio" name="gallery_move_info" class="gallery-move-info" value="move">' + $.lang[LANG]['editor.block.gallery.item.move.after.2'] + '</label>\
22422                                </div>\
22423                            </div>\
22424                            ';
22425                        }
22426
22427                        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() {
22428                            $('.gallery-move-list').removeClass('not-selected');
22429                            $('.move-alert').text('');
22430
22431                            var $active = $('.gallery-move.active:not(.disabled)');
22432                            if($active.length == 0 && gallery_count > 0) {
22433                                $('.gallery-move-list').addClass('not-selected');
22434                                $('.move-alert').text($.lang[LANG]['editor.block.gallery.item.move.error']);
22435                                return false;
22436                            }
22437                            var block_id = $active.attr('data-gallery-id'),
22438                                isMove = $("input.gallery-move-info:checked").val();
22439                            if(typeof block_id == "undefined") {
22440                                $('.move-alert').text($.lang[LANG]['editor.block.gallery.error']);
22441                                return false;
22442                            }
22443
22444                            if($.gallery.ex_id.length) {
22445                                $.gallery.move = $.gallery.move.filter(item => !$.gallery.ex_id.includes(item));
22446                            }
22447                            moveModal.modal('hide');
22448                            var move_block_id = (isMove == "stay") ? $.gallery.block_id : block_id;
22449                            $.progressON($.lang[LANG]['editor.block.gallery.moving.str.1']);
22450                            var total = ($.gallery.move).length, 
22451                                moving = $.lang[LANG]['editor.block.gallery.moving.str.2'], 
22452                                progress = 0,
22453                                loading = '<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i> ',
22454                                done = 0,
22455                                group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item',
22456                                item = $(group).length,
22457                                cpage = Math.ceil(item/30),
22458                                spos = $('.gallery-modal').scrollTop();
22459                                seqs = $.gallery.move;
22460
22461                            $('.progressModal .info1').html(loading + moving);
22462                            $.each($.gallery.move,function(i,v) {
22463                                var t = setTimeout(function() {
22464                                    if(CANCEL) {
22465                                        if(ABORT) {
22466                                            // 리스트 갱신 작업
22467                                            $.gallery.show($.gallery.block_id,cpage,$.gallery.category, function() {
22468                                                setTimeout(function() { 
22469                                                    $.gallery.move = [];
22470                                                    $('.gallery-modal').scrollTop(spos); 
22471                                                    $.processOFF();
22472                                                    $.gallery.update = true;
22473                                                }, 500);
22474                                            });
22475                                            ABORT = false;
22476                                            $.progressOFF();
22477                                        }
22478                                        i=0; return false;
22479                                    }
22480                                    galleryMoveItem(block_id,v,$.gallery.pages[block_id],function() {
22481                                        done++;
22482                                        progress = parseInt((done / total) * 100,10);
22483                                        $('.file-upload-progress .progress-bar').css('width',progress + "%");
22484                                        $('.progressModal .info2').text(done.toString() + ' / ' + total.toString());
22485                                        if(typeof VIEW == 'undefined') {
22486                                            $.gallery.unlink = true;
22487                                        } else if(v==VIEW) $.gallery.unlink = true;
22488                                        if(total == done) {
22489                                            $.gallery.show(move_block_id,1,$.gallery.category, function() {
22490                                                var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item';
22491                                                $.each($.gallery.move, function(i,v) {
22492                                                    $(group + '[data-seq="' + v + '"]').addClass('return');
22493                                                });
22494                                                setTimeout(function() { 
22495                                                    $.gallery.move = [];
22496                                                    $('.gallery-modal').scrollTop(spos); 
22497                                                    $.progressOFF();
22498                                                    $.gallery.update = true;
22499                                                }, 500);
22500                                            });
22501                                        } else {
22502                                            moving = $(group + '[data-seq="' + seqs[i+1] + '"] .td-title .item-title-str').text();
22503                                            if(moving == "") moving = $.lang[LANG]['editor.block.gallery.moving.str.2'];
22504                                            $('.progressModal .info1').html(loading + moving);
22505                                        }
22506                                    });
22507                                },500*i);
22508                            });                            
22509                        },'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0',true,'','',function() {
22510                            $.gallery.seqs = $.gallery.move;
22511                        });
22512
22513                        break;
22514                    case "paste":
22515                        if(($.gallery.copy).length) $.gallery.cp();
22516                        if(($.gallery.move).length) $.gallery.mv();
22517                        break;
22518                    case "delete":
22519                        $.gallery.delete = $.gallery.seqs; $.gallery.move = []; $.gallery.copy = [];
22520                        $('.gallery-toolbar.mod-gallery').remove();
22521                        $.gallery.del();
22522                        break;
22523                    case "grade":
22524                        var grade = $(this).find('i').attr('data-grade'),
22525                            visible = '',
22526                            mode = '';
22527                        var $this = $(this);
22528
22529                        visible = (grade == 'ON') ? 0 : 1;
22530                        mode = (visible == 1) ? 'ON' : 'OFF';
22531                        $(this).find('i').attr('data-visible', visible).attr('data-grade', mode);
22532                        $.each($.gallery.seqs, function(i,v) {
22533                            $('.gallery-items .table-item[data-seq="'+ v +'"]').attr('data-grade', mode);
22534                        });
22535                        if(visible == 1) $(this).find('i').text($.lang[LANG]['editor.gallery.icon.grade.off']);
22536                        else $(this).find('i').text($.lang[LANG]['editor.gallery.icon.grade.on']);
22537                        
22538                        $.post('/template/gallery/grade', { s: $.gallery.seqs, view: visible, mode: mode }, function (data) {
22539                            checkError(data);
22540                            
22541                        },'json');
22542
22543                        break;
22544                    case "visible":
22545                        var seq = $(this).find('i').attr('data-glseq'),
22546                            visible = $(this).find('i').attr('data-visible'),
22547                            mode = '';
22548                        var $this = $(this);
22549
22550                        visible = (visible == 1) ? 0 : 1;
22551
22552                        var limitCnt = 0;
22553                        if($('.table-item').length) {
22554                            mode = 'product';
22555                            $.each($.gallery.seqs, function(i,v) {
22556                                var outDatetime = $('.gallery-items .table-item[data-seq="' + v + '"]').attr('data-out-datetime');
22557                                if(visible == 0 && outDatetime == '1') {
22558                                    limitCnt++;
22559                                }
22560                            });
22561                        }
22562
22563                        if(limitCnt > 0) {
22564                            var modal_str = '선택된 상품은 기간한정판매 상품입니다.<br>\
22565                            판매기간 제외 상품노출 기능이 사용으로 변경됩니다.<br>\
22566                            선택한 상품을 노출 시키겠습니까?';
22567
22568                            if(limitCnt > 1) modal_str = '선택된 상품 중 기간한정판매 상품이 포함되어 있습니다.<br>\
22569                                기간한정판매 상품의 판매기간 제외 상품노출 기능이 사용으로 변경됩니다.<br>\
22570                                선택한 '+limitCnt+'개의 상품을 노출 시키겠습니까?';
22571
22572                            var modal = $(this).showModalFlat($.lang[LANG]['config.information'], modal_str, true, true, function(){
22573                                $.post('/template/gallery/visible', { s: $.gallery.seqs, view: visible, mode: mode }, function (data) {
22574                                    checkError(data);
22575                                    updateItem(data.item);
22576                                },'json');
22577
22578                                var type = 'ELEM',
22579                                    checked = (visible) ? false : true;
22580                                setLogs(type,'gallery.item.visible.'+checked,'visible-'+checked,type,'product-manager','el');
22581
22582                                $.each($.gallery.seqs, function(i,v) {
22583                                    if($('.table-item').length) {
22584                                        var outDatetime = $('.gallery-items .table-item[data-seq="' + v + '"]').attr('data-out-datetime');
22585                                        switch (outDatetime) {
22586                                            case 'off':
22587                                                if(visible == '1') {
22588                                                    $('.gallery-items .table-item[data-seq="' + v + '"]').addClass('invisible').attr('data-visible','1');
22589                                                    // $('.gallery-items .table-item[data-seq="' + v + '"] .td-note').text('숨김');
22590                                                } else {
22591                                                    $('.gallery-items .table-item[data-seq="' + v + '"]').removeClass('invisible').attr('data-visible','0');
22592                                                    // $('.gallery-items .table-item[data-seq="' + v + '"] .td-note').text('');
22593                                                }
22594                                                break;
22595                                            case '0':
22596                                                if(visible == '1') {
22597                                                    $('.gallery-items .table-item[data-seq="' + v + '"]').addClass('invisible').attr('data-visible','1');
22598                                                } else {
22599                                                    $('.gallery-items .table-item[data-seq="' + v + '"]').removeClass('invisible').attr('data-visible','0');
22600                                                }
22601                                                break;
22602
22603                                            case '1':
22604                                                (visible == '1') ? $('.gallery-items .table-item[data-seq="' + v + '"]').addClass('invisible').attr('data-out-datetime','1')
22605                                                                : $('.gallery-items .table-item[data-seq="' + v + '"]').removeClass('invisible').attr('data-out-datetime','0');
22606                                                break;
22607                                        }
22608                                    } else {
22609                                        (visible == '1') ? $('.gallery-items .item[data-seq="' + v + '"]').addClass('invisible').attr('data-visible','1')
22610                                                         : $('.gallery-items .item[data-seq="' + v + '"]').removeClass('invisible').attr('data-visible','0');
22611                                    }
22612                                });
22613                                
22614                                (visible == '1') ? $this.find('i').attr('data-visible','1') : $this.find('i').attr('data-visible','0');
22615                                (visible == '1') ? $('.gallery-modal .toolbar li > i[data-cmd="visible"]').text($.lang[LANG]["editor.gallery.icon.visible.on"])
22616                                                 : $('.gallery-modal .toolbar li > i[data-cmd="visible"]').text($.lang[LANG]["editor.gallery.icon.visible.off"]);
22617                                $.gallery.update = true;
22618                                $.gallery.unlink = true;
22619                                modal.modal('hide');
22620                            }, 'cancel', 'ok', 'cl-p70 cl-cmmodal cl-s-btn w560 cl-p0');
22621
22622                            return false;
22623                        }
22624                        
22625                        $.post('/template/gallery/visible', { s: $.gallery.seqs, view: visible, mode: mode }, function (data) {
22626                            checkError(data);
22627                            updateItem(data.item);
22628                        },'json');
22629                        // showPageCallback(showPage);
22630                        var type = 'ELEM',
22631                            checked = (visible) ? false : true;
22632                        setLogs(type,'gallery.item.visible.'+checked,'visible-'+checked,type,'product-manager','el');
22633
22634                        $.each($.gallery.seqs, function(i,v) {
22635                            if($('.table-item').length) {
22636                                var outDatetime = $('.gallery-items .table-item[data-seq="' + v + '"]').attr('data-out-datetime');
22637                                switch (outDatetime) {
22638                                    case 'off':
22639                                        if(visible == '1') {
22640                                            $('.gallery-items .table-item[data-seq="' + v + '"]').addClass('invisible').attr('data-visible','1');
22641                                            // $('.gallery-items .table-item[data-seq="' + v + '"] .td-note').text('숨김');
22642                                        } else {
22643                                            $('.gallery-items .table-item[data-seq="' + v + '"]').removeClass('invisible').attr('data-visible','0');
22644                                            // $('.gallery-items .table-item[data-seq="' + v + '"] .td-note').text('');
22645                                        }
22646                                        break;
22647                                    case '0':
22648                                        if(visible == '1') {
22649                                            $('.gallery-items .table-item[data-seq="' + v + '"]').addClass('invisible').attr('data-visible','1');
22650                                        } else {
22651                                            $('.gallery-items .table-item[data-seq="' + v + '"]').removeClass('invisible').attr('data-visible','0');
22652                                        }
22653                                        break;
22654
22655                                    case '1':
22656                                        (visible == '1') ? $('.gallery-items .table-item[data-seq="' + v + '"]').addClass('invisible').attr('data-out-datetime','1')
22657                                                        : $('.gallery-items .table-item[data-seq="' + v + '"]').removeClass('invisible').attr('data-out-datetime','0');
22658                                        break;
22659                                }
22660                                // if(outDatetime != 'off') {
22661                                //     (visible == '1') ? $('.gallery-items .table-item[data-seq="' + v + '"]').addClass('invisible').attr('data-out-datetime','1')
22662                                //                     : $('.gallery-items .table-item[data-seq="' + v + '"]').removeClass('invisible').attr('data-out-datetime','0');
22663
22664                                // } else {
22665                                //     console.log($('.gallery-items .table-item[data-seq="' + v + '"] .td-note'));
22666                                //     if(visible == '1') {
22667                                //         $('.gallery-items .table-item[data-seq="' + v + '"]').addClass('invisible').attr('data-visible','1');
22668                                //         $('.gallery-items .table-item[data-seq="' + v + '"] .td-note').text('숨김');
22669                                //     } else {
22670                                //         $('.gallery-items .table-item[data-seq="' + v + '"]').removeClass('invisible').attr('data-visible','0');
22671                                //         $('.gallery-items .table-item[data-seq="' + v + '"] .td-note').text('');
22672                                //     }
22673                                // }
22674                            } else {
22675                                (visible == '1') ? $('.gallery-items .item[data-seq="' + v + '"]').addClass('invisible').attr('data-visible','1')
22676                                                 : $('.gallery-items .item[data-seq="' + v + '"]').removeClass('invisible').attr('data-visible','0');
22677                            }
22678                        });
22679
22680                        (visible == '1') ? $this.find('i').attr('data-visible','1') : $this.find('i').attr('data-visible','0');
22681                        (visible == '1') ? $('.gallery-modal .toolbar li > i[data-cmd="visible"]').text($.lang[LANG]["editor.gallery.icon.visible.on"])
22682                                         : $('.gallery-modal .toolbar li > i[data-cmd="visible"]').text($.lang[LANG]["editor.gallery.icon.visible.off"]);
22683                        // $('.gallery-toolbar').empty();
22684                        // galleryStatusInit();
22685                        $.gallery.update = true;
22686                        $.gallery.unlink = true;
22687                        // $.gallery.reset();
22688
22689                        break;
22690                    case "link":
22691                        var config_icon = ($(this).hasClass('gl-item-link')) ? 'gl-item-link' : 'gallery-item-link-icon',
22692                            seq = $(this).find('i').attr('data-glseq'),
22693                            glink = $(this).find('i').attr('data-glink'),
22694                            is_glink_target = $(this).find('i').attr('data-glink-target'),
22695                            glmode = $('.gallery-modal').attr('data-mode'),
22696                            glpid = $('.gallery-modal').attr('data-pid'),
22697                            glpage = $('.gallery-modal').attr('data-page'),
22698                            glel = $('.' + $.gallery.block_id),
22699                            prev_glink = '', input_glink = '',
22700                            target_check = (typeof is_glink_target != 'undefined' && is_glink_target == '_blank') ? 'checked' : '',
22701                            link_content = '',
22702                            glname = $.gallery.block_name;
22703
22704                        var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item';
22705                        $select_glink = $('.gallery-item[data-seq="'+seq+'"]').find('a');
22706                        if(typeof glink != 'undefined' && glink) {
22707                            if($select_glink.attr('data-user-link')) {
22708                                prev_glink = glink;
22709                            } else if ($select_glink.attr('attr-bookmark')) {
22710                                prev_glink = $select_glink.attr('href');
22711                            } else if ($select_glink.attr('attr-flink')) {
22712                                prev_glink = 'flink@' + $select_glink.attr('attr-flink');
22713                            } else if ($select_glink.attr('attr-link')) {
22714                                prev_glink = $select_glink.attr('attr-link');
22715                            } else {
22716                                prev_glink = glink;
22717                            }
22718                        }
22719                        var site_smenu = (typeof SMENU == 'undefined') ? $.gallery.SMENU : SMENU,
22720                            block_el = (typeof selectEL == 'undefined') ? $.gallery.block_el : selectEL;
22721                        link_content = '<ul class="link-content gallery edit-link-Content" data-type="' + glmode + '" data-name="' + glname + '">\
22722                                        ' + makeLinkList(site_smenu,'gallery',glname,glink);
22723                        link_content = link_content + '\
22724                            </ul>\
22725                            <div class="link-target">\
22726                                <div class="newcheckbox hand ">\
22727                                    <label>\
22728                                        <div class="newcheckboxSvg">\
22729                                            <input type="checkbox" class="img-link-target" id="linktarget-onoff" '+target_check+' data-el="'+block_el+'" />\
22730                                            <svg viewBox="0 0 16 16" width="16" height="16">\
22731                                                <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"/>\
22732                                                <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"/>\
22733                                            </svg>\
22734                                            <svg class="active" viewBox="0 0 16 16" width="16" height="16">\
22735                                                <rect x="2" y="2" class="st6" width="12" height="12"/>\
22736                                                <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"/>\
22737                                            </svg>\
22738                                        </div>\
22739                                        <span>'+ $.lang[LANG]['editor.link.open.target'] +'</span>\
22740                                    </label>\
22741                                </div>\
22742                            </div>\
22743                        \
22744                        ';
22745
22746                        var modal = $(this).showModalFlat($.lang[LANG]['editor.link.modal.title.gallery'], link_content, true, true, function() {
22747                            var input_type = $('.link-content').find('.link-type.active').children().attr('class');
22748                            var result = getInputLink(input_type);
22749                                link = result[0], isOkay = result[1], isActive = result[2], 
22750                                target_val = '', target_change = '';
22751
22752                            target_val = ($('#linktarget-onoff').prop('checked')) ? '_blank' : '';
22753                            target_change = (((target_check=='checked') ? 'on' : 'off') == ((target_val=='_blank') ? 'on' : 'off')) ? false : true;
22754
22755                            if(isOkay) {
22756                                $.each($.gallery.seqs, function(i,v) {
22757                                    if((isActive && prev_glink==link || isActive==false && prev_glink=='') && !target_change && ($.gallery.seqs).length == 1) {
22758                                        modal.modal('hide'); 
22759                                        return true;
22760                                    }
22761
22762                                    var gsettings = {
22763                                        'glink' : (checkBase64Encode(decodeURIComponent(link))) ? link : Base64.encode(link),
22764                                        'glink_target' : target_val
22765                                    }
22766                                    $.post('/template/settings', {sid: SID, settings: JSON.stringify(gsettings), el: 'gallery_settings', seq: v}, function(data) {
22767                                        checkError(data);
22768
22769                                        $select_glink.removeAttr('data-gallery').removeAttr('data-user-link').removeAttr('attr-link').removeAttr('attr-bookmark').removeAttr('attr-flink');
22770                                        $select_glink_config = $('#el-property[data-element="'+block_el+'"] #gallery-list-config');
22771
22772                                        if(link) {
22773                                            var gallery_link = makeLinkUrl(link, ONE, VIEW);
22774
22775                                            $select_glink.attr('href',gallery_link);
22776                                            if($.inArray(link.replace(/ /g,'-'),MENULIST) > -1) {
22777                                                $select_glink.attr('data-user-link',gallery_link);
22778                                            } else if(link.match(/^\@/g) !== null) {
22779                                                $select_glink.attr('attr-bookmark',link.replace(/^\@/g,''));
22780                                            } else if(link.match(/^flink\@/g) !== null) {
22781                                                $select_glink.attr('attr-flink',link.replace(/^flink\@/g,''));
22782                                            }else {
22783                                                $select_glink.attr('attr-link',link);
22784                                            }
22785
22786                                            $select_glink_config.find('.gl-item-link[data-glseq="'+v+'"]').attr('data-glink',link).addClass('active');
22787                                            if(config_icon == 'gallery-item-link-icon') $('.gallery-item-link-icon[data-glseq="'+v+'"]').attr('data-glink',link);
22788                                            
22789                                        } else {
22790                                            $select_glink_config.find('.gl-item-link[data-glseq="'+v+'"]').attr('data-glink',link).removeClass('active');
22791                                            if(config_icon == 'gallery-item-link-icon') $('.gallery-item-link-icon[data-glseq="'+v+'"]').attr('data-glink',link);
22792                                            var imgURL =  $('.gallery-item[data-seq="' + v + '"]').find('img').prop('src');
22793                                            if(glmode == 'gallery') {
22794                                                if((typeof imgURL=='undefined' || !imgURL) && glmode == 'gallery') {
22795                                                    var imgURL_popup = $('.ui-selectee[data-seq="' + v + '"]').find('img').prop('src');
22796                                                    imgURL = imgURL_popup.split('=')[0] + '=s0';
22797                                                }
22798                                                $select_glink.attr({'href': imgURL ,'data-gallery': '#gframe-' + glpid});
22799                                            } else {
22800                                                $select_glink.removeAttr('data-gallery');
22801                                                $select_glink.attr('href', '/'+CONFIG_URL+'config/page/' + glpage + '/view/' + v);
22802                                            }
22803
22804                                        }
22805
22806                                        $(group + '[data-seq="' + v + '"]').attr('data-link',Base64.decode(data.data.glink)).attr('data-target',data.data.glink_target);
22807                                        $('.gallery-modal .gallery-toolbar li [data-cmd="link"]').attr('data-glink',Base64.decode(data.data.glink)).attr('data-glink-target',data.data.glink_target);
22808                                        $('.cl_icon_link').attr('data-glink',data.data.glink).attr('data-glink-target',data.data.glink_target);
22809
22810                                        if(data.data.glink == '') {
22811                                            $('.gallery-items .item[data-seq="' + v + '"]').find('.info').remove();
22812                                            $('.gallery-items .table-item[data-seq="' + v + '"]').find('.info-link').remove();
22813                                        }
22814                                        else {
22815                                            if($('.gallery-items .item[data-seq="' + v + '"]').find('.info-link').length == 0) {
22816                                                // $('.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>');
22817                                                $('.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>');
22818                                            }
22819                                            if($('.gallery-items .table-item[data-seq="' + v + '"] .td-img .info-link').length == 0) {
22820                                                $('.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>');
22821                                            }
22822                                        }
22823
22824                                        if(target_val == '_blank') $select_glink.attr('target','_blank');
22825                                        else $select_glink.removeAttr('target');
22826                                        
22827                                        // if(target_change) {
22828                                        //     if(target_val) $select_glink.attr('target',target_val);
22829                                        //     else $select_glink.removeAttr('target');
22830                                        //     // $select_glink_config.find('.gl-item-link[data-glseq="'+seq+'"]').attr('data-glink-target',target_val);
22831                                        //     // if(config_icon == 'gallery-item-link-icon') $('.gallery-item-link-icon[data-glseq="'+seq+'"]').attr('data-glink-target',target_val);
22832                                        // }
22833
22834                                        var log_text = (isActive || !isActive && target_change) ? 'active' : 'broken',
22835                                            type = getElementType();
22836                                        setLogs(type,'gallery.link.'+log_text,'link-'+log_text,type,'product-manager','el');
22837
22838                                        // galleryStatusInit();
22839                                    }, 'json');
22840                                });
22841
22842                                modal.modal('hide');
22843                            }
22844                        } ,'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(){
22845                            $('[data-toggle="popover"]').popover();
22846                        });
22847                        break;
22848                    case "org-price":
22849                    case "disc-price":
22850                    case "sale-price":
22851                        if($this.hasClass('disabled')) return;
22852                        var price_type = cmd.replace('-price','');
22853                            selectedProduct_html = getSelectedProductList(SID,price_type,$.gallery.seqs),
22854                            config_icon = ($(this).hasClass('gl-item-discount')) ? 'gl-item-discount' : 'gallery-item-discount-icon',
22855                            seq = $(this).find('i').attr('data-glseq'),
22856                            discount = $(this).find('i').attr('data-discount'),
22857                            is_discount_target = $(this).find('i').attr('data-discount-target'),
22858                            glmode = $('.gallery-modal').attr('data-mode'),
22859                            glpid = $('.gallery-modal').attr('data-pid'),
22860                            glpage = $('.gallery-modal').attr('data-page'),
22861                            glel = $('.'+ $.gallery.block_id),
22862                            prev_discount = '', input_discount = '',
22863                            target_check = (typeof is_discount_target != 'undefined' && is_discount_target == '_blank') ? 'checked' : '';
22864                            
22865                        var price_content = '';
22866
22867                        price_content += '<div class="price_setting_box modal-contents-box">'+ selectedProduct_html + '</div>';                       
22868
22869                        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
22870                            var useDiscount = $('input[name="use_discount"]:checked').val(),
22871                                discountRate = Number(removeCommas($('#prod-price-rate').val())),
22872                                discountUnit = $('#prod-price-unit').attr('data-value');                 
22873
22874                            if($('.price_setting_box').find('.error_text').length > 0) return false;
22875
22876                            var category_type = $('.price_setting_input_box').attr('data-category'), 
22877                                price_input_val = Number(removeCommas($('#prod-price-rate').val())),
22878                                price_unit = $('#prod-price-unit').attr('data-value'),
22879                                price_mark = $('#price-setting-mark-select').attr('data-value'),
22880                                price_fixtype = (category_type=='org') ? $('input[name="pr_detail_fix_type"][checked="checked"]').attr('data-fix') : '',
22881                                ch_val = (price_mark=='change') ? price_input_val : (price_mark=='raise' ? price_input_val : -price_input_val);
22882
22883                            if(!$('.setting_product_list').hasClass('change_price')) {
22884                                modal.modal('hide');
22885                                return false;
22886                            }
22887
22888                            var route = (CONFIG_URL) ? '/_admin' : '';
22889                            // $.processON();
22890                            // $.ajax({
22891                            //     type: 'POST',
22892                            //     url : route + '/shopping/setProduct',
22893                            //     data :  unit_obj,
22894                            //     dataType : 'json',
22895                            //     async: true,
22896                            //     cache: false,
22897                            //     success : function(data) {
22898                            //         checkError(data);
22899                            //         var page = getStorageItem('gallery-product-page');
22900                            //         $.gallery.show($.gallery.block_id,page,$.gallery.cateogry);
22901                            //         $.gallery.update = true;
22902                            //         $.gallery.reset();
22903                            //         $.processOFF();
22904                            //         modal.modal('hide');
22905                            //     },
22906                            //     error : function(xhr, status, error) {
22907                            //         $.processOFF();
22908                            //         alert("Error " + xhr.status + " : 관리자
22908에게 문의");
22909                            //     }
22910                            // });
22911
22912                            var list_html = ``;
22913                            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();
22914                            $(list_items).each(function(k, v) {
22915                                list_html += `
22916                                <div class="process" data-seq="${v.seq}">
22917                                    <div class="bar">
22918                                        <div class="progressbar"></div>
22919                                    </div>
22920                                    <div class="desc">
22921                                        <span class="name" style="">${v.pname}</span>
22922                                        <div class="status">변경 중</div>
22923                                    </div>
22924                                </div>
22925                                `;
22926                            });
22927
22928                            var html = `
22929                            <div>
22930                                <div class="main-progress">
22931                                    <div class="bar">
22932                                        <div></div>
22933                                    </div>
22934                                    <div class="spin">
22935                                        <span><i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i></span>
22936                                        <div class="counter"><span>0</span>/${list_items.length}</div>
22937                                    </div>
22938                                </div>
22939                                <div class="detail-progress">
22940                                    ${list_html}
22941                                </div>
22942                            </div>
22943                            `;
22944
22945                            var total_cnt = list_items.length;
22946                            var cur_cnt = 0;
22947                            var ajaxController;
22948                            var cancelFlag = false;
22949                            var hasError = false;
22950                            var product_modal_title = '정가를 변경 중입니다.';
22951                            if(category_type == 'disc') {
22952                                product_modal_title = (price_unit == 'P') ? '할인율을 변경 중입니다.' : '할인가를 변경 중입니다.';
22953                            } else if(category_type == 'sale') {
22954                                product_modal_title = '판매가를 변경 중입니다.';
22955                            }
22956
22957                            var product_modal = $(this).showModalFlat(product_modal_title, html, true, true, function() {
22958                                product_modal.modal('hide');
22959                            },'cancel', 'ok', 'cl-cmmodal cl-product-price-setting cl-s-btn cl-p0 w700 zindex1045 cover fullcover-modal', true, function() {
22960                                // close callback
22961                                console.log('중간에 꺼버림')
22962                                if(ajaxController) ajaxController.abort();
22963                                cancelFlag = true;
22964                            },'',function(){
22965                                modal.modal('hide');
22966                                var page = getStorageItem('gallery-product-page');
22967                                $.gallery.show($.gallery.block_id,page,$.gallery.cateogry);
22968                                $.gallery.update = true;
22969                                $.gallery.reset();
22970                            });
22971
22972                            product_modal.find('.ok-button-dialog').hide();
22973
22974                            function ajaxRequest(item) {
22975                                return new Promise((resolve, reject) => {
22976                                    if(cancelFlag) {
22977                                        reject();
22978                                        return;
22979                                    }
22980                                    ajaxController = $.ajax({
22981                                        url : route + '/shopping/setProduct',
22982                                        async:false,
22983                                        dataType:'json',
22984                                        type:'post',
22985                                        data: {
22986                                            sid: SID, 
22987                                            seqs: item.seq,
22988                                            type: category_type, 
22989                                            mark : price_mark, 
22990                                            v : ch_val, 
22991                                            unit : price_unit,
22992                                            fx : category_type == 'org' ? price_fixtype : '',
22993                                        },
22994                                        success: function(response) {
22995                                            // AJAX 성공 시 애니메이션 효과 추가
22996                                            product_modal.find(`.process[data-seq="${item.seq}"]`).find('.progressbar').css('width', '100%');
22997                                            if(!response.error) {
22998                                                setTimeout(function() {
22999                                                    product_modal.find(`.process[data-seq="${item.seq}"]`).find('.status').addClass('info').text('변경 완료')
23000                                                },500);
23001                                            } else {
23002                                                hasError = true;
23003                                                setTimeout(function() {
23004                                                    product_modal.find(`.process[data-seq="${item.seq}"]`).find('.progressbar').addClass('danger');
23005                                                    product_modal.find(`.process[data-seq="${item.seq}"]`).find('.status').addClass('danger').text('변경 실패');
23006                                                    product_modal.find(`.process[data-seq="${item.seq}"]`).append(
23007                                                        `
23008                                                        <div class="desc">
23009                                                            <span class="error">
23010                                                                <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>
23011                                                                ${response.error}
23012                                                            </span>
23013                                                        </div>
23014                                                        `
23015                                                    );
23016                                                }, 500);
23017                                            }
23018                                        },
23019                                        error: function(error) {
23020                                            console.log(error);
23021                                            if(error.statusText === 'abort') {
23022                                                reject();
23023                                                return;
23024                                            }
23025                                            hasError = true;
23026                                            product_modal.find(`.process[data-seq="${item.seq}"]`).find('.progressbar').addClass('danger').css('width', '100%');
23027                                            product_modal.find(`.process[data-seq="${item.seq}"]`).find('.status').addClass('danger').text('변경 실패');
23028                                        },
23029                                        complete:function() {
23030                                            cur_cnt++;
23031                                            product_modal.find(`.main-progress .bar`).find('div').css('width', (cur_cnt/total_cnt*100) + '%');
23032                                            product_modal.find(`.main-progress .counter span`).text(cur_cnt)
23033                                            setTimeout(function() {
23034                                                resolve();
23035                                            },600);
23036                                        }
23037                                    });
23038                                });
23039                            }
23040                            async function runAjaxRequests(items) {
23041                                try {
23042                                    for (var item of items) {
23043                                        await ajaxRequest(item); // 각 요청이 완료될 때까지 기다림
23044                                    }
23045                                } catch (error) {
23046                                    console.log('중지시켜버림')
23047                                }
23048                            }
23049
23050                            setTimeout(function() {
23051                                runAjaxRequests(list_items).then(function() {
23052                                    if(cancelFlag) return;
23053                                    if(hasError) {
23054                                        product_modal.find('.ok-button-dialog').show();
23055                                        product_modal.find('.close-button-dialog').hide();
23056                                    } else {
23057                                        product_modal.modal('hide');
23058                                    }
23059                                });
23060                            },1100)
23061                        } ,'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(){
23062                            
23063                            var scrollHeight = document.querySelector('.product_contents').scrollHeight,
23064                                clientHeight = document.querySelector('.product_contents').clientHeight;
23065                                
23066                            if(scrollHeight > clientHeight) $('.product_contents').addClass('pr_scroll');
23067                            else $('.product_contents').removeClass('pr_scroll');
23068
23069                        }, function(){ //hide
23070                            // $('[data-toggle="popover"]').popover();
23071                        },true);
23072                        break;
23073                    case "badge":
23074                        var badgeInput = 'change';
23075                        var badgeArr = ['new', 'best', 'md', 'free', 'hot'];
23076                        var product_list = '';
23077                        var badge_head = '';
23078                        var badge_settings = $.parseJSON(localStorage.getItem('badge_settings'));
23079
23080                        $.each(badgeArr, function(idx, type) {
23081                            var bsettings = (typeof badge_settings[type] != 'undefined')? badge_settings[type] : {};
23082                            var badgeType = (typeof bsettings.type != 'undefined' && bsettings.type)? bsettings.type : 'edit';
23083                            var badgeStyle = (typeof bsettings.style != 'undefined' && bsettings.style)? bsettings.style : 'default-1 small';
23084                            var badgeText = (typeof bsettings.badge_text != 'undefined' && bsettings.badge_text)? bsettings.badge_text : $.lang[LANG]['gallery.shopping.badge.'+type];
23085                            var badgeBorderColor = (typeof bsettings.border_color != 'undefined' && bsettings.border_color)? bsettings.border_color : '';
23086                            var badgeBackgroundColor = (typeof bsettings.background_color != 'undefined' && bsettings.background_color)? bsettings.background_color : '';
23087                            var badgeFontColor = (typeof bsettings.font_color != 'undefined' && bsettings.font_color)? bsettings.font_color : '';
23088                            var badgeImgSrc = (typeof bsettings.image_src != 'undefined' && bsettings.image_src)? bsettings.image_src : '';
23089                            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>');
23090                            var badgeCnt = $('.table-item.ui-selected .product-badge[data-type="'+type+'"]').length;
23091                            var checkedAll = '';
23092                            if(badgeBorderColor) $badge.css('border-color', badgeBorderColor);
23093                            if(badgeBackgroundColor) $badge.css('background-color', badgeBackgroundColor);
23094                            if(badgeFontColor) $badge.css('color', badgeFontColor);
23095
23096                            if($.gallery.seqs.length == badgeCnt) {
23097                                checkedAll = 'checked';
23098                            }
23099
23100                            badge_head += '\
23101                                    <div class="divTableHead">\
23102                                        <div class="badge-view">' + $badge[0].outerHTML + '</div>\
23103                                        <div class="newcheckbox">\
23104                                            <label>\
23105                                                <input type="checkbox" class="check-all" data-type="' + type + '" '+checkedAll+'>\
23106                                                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
23107                                                    <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"/>\
23108                                                </svg>\
23109                                                <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
23110                                                    <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"/>\
23111                                                </svg>\
23112                                            </label>\
23113                                        </div>\
23114                                    </div>\
23115                            ';
23116                        });
23117                        $.each($.gallery.seqs, function(i,v) {
23118                            var badge_list = '';
23119
23120                            $.each(badgeArr, function(idx, type) {
23121                                var $badge = $('.table-item[data-seq="'+v+'"] .product-badge[data-type="'+type+'"]');
23122                                badge_list += '\
23123                                    <div class="divTableCell product-badge-item" data-seq="'+v+'">\
23124                                        <div class="newcheckbox">\
23125                                            <label>\
23126                                                <input type="checkbox" class="product-badge badge-' + type + '" data-type="' + type + '" '+ (($badge.length > 0)? 'checked' : '') +'>\
23127                                                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
23128                                                    <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"/>\
23129                                                </svg>\
23130                                                <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
23131                                                    <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"/>\
23132                                                </svg>\
23133                                            </label>\
23134                                        </div>\
23135                                    </div>\
23136                                ';
23137                            });
23138                            var num = i + 1;
23139                            product_list += '<div class="divTableRow display-flex space-between align-items-center" data-seq="' + v + '">\
23140                                <div class="divTableCell row-num">' + ((num < 10)? '0' + num : num) + '</div>\
23141                                <div class="divTableCell product-title">' + $('.table-item[data-seq="'+v+'"] .td-title .item-title-str').text() + '</div>\
23142                            ' + badge_list + '</div>';
23143                        });
23144                        var badge_content = '\
23145                            <div class="badge-setting-header display-flex space-between align-items-center">\
23146                                <h2>' + $.lang[LANG]['editor.block.gallery.product.badge'] + '</h2>\
23147                                <ul class="badge-setting-button">\
23148                                    <li class="modal-close">취소</li>\
23149                                    <li class="modal-save ok-button-dialog">저장</li>\
23150                                </ul>\
23151                            </div>\
23152                            <div class="badge-setting-table thin-scroll-bar">\
23153                                <div class="badge-setting-top display-flex space-between align-items-center">\
23154                                    <div class="row-cnt">선택목록<span>' + ($.gallery.seqs.length) + '개</span></div>\
23155                                    <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>\
23156                                </div>\
23157                                <div class="divTable">\
23158                                    <div class="divTableHeading display-flex space-between align-items-center">\
23159                                        <div class="divTableHead row-num">번호</div>\
23160                                        <div class="divTableHead product-title">상품</div>'
23161                                        + badge_head +
23162                                    '</div>\
23163                                    <div class="divTableBody">' + product_list + '</div>\
23164                                </div>\
23165                                <div class="badge-setting-bottom"></div>\
23166                            </div>\
23167                        ';
23168
23169                        var badgeSettingModal = $(this).showModalFlat('', badge_content, false, true, function() { //confirm
23170                            var same = 0;
23171                            var total = $.gallery.seqs.length;
23172                            var spos = $('.gallery-modal').scrollTop();
23173
23174                            var useBadge_obj = {};
23175                            var before_useBadge_obj = {};
23176                            var update_obj = {};
23177                            $.each($.gallery.seqs, function(i,v) {
23178                                var productName = $('.table-item[data-seq="'+v+'"] .td-title .item-title-str').text();
23179                                var useBadge = [];
23180                                var beforeUseBadge = [];
23181                                $('.product-badge-item[data-seq="'+v+'"]').each(function(idx, badge){
23182                                    var badgeType = $(badge).find('input.product-badge:checked').attr('data-type');
23183                                    if(typeof badgeType != 'undefined' && badgeType) useBadge.push(badgeType);
23184                                });
23185                                
23186                                $.each(badgeArr, function(idx, type) {
23187                                    var $badge = $('.table-item[data-seq="'+v+'"] .product-badge[data-type="'+type+'"]');
23188                                    if ($badge.length > 0) beforeUseBadge.push(type);
23189                                });
23190
23191                                if (JSON.stringify(useBadge) === JSON.stringify(beforeUseBadge)) {
23192                                    same ++;    
23193                                } else {
23194                                    update_obj[v] = useBadge;
23195                                    useBadge_obj[v] = {'pname': productName, 'use_badge': useBadge};
23196                                    before_useBadge_obj[v] = {'pname': productName, 'use_badge': beforeUseBadge};
23197                                }
23198                                
23199                            });
23200
23201                            if(total <= same) {
23202                                if($('.modal-product-badge').eq(0).hasClass('design-update')) {
23203                                    var p = $.gallery.pages;
23204                                    $.gallery.show($.gallery.block_id, p.page, '', function() {
23205                                        setTimeout(function() { 
23206                                            $('.gallery-modal').scrollTop(spos); 
23207                                        }, 200);
23208                                    });
23209
23210                                    $.gallery.update = true;
23211                                    $.gallery.reset();
23212                                }
23213
23214                                badgeSettingModal.modal('hide');
23215                                return false;
23216                            }
23217                            
23218                            $.progressON('뱃지 설정 적용중입니다...', '', '', true);
23219
23220                            var done = 0;
23221                            var progress = 0;
23222                            var route = (CONFIG_URL) ? '/_admin' : '';
23223                            total = Object.keys(update_obj).length;
23224                            $.each(update_obj, function(seq, useBadge) {
23225                                var gsettings = {'use_badge' : useBadge};
23226                                setTimeout(function(){
23227                                    $.ajax({
23228                                        type: 'POST',
23229                                        url: '/template/settings',
23230                                        data: {sid: SID, settings: JSON.stringify(gsettings),  el: 'gallery_settings', seq: seq, screenupdate: 'directupload'},
23231                                        dataType: 'json',
23232                                        async: true,
23233                                        success: function(data) {
23234                                            checkError(data);
23235                                            done++;
23236                                            progress = parseInt((done / total) * 100,10);
23237                                            $('.progressModal .progress-bar').css('width', progress+'%');
23238                                            $('.progressModal .info2').html('<span class="progressCnt">' + done + '</span>' + ' / ' + total);
23239
23240                                            if(total == done) {
23241                                                $.ajax({
23242                                                    type: 'POST',
23243                                                    url: route + '/shopping/badge_design',
23244                                                    data: {sid: SID, type: 'use_badge_slog', slog: JSON.stringify(useBadge_obj), before_slog: JSON.stringify(before_useBadge_obj)},
23245                                                    dataType: 'json',
23246                                                    async: true,
23247                                                    success: function(data) {
23248                                                    }
23249                                                });
23250
23251                                                var p = $.gallery.pages;
23252                                                setTimeout(function(){
23253                                                    $.gallery.show($.gallery.block_id, p.page, '', function() {
23254                                                        setTimeout(function() { 
23255                                                            $('.gallery-modal').scrollTop(spos); 
23256                                                        }, 200);
23257                                                    });
23258
23259                                                    $.gallery.update = true;
23260                                                    $.gallery.reset();
23261                                                    $.progressOFF();
23262
23263                                                    badgeSettingModal.modal('hide');
23264                                                }, 400);
23265                                            }
23266                                        }
23267                                    });
23268                                }, 200*done);
23269                            });
23270                        }, '', '', 'cl-cmmodal cover cl-s-btn cl-p70 cl-p0 cl-edit-badge modal-product-badge', true, '', function() { //show
23271
23272                            $(document).on('change', '.modal-product-badge-wrap .divTableHead .check-all', function() {
23273                                var type = $(this).attr('data-type');
23274                                if($(this).prop('checked') == true) {
23275                                    // $('input.check-all').prop('checked', true);
23276                                    $('.modal-product-badge-wrap input[data-type="'+type+'"]').prop('checked', true);
23277                                } else {
23278                                    $('.modal-product-badge-wrap input[data-type="'+type+'"]').prop('checked', false);
23279                                }
23280                            });
23281                            
23282                            $(document).on('change', '.modal-product-badge-wrap .product-badge-item input[type="checkbox"]', function() {
23283                                var type = $(this).attr('data-type');
23284                                if($(this).prop('checked') == true && ($.gallery.seqs.length == $('.modal-product-badge-wrap .product-badge-item input[type="checkbox"][data-type="'+type+'"]:checked').length)) {
23285                                    $('.modal-product-badge-wrap .divTableHead .check-all[data-type="'+type+'"]').prop('checked', true);
23286                                } else {
23287                                    $('.modal-product-badge-wrap .divTableHead .check-all[data-type="'+type+'"]').prop('checked', false);
23288                                }
23289                            });
23290
23291                            var chBadgeDsgnContent = '\
23292                            <div class="badge-setting-header display-flex space-between align-items-center">\
23293                                <h2>뱃지 디자인 변경</h2>\
23294                                <ul class="badge-setting-button">\
23295                                    <li class="modal-close">취소</li>\
23296                                    <li class="modal-save ok-button-dialog">저장</li>\
23297                                </ul>\
23298                            </div>\
23299                            <div class="badge-setting-top display-flex space-between">\
23300                                <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.
2330018 17c3.87 0 7-3.13 7-7s-3.14-7-7-7z"></path></svg>뱃지 디자인 초기화</div>\
23301                            </div>\
23302                            <div class="divTable">\
23303                                <div class="divTableHeading display-flex space-between align-items-center">\
23304                                    <div class="divTableHead">뱃지</div>\
23305                                    <div class="divTableHead">스타일</div>\
23306                                    <div class="divTableHead">문구</div>\
23307                                    <div class="divTableHead">선</div>\
23308                                    <div class="divTableHead">ë°°ê²½</div>\
23309                                    <div class="divTableHead">텍스트</div>\
23310                                </div>\
23311                                <div class="divTableBody">\
23312                                </div>\
23313                            </div>\
23314                            \
23315                            ';
23316
23317                            // $('.modal-product-badge-wrap .return-prev-setting').on('click', function(){
23318                            //     $('.divTableCell.product-badge-item input[type="checkbox"]').prop('checked', false);
23319                            //     $.each($.gallery.seqs, function(i,v) {
23320                            //         $.each(badgeArr, function(idx, type) {
23321                            //             var $badge = $('.table-item[data-seq="'+v+'"] .product-badge[data-type="'+type+'"]');
23322                            //             var checked = ($badge.length > 0)? 'checked' : '';
23323                            //             $('.divTableCell.product-badge-item[data-seq="'+v+'"] input.product-badge[data-type="'+type+'"]').prop('checked', checked);
23324
23325                            //             var badgeCnt = $('.table-item.ui-selected .product-badge[data-type="'+type+'"]').length;
23326                            //             if($.gallery.seqs.length == badgeCnt) {
23327                            //                 $('.check-all[data-type="'+type+'"]').prop('checked', checked);
23328                            //             }
23329                            //         });
23330                            //     });
23331
23332                            //     var settings = localStorage.getItem('badge_settings');
23333                            //     var before_settings = localStorage.getItem('before_badge_settings');
23334                            //     $('.modal-product-badge').eq(0).addClass('return-prev');
23335                            //     localStorage.setItem('badge_settings', before_settings);
23336                            //     $.badgeSettings.init($.parseJSON(before_settings));
23337
23338                            //     // $.ajax({
23339                            //     //     type: 'POST',
23340                            //     //     url: '/shopping/badge_design',
23341                            //     //     data: { sid: SID, type: 'add', settings: before_settings, before_settings: settings },
23342                            //     //     dataType: 'json',                    
23343                            //     //     async: true,
23344                            //     //     success: function(data) {
23345                            //     //         localStorage.setItem('badge_settings', before_settings);
23346                            //     //         $.badgeSettings.init($.parseJSON(before_settings));
23347                            //     //     }
23348                            //     // });
23349                            // });
23350
23351                            $(document).off('click', '.modal-product-badge-wrap .change-badge-design');
23352                            $(document).on('click', '.modal-product-badge-wrap .change-badge-design', function(e){
23353                                e.stopPropagation();
23354                                if($('.cl-change-badge-design').length > 0) return false;
23355                                var chBadgeModal = $(this).showModalFlat('', chBadgeDsgnContent, false, true, function(){ //confirm
23356                                    var before_settings = localStorage.getItem('before_badge_settings');
23357                                    var input_data = new Object();
23358                                    $('.badge-option-row').each(function(idx, v) {
23359                                        var key = $(v).attr('data-default');
23360                                        input_data[key] = {
23361                                            'type': $(v).find('input[name="type"]').val(),
23362                                            'style': ($(v).find('input[name="type"]').val() == 'edit')? $(v).find('input[name="style"]').val() : '',
23363                                            'badge_text': $(v).find('input[name="badge_text"]').val(),
23364                                            'border_color': $(v).find('input[name="border_color"]').val(),
23365                                            'background_color': $(v).find('input[name="background_color"]').val(),
23366                                            'font_color': $(v).find('input[name="font_color"]').val(),
23367                                            'image_src': $(v).find('input[name="image_src"]').val(),
23368                                            'image_name': $(v).find('input[name="image_name"]').val(),
23369                                        };
23370                                    });
23371                                    var isReset = $('.cl-change-badge-design').hasClass('reset-design');
23372                                    var route = (CONFIG_URL) ? '/_admin' : '';
23373                                    $.ajax({
23374                                        type: 'POST',
23375                                        url: route + '/shopping/badge_design',
23376                                        data: { sid: SID, type: 'add', settings: JSON.stringify(input_data), before_settings: before_settings, is_reset: isReset},
23377                                        dataType: 'json',                    
23378                                        async: true,
23379                                        success: function(data) {
23380                                            if(Object.keys(data).length > 0) {
23381                                                // console.log(data);
23382                                                var badge_settings = data;
23383                                                $.badgeSettings.init(badge_settings);
23384                                                localStorage.setItem('badge_settings', JSON.stringify(badge_settings));
23385                                                $('.modal-product-badge').eq(0).addClass('design-update');
23386                                                $.gallery.update = true;
23387                                            }
23388
23389                                            chBadgeModal.modal('hide');
23390                                        }
23391                                    });
23392                                }, '', '', 'cl-cmmodal cover cl-s-btn cl-p70 cl-p0 cl-edit-badge cl-change-badge-design modal-product-badge', true, '', function() { //show
23393                                    var badge_settings = $.parseJSON(localStorage.getItem('badge_settings'));
23394                                    var changeBadgeDsgnRow = $.badgeSettings.initDesign(badgeArr, badge_settings);
23395                                    $('.cl-change-badge-design .divTableBody').html(changeBadgeDsgnRow);
23396                                    $('.cl-change-badge-design .divTable').after('<div class="text-right">※ 뱃지 디자인 변경 시, 모든 갤러리 블럭의 뱃지 디자인에 반영됩니다.</div>');
23397
23398                                    $('.cl-change-badge-design').closest('.modal-default').css('z-index', 1043);
23399                                    // $('.cl-change-badge-design').closest('.cl-common-modal').next('.modal-backdrop.fade.in').css('z-index', 1044);
23400
23401                                    $('.badge-option-row').each(function(idx, v){
23402                                        if($(v).find('input[name="type"]').val() == 'edit') {
23403                                            var $badge = $(v).find('.product-badge');
23404                                            var badgeBorderColor = style.getHex($badge.css('border-color'));
23405                                            var badgeBackgroundColor = style.getHex($badge.css('background-color'));
23406                                            var badgetextColor = style.getHex($badge.css('color'));
23407                                            
23408                                            $(v).find('.color-picker-badge[pn="border-color"]').css('background-color', badgeBorderColor);
23409                                            $(v).find('.color-picker-badge[pn="background-color"]').css('background-color', badgeBackgroundColor);
23410                                            $(v).find('.color-picker-badge[pn="color"]').css('background-color', badgetextColor);
23411                                        }
23412                                    });
23413
23414                                    $('input[name="badge_text"]').on({
23415                                        focusout: function(){
23416                                            $('.cl-change-badge-design').removeClass('reset-design');
23417                                            // $('.modal-product-badge').eq(0).removeClass('return-prev');
23418
23419                                            var badgeText = $(this).val().trim();
23420                                            if(badgeText) $(this).closest('.badge-option-row').find('.product-badge').text(badgeText);
23421                                        },
23422                                        keyup: function(e){
23423                                            if(e.keyCode == 13) {
23424                                                $('.cl-change-badge-design').removeClass('reset-design');
23425                                                // $('.modal-product-badge').eq(0).removeClass('return-prev');
23426
23427                                                var badgeText = $(this).val().trim();
23428                                                if(badgeText) $(this).closest('.badge-option-row').find('.product-badge').text(badgeText);
23429                                            }
23430                                        }
23431                                    });
23432
23433                                    setBadgeColorPicker();
23434
23435                                    //뱃지 스타일 변경
23436                                    $(document).off('click', '.modal-product-badge-wrap .cl-change-badge-design .select-style-btn');
23437                                    $(document).on('click', '.modal-product-badge-wrap .cl-change-badge-design .select-style-btn', function(){
23438                                        var uploadedImgs = '';
23439                                        if(localStorage.getItem('badge_imgs')) {
23440                                            var uploadedImgsArr = localStorage.getItem('badge_imgs').split('||');
23441                                            // console.log(uploadedImgsArr);
23442                                            $.each(uploadedImgsArr, function(idx, v){
23443                                                var img = v.split('::');
23444                                                var src = (typeof img[1] != 'undefined') ? img[1] : img[0];
23445                                                uploadedImgs += '\
23446                                                <div class="select-badge user-upload hand">\
23447                                                    <span class="product-badge"><img src="'+src+'" alt="'+img[0]+'"></span>\
23448                                                    <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>\
23449                                                </div>';
23450                                            });
23451                                        }
23452                                        var badgeStylePopup = '\
23453                                        <div class="badge-style-popup">\
23454                                            <div class="badge-style-header display-flex align-items-center space-between">\
23455                                                <div class="badge-style-title">스타일 선택</div>\
23456                                                <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
23456-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>\
23457                                            </div>\
23458                                            <ul class="badge-type-tab display-flex align-items-center">\
23459                                                <li class="hand active" data-tab="edit">편집형</li>\
23460                                                <li class="hand" data-tab="image">이미지형</li>\
23461                                            </ul>\
23462                                            <div class="badge-type-tab-content badge-tab-edit">\
23463                                                <div class="badge-size-tab display-flex align-items-center">\
23464                                                    <span class="select-badge-size hand active" data-size="small">작은</span>\
23465                                                    <span>·</span>\
23466                                                    <span class="select-badge-size hand" data-size="medium">중간</span>\
23467                                                    <span>·</span>\
23468                                                    <span class="select-badge-size hand" data-size="large">큰</span>\
23469                                                </div>\
23470                                                <div class="select-badge-table display-flex" data-size="small">\
23471                                                    <div class="hand select-badge selected" data-style="default-1"><span class="product-badge default-1 small">NEW</span></div>\
23472                                                    <div class="hand select-badge" data-style="red-1"><span class="product-badge red-1 small">NEW</span></div>\
23473                                                    <div class="hand select-badge" data-style="blue-1"><span class="product-badge blue-1 small">NEW</span></div>\
23474                                                    <div class="hand select-badge" data-style="black-1"><span class="product-badge black-1 small">NEW</span></div>\
23475                                                    \
23476                                                    <div class="hand select-badge" data-style="default-2"><span class="product-badge default-2 small">NEW</span></div>\
23477                                                    <div class="hand select-badge" data-style="red-2"><span class="product-badge red-2 small">NEW</span></div>\
23478                                                    <div class="hand select-badge" data-style="blue-2"><span class="product-badge blue-2 small">NEW</span></div>\
23479                                                    <div class="hand select-badge" data-style="black-2"><span class="product-badge black-2 small">NEW</span></div>\
23480                                                    \
23481                                                    <div class="hand select-badge" data-style="default-3"><span class="product-badge default-3 small">NEW</span></div>\
23482                                                    <div class="hand select-badge" data-style="red-3"><span class="product-badge red-3 small">NEW</span></div>\
23483                                                    <div class="hand select-badge" data-style="blue-3"><span class="product-badge blue-3 small">NEW</span></div>\
23484                                                    <div class="hand select-badge" data-style="black-3"><span class="product-badge black-3 small">NEW</span></div>\
23485                                                    \
23486                                                    <div class="hand select-badge" data-style="default-4"><span class="product-badge default-4 small">NEW</span></div>\
23487                                                    <div class="hand select-badge" data-style="red-4"><span class="product-badge red-4 small">NEW</span></div>\
23488                                                    <div class="hand select-badge" data-style="blue-4"><span class="product-badge blue-4 small">NEW</span></div>\
23489                                                    <div class="hand select-badge" data-style="black-4"><span class="product-badge black-4 small">NEW</span></div>\
23490                                                    \
23491                                                    <div class="hand select-badge" data-style="default-5"><span class="product-badge default-5 small">NEW</span></div>\
23492                                                    <div class="hand select-badge" data-style="red-5"><span class="product-badge red-5 small">NEW</span></div>\
23493                                                    <div class="hand select-badge" data-style="blue-5"><span class="product-badge blue-5 small">NEW</span></div>\
23494                                                    <div class="hand select-badge" data-style="black-5"><span class="product-badge black-5 small">NEW</span></div>\
23495                                                    \
23496                                                    <div class="hand select-badge" data-style="default-6"><span class="product-badge default-6 small">NEW</span></div>\
23497                                                    <div class="hand select-badge" data-style="red-6"><span class="product-badge red-6 small">NEW</span></div>\
23498                                                    <div class="hand select-badge" data-style="blue-6"><span class="product-badge blue-6 small">NEW</span></div>\
23499                                                    <div class="hand select-badge" data-style="black-6"><span class="product-badge black-6 small">NEW</span></div>\
23500                                                    \
23501                                                    <div class="hand select-badge" data-style="red-7"><span class="product-badge red-7 small">NEW</span></div>\
23502                                                    <div class="hand select-badge" data-style="red-8"><span class="product-badge red-8 small">NEW</span></div>\
23503                                                    <div class="hand select-badge" data-style="red-9"><span class="product-badge red-9 small">NEW</span></div>\
23504                                                    <div class="hand select-badge" data-style="blue-7"><span class="product-badge blue-7 small">NEW</span></div>\
23505                                                    <div class="hand select-badge" data-style="blue-8"><span class="product-badge blue-8 small">NEW</span></div>\
23506                                                    <div class="hand select-badge" data-style="blue-9"><span class="product-badge blue-9 small">NEW</span></div>\
23507                                                </div>\
23508                                            </div>\
23509                                            <div class="badge-type-tab-content badge-tab-image hide">\
23510                                                <div class="select-badge-table display-flex">\
23511                                                    <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>\
23512                                                    <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>\
23513                                                    <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>\
23514                                                    <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>\
23515                                                    \
23516                                                    <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>\
23517                                                    <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>\
23518                                                    <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>\
23519                                                    <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>\
23520                                                    \
23521                                                    <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>\
23522                                                    <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>\
23523                                                    <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>\
23524                                                    <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>\
23525                                                    \
23526                                                    <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>\
23527                                                    <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>\
23528                                                    <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>\
23529                                                    <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>\
23530                                                    \
23531                                                    <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>\
23532                                                    <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>\
23533                                                    <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>\
23534                                                    <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>\
23535                                                    \
23536                                                    ' + uploadedImgs + '\
23537                                                </div>\
23538                                                <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>\
23539                                            </div>\
23540                                            <div class="badge-style-footer display-flex align-items-center">\
23541                                                <span class="hide">권장 이미지 높이 : 20px 이하</span>\
23542                                                <ul class="display-flex align-items-center">\
23543                                                    <li class="modal-close hand">취소</li>\
23544                                                    <li class="modal-save hand">저장</li>\
23545                                                </ul>\
23546                                            </div>\
23547                                        </div>\
23548                                        ';
23549
23550                                        $('.badge-style-popup').remove();
23551                                        $(this).toggleClass('active');
23552                                        if($(this).hasClass('active')) {
23553                                            $(this).after(badgeStylePopup);
23554                                            $.badgeSettings.initStylePopup($(this));
23555                                        }
23556                                    });
23557                                    
23558                                    $('.modal-product-badge-wrap .cl-change-badge-design .return-default-design').on('click', function(e) {
23559                                        e.stopPropagation();
23560                                        if($('.cl-reset-badge-design').length > 0) return false;
23561                                        var modal = $(this).showModalFlat('뱃지 디자인 초기화', '모든 갤러리 블록에 적용된 뱃지 디자인이 초기화됩니다.<br>정말 초기화하시겠습니까?', true, true, function(){ //confirm
23562                                            $('.badge-option-row').each(function(idx, v){
23563                                                var $badge = $(v).find('.product-badge-view > .product-badge');
23564                                                var defaultType = $(v).attr('data-default');
23565                                                $badge.attr('class', 'product-badge default-1 small');
23566                                                $badge.removeAttr('style');
23567                                                $badge.html($.lang[LANG]['gallery.shopping.badge.'+defaultType]);
23568
23569                                                $(v).find('input[name="badge_text"]').prop('disabled', false);
23570                                                $(v).find('input[name="badge_text"]').val($.lang[LANG]['gallery.shopping.badge.'+defaultType]);
23571                                                $(v).find('input[name="type"]').val('edit');
23572                                                $(v).find('input[name="style"]').val('default-1 small');
23573                                                $(v).find('input[name="border_color"]').val('#bebebe');
23574                                                $(v).find('input[name="background_color"]').val('#ffffff');
23575                                                $(v).find('input[name="font_color"]').val('#000000');
23576                                                $(v).find('input[name="image_src"]').val('');
23577                                                $(v).find('input[name="image_name"]').val('');
23578
23579                                                $(v).find('.color-picker-badge').removeClass('disabled');
23580                                                $(v).find('.color-picker-badge[pn="border-color"]').css('background-color', '#bebebe');
23581                                                $(v).find('.color-picker-badge[pn="background-color"]').css('background-color', '#ffffff');
23582                                                $(v).find('.color-picker-badge[pn="color"]').css('background-color', '#000000');
23583                                            });
23584                                            $('.cl-change-badge-design').addClass('reset-design');
23585                                            modal.modal('hide');
23586                                        }, 'cancel', 'ok', 'cl-cmmodal cl-reset-badge-design cl-s-btn w560 cl-p70 cl-p0', false, '', function(){ //show
23587                                            $('.cl-reset-badge-design').closest('.modal-default').css('z-index', 1046);
23588                                            $('.cl-reset-badge-design').closest('.cl-common-modal').next('.modal-backdrop.fade.in').css('z-index', 1045);
23589                                        });
23590                                        
23591                                    });
23592
23593                                    $(document).off('click', '.badge-style-popup .modal-save');
23594                                    $(document).on('click', '.badge-style-popup .modal-save', function(){
23595                                        var $selectedBadge = $('.badge-style-popup .badge-type-tab-content:not(.hide) .select-badge-table .select-badge.selected');
23596                                        if($selectedBadge.length > 0) $.badgeSettings.handleSelection($selectedBadge);
23597
23598                                        $('.select-style-btn').removeClass('active');
23599                                        $('.badge-style-popup').remove();
23600                                    });
23601
23602                                    $(document).off('click', '.badge-style-popup .modal-close');
23603                                    $(document).on('click', '.badge-style-popup .modal-close', function(){
23604                                        $('.select-style-btn').removeClass('active');
23605                                        $('.badge-style-popup').remove();
23606                                    });
23607
23608                                    // $('.cl-change-badge-design .modal-body').off('click');
23609                                    // $('.cl-change-badge-design .modal-body').on('click', function(e){
23610                                    //     if(!$(e.target).is('.select-style-btn') && $(e.target).closest('.badge-style-popup').length == 0) {
23611                                    //         $('.select-style-btn').removeClass('active');
23612                                    //         $('.badge-style-popup').remove();
23613                                    //     }
23614                                    // });
23615
23616                                    $(document).off('click', '.badge-type-tab > li');
23617                                    $(document).on('click', '.badge-type-tab > li', function(){ //편집형, 이미지형 탭
23618                                        var optionIdx = $(this).closest('.badge-option-row').attr('data-idx');
23619                                        var badgeText = $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="badge_text"]').val();
23620                                        var badgeType = $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="type"]').val();
23621                                        var badgeStyle = $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="style"]').val();
23622                                        var badgeStyleArr = badgeStyle.split(' ');
23623                                        var style = badgeStyleArr[0];
23624                                        var size = badgeStyleArr[1];
23625
23626                                        $('.badge-type-tab > li').removeClass('active');
23627                                        $(this).addClass('active');
23628                                        $('.badge-type-tab-content').addClass('hide');
23629                                        $('.badge-style-popup .badge-style-footer > span').addClass('hide');
23630
23631                                        $('.badge-tab-' + $(this).attr('data-tab')).removeClass('hide');
23632                                        if($(this).attr('data-tab') == 'edit') {
23633                                            if(!style) style = 'default-1';
23634                                            if(!size) {
23635                                                size = 'small';
23636                                                $('.badge-size-tab .select-badge-size').removeClass('active');
23637                                                $('.badge-size-tab .select-badge-size[data-size="'+size
23637+'"]').addClass('active');
23638                                                $('.select-badge-table').attr('data-size', size);
23639                                            }
23640                                            if(!badgeText) badgeText = $.lang[LANG]['gallery.shopping.badge.'+ $(this).closest('.badge-option-row').attr('data-default')]
23641                                            $('.badge-style-popup .badge-tab-edit .select-badge .product-badge').html(badgeText);
23642                                            $('.badge-style-popup .badge-tab-edit .select-badge .product-badge').addClass(size);
23643                                        } else {
23644                                            $('.badge-style-popup .badge-style-footer > span').removeClass('hide');
23645                                            $('.badge-style-popup .select-badge-table .product-badge').removeClass('small medium large');
23646                                        }
23647                                    });
23648
23649                                    $(document).off('click', '.badge-style-popup .badge-size-tab .select-badge-size');
23650                                    $(document).on('click', '.badge-style-popup .badge-size-tab .select-badge-size', function() { //뱃지 사이즈 탭
23651                                        $('.badge-size-tab .select-badge-size').removeClass('active');
23652                                        $(this).addClass('active');
23653
23654                                        var badgeSize = $(this).attr('data-size');
23655                                        $('.select-badge-table').attr('data-size', badgeSize);
23656                                        $('.select-badge-table .product-badge').removeClass('small medium large');
23657                                        $('.select-badge-table .product-badge').addClass(badgeSize);
23658                                    });
23659
23660                                    $(document).off('click', '.badge-style-popup .select-badge-table .select-badge');
23661                                    $(document).on('click', '.badge-style-popup .select-badge-table .select-badge', function() {
23662                                        if($(this).find('.product-badge > img').attr('src') == '//storage.googleapis.com/i.addblock.net/icon_broken_img.png') {
23663                                            return false;
23664                                        }
23665                                        $('.badge-style-popup .select-badge-table .select-badge').removeClass('selected');
23666                                        $(this).addClass('selected');
23667
23668                                        // $.badgeSettings.handleSelection($(this));
23669                                    });
23670
23671                                    $(document).off('click', '.badge-style-popup .select-badge-table .select-badge .delete-badge');
23672                                    $(document).on('click', '.badge-style-popup .select-badge-table .select-badge .delete-badge', function() {
23673                                        var $this = $(this);
23674                                        var modal = $(this).showModalFlat('뱃지 이미지 삭제', '선택한 이미지를 삭제하시겠습니까?', true, true, function(){ //confirm
23675                                            var optionIdx = Number($this.closest('.badge-option-row').attr('data-idx'));
23676                                            var imgSrc = $this.closest('.select-badge').find('img').attr('src');
23677                                            var imgName = $this.closest('.select-badge').find('img').attr('alt');
23678                                            var beforeImgSrcArr = $('.badge-option-row input[name="image_src"]').map(function(idx, v){
23679                                                return $(v).val();
23680                                            }).get();
23681                                            // console.log(optionIdx, imgSrc, beforeImgSrcArr);
23682                                            $this.closest('.select-badge').remove();
23683                                            
23684                                            var badgeImgsArr = new Array();
23685                                            $('.badge-tab-image .select-badge-table .select-badge.user-upload .product-badge img').each(function(idx, v){
23686                                                var imgData = (typeof $(v).attr('alt') != 'undefined' && $(v).attr('alt')) ? $(v).attr('alt') + '::' + $(v).attr('src') : $(v).attr('src');
23687                                                badgeImgsArr.push(imgData);
23688                                            });
23689                                            // console.log('badgeImgsArr', badgeImgsArr);
23690                                            var badge_imgs = (badgeImgsArr.length > 0)? badgeImgsArr.join('||') : '';
23691                                            var route = (CONFIG_URL) ? '/_admin' : '';
23692                                            $.ajax({
23693                                                type: 'POST',
23694                                                url: route + '/shopping/badge_design',
23695                                                data: { sid: SID, type: 'delete-image', settings: badge_imgs, file_name: imgName, },
23696                                                dataType: 'json',                    
23697                                                async: true,
23698                                                success: function(data) {
23699                                                    // console.log(data);
23700                                                    localStorage.setItem('badge_imgs', badge_imgs);
23701                                                    var imgIdx = beforeImgSrcArr.indexOf(imgSrc);
23702
23703                                                    if(imgIdx > -1) {
23704                                                        var badgeText = $('.badge-option-row[data-idx="'+imgIdx+'"] input[name="badge_text"]').val();
23705
23706                                                        if(imgIdx == optionIdx) {
23707                                                            $('.badge-style-popup .select-badge-table .select-badge').removeClass('selected');
23708                                                            $('.badge-style-popup .badge-tab-edit .select-badge-table').attr('data-size', 'small');
23709                                                            $('.badge-style-popup .badge-tab-edit .select-badge-table .select-badge .product-badge').addClass('small');
23710                                                            $('.badge-style-popup .badge-tab-edit .select-badge-table .select-badge .product-badge').html(badgeText);
23711
23712                                                            var defaultBadge = $('.badge-style-popup .badge-tab-edit .select-badge-table[data-size="small"] .select-badge[data-style="default-1"]');
23713                                                            defaultBadge.addClass('selected');
23714                                                            // console.log('defaultBadge', defaultBadge);
23715                                                            $.badgeSettings.handleSelection(defaultBadge);
23716                                                        } else {
23717                                                            var badgeEL = $('<span class="product-badge default-1 small">' + badgeText + '</span>');
23718                                                            $('.badge-option-row[data-idx="'+imgIdx+'"] .product-badge-view').html(badgeEL);
23719
23720                                                            $('.badge-option-row[data-idx="'+imgIdx+'"]').find('.color-picker-badge').removeClass('disabled');
23721                                                            $('.badge-option-row[data-idx="'+imgIdx+'"]').find('input[name="badge_text"]').prop('disabled', false);
23722
23723                                                            $('.badge-option-row[data-idx="'+imgIdx+'"]').find('.color-picker-badge[pn="border-color"]').css('background-color', '#bebebe');
23724                                                            $('.badge-option-row[data-idx="'+imgIdx+'"]').find('.color-picker-badge[pn="background-color"]').css('background-color', '#ffffff');
23725                                                            $('.badge-option-row[data-idx="'+imgIdx+'"]').find('.color-picker-badge[pn="color"]').css('background-color', '#000000');
23726
23727                                                            $('.badge-option-row[data-idx="'+imgIdx+'"] input[name="type"]').val('edit');
23728                                                            $('.badge-option-row[data-idx="'+imgIdx+'"] input[name="style"]').val('default-1 small');
23729                                                            $('.badge-option-row[data-idx="'+imgIdx+'"] input[name="border_color"]').val('#bebebe');
23730                                                            $('.badge-option-row[data-idx="'+imgIdx+'"] input[name="background_color"]').val('#ffffff');
23731                                                            $('.badge-option-row[data-idx="'+imgIdx+'"] input[name="font_color"]').val('#000000');
23732                                                            $('.badge-option-row[data-idx="'+imgIdx+'"] input[name="image_src"]').val('');
23733                                                            $('.badge-option-row[data-idx="'+imgIdx+'"] input[name="image_name"]').val('');
23734                                                        }
23735                                                    }
23736                                                }
23737                                            });
23738                                            modal.modal('hide');
23739                                        }, 'cancel', 'ok', 'cl-cmmodal cl-delete-badge-image cl-s-btn w560 cl-p70 cl-p0', false);
23740                                    });
23741                                    $(document).on('click', '.upload-badge-image', function(){
23742                                        setResourceBtn(true,{maxcount:0, property:'upload-badge-image', element:'.product-badge'});
23743                                    });
23744                                    
23745                                    
23746                                }, function(){ //hide
23747                                    $('[data-toggle="popover"]').popover();
23748                                });
23749                                
23750                                $('.cl-change-badge-design .badge-setting-button > .modal-close').on('click', function() { 
23751                                    chBadgeModal.modal('hide');
23752                                });
23753                            });
23754                        }, function(){ //hide
23755                            $('[data-toggle="popover"]').popover();
23756                        });
23757
23758                        $('.modal-product-badge-wrap .badge-setting-header .modal-close').on('click', function() {
23759                            badgeSettingModal.modal('hide');
23760                            if($(this).closest('.modal-product-badge').hasClass('design-update')) $.gallery.show($.gallery.block_id);
23761                        });
23762
23763                        break;
23764                    case "margin":
23765                        var route = (CONFIG_URL) ? '/_admin' : '';
23766                        var firstItem = $('.gallery-items .table-item.ui-selected').eq(0),
23767                            margin_rate = firstItem.find('.margin-info .rate').text().trim().replace(/[^0-9.]/g,'') * 1,
23768                            margin_add = firstItem.find('.margin-info .add').text().trim().replace(/[^0-9.]/g,'') * 1,
23769                            margin_seqs = $.gallery.seqs,
23770                            margin_html = '\
23771                                <ul>\
23772                                    <li>\
23773                                        <span class="title">마진율</span>\
23774                                        <span class="prod-margin-price cal-margin">\
23775                                            <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>\
23776                                            <input type="text" class="prod-user-margin input-margin" value="'+ margin_rate +'" numberOnly>%\
23777                                            <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>\
23778                                        </span>\
23779                                    </li>\
23780                                    <li>\
23781                                        <span class="title">마진값</span>\
23782                                        <span class="prod-margin-price cal-price">\
23783                                            <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>\
23784                                            <input type="text" class="prod-user-price input-margin" value="'+ addCommas(margin_add) +'" numberOnly>원\
23785                                            <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>\
23786                                        </span>\
23787                                    </li>\
23788                                </ul>\
23789                            ';
23790
23791                        var marginModal = $(this).showModalFlat('마진 설정', margin_html, true, true, function() {
23792                            var new_mrate = marginModal.find('.prod-user-margin').val().trim().replace(/[^0-9.]/g,'') * 1,
23793                                new_madd = marginModal.find('.prod-user-price').val().trim().replace(/[^0-9.]/g,'') * 1;
23794                            $.processON();
23795                            setTimeout(function() {
23796                                $.post(route + '/shopping/setMargin', {sid: SID, seqs: margin_seqs, rate: new_mrate, val: new_madd}, function(data) {
23797                                    if(typeof data.error != 'undefined' && data.error) {
23798                                        var marginError = $(this).showModalFlat('ERROR','실패',true,false,'','close','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0');
23799                                        marginModal.modal('hide');
23800                                        return false;
23801                                    }
23802
23803                                    var changed_seqs = margin_seqs;
23804                                    $('.gallery-modal .table-item.ui-selected').each(function() {
23805                                        // if($.inArray($(this).attr('data-seq'), margin_seqs.i) > -1 || $.inArray($(this).attr('data-seq'), margin_seqs.u) > -1) {
23806                                        if($.inArray($(this).attr('data-seq'), data.list.edit) > -1) {
23807                                            var p_retail = $(this).find('.td-title .add-info .sale-rate').attr('data-retail').trim() * 1,
23808                                                p_supply = $(this).find('.td-title .add-info .margin-info .price').attr('data-supply').trim() * 1,
23809                                                tmp_cal = p_supply * (new_mrate/100),
23810                                                tmp_five = (tmp_cal - Math.floor(tmp_cal) == 0.5) ? true : false,
23811                                                tmp_r = (tmp_five) ? Math.floor(tmp_cal) : Math.round(tmp_cal),
23812                                                new_margin = tmp_r + new_madd,
23813                                                new_price = p_supply + new_margin,
23814                                                new_srate = (p_retail - new_price > 0) ? Math.floor((p_retail - new_price) / p_retail  * 100) : 0;
23815
23816                                            var new_price_span = (new_price > 0) ? '<span class="price-val">' + addCommas(new_price) + '원</span>' : '<span class="price-val">-</span>',
23817                                                new_srate_span = (new_price < p_retail) ? '할인율 <span class="rate">' + new_srate + '</span>%' : '',
23818                                                new_sale_span = (new_price < p_retail) ? '<span class="price-sale">' + addCommas(p_retail) + '원</span>' : '';
23819
23820                                            var p_name = $(this).find('.td-title .item-title-str').text().trim(),
23821                                                p_seq = $(this).attr('data-seq'),
23822                                                pid = $(this).closest('.gallery-modal').attr('data-pid'),
23823                                                before_margin = '미지정',
23824                                                after_margin = '마진율 : ' + new_mrate + '% / 마진값 : ' + addCommas(new_madd) + '원';
23825                                            
23826                                            if($(this).find('.margin-info .rate').length > 0) {
23827                                                var old_mrate = $(this).find('.margin-info .rate').text().trim().replace(/[^0-9.]/g,'') * 1,
23828                                                    old_madd = $(this).find('.margin-info .add').text().trim().replace(/[^0-9.]/g,'') * 1,
23829                                                    before_margin = '마진율 : ' + old_mrate + '% / 마진값 : ' + addCommas(old_madd) + '원';
23830                                            }
23831                                            var slog_obj = {'pname':p_name, 'seq':p_seq, 'pid':pid, 'supply_price': addCommas(p_supply)+'원', 'before_margin':before_margin, 'margin':after_margin};
23832                                            setSiteLogs('sh.product.edit','margin',slog_obj,'sh.config',p_seq);
23833
23834                                            $(this).attr('data-pcase','M');
23835                                            $(this).find('.td-title .add-info .sale-rate').html(new_srate_span);
23836                                            $(this).find('.td-title .add-info .margin-info .rate').text(new_mrate);
23837                                            $(this).find('.td-title .add-info .margin-info .add').text(addCommas(new_madd));
23838                                            $(this).find('.td-title .add-info .margin-info .price').text(addCommas(new_margin));
23839                                            $(this).find('.td-price').html(new_price_span + new_sale_span);
23840                                        }
23841
23842                                    });
23843
23844                                    $.processOFF();
23845                                    marginModal.modal('hide');
23846
23847                                    if(typeof data.list.error != 'undefined' && data.list.error.length > 0) {
23848                                        var error_msg = '판매가가 10억이 넘게 적용되는 일부 상품(들)이 존재합니다.<br>마진 설정은 최종 판매가가 10억 이하의 상품들에만 적용되고,<br>10억이 넘는 상품들은 가격 또는 마진 설정을 재 검토해 주세요.';
23849                                        // var error_msg = (data.list.error.length == $.gallery.seqs.length) ? '문구요청1. 선택 상품 마진 변경 불가. 금액 10억 이상 이라서' : '문구요청1. 선택 상품 중 일부 상품 마진 변경 불가. 금액 10억 이상 이라서';
23850                                        $(this).showModalFlat('마진 설정', error_msg, true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0 cl-shopping-margin-error');
23851                                    }
23852
23853                                }, 'json');
23854                            });
23855                        } ,'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0 cl-shopping-margin','','',function(){
23856
23857                            $('.cl-shopping-margin .prod-margin-price > svg.bi').off('click').on({
23858                                click: function(e) {
23859                                    var margin_type = ($(this).closest('.prod-margin-price').hasClass('cal-margin')) ? 'margin' : 'price',
23860                                        marginInput = $(this).closest('.prod-margin-price').find('.prod-user-'+margin_type),
23861                                        isPlus = (($(this).attr('class')).indexOf('plus') > -1) ? true : false,
23862                                        margin = marginInput.val().trim(),
23863                                        r = Number(margin.replace(/[^0-9.]/g,''));
23864                                    if(margin_type == 'margin') {
23865                                        r = (isPlus) ? r + 1 : r - 1;
23866                                        if(r < 0) r = 0;
23867                                        if(r > 100) r = 100;
23868                                    } else {
23869                                        r = (isPlus) ? r + 10000 : r - 10000;
23870                                        if(r < 0) r = 0;
23871                                        r = addCommas(r);
23872                                    }
23873                                    marginInput.val(r);
23874                                }
23875                            });
23876
23877                            $('.cl-shopping-margin .prod-user-margin, .cl-shopping-margin .prod-user-price').off('blur').on({
23878                                blur: function(e) {
23879                                    if($(this).val().trim() == '') $(this).val('0');
23880                                    if($(this).hasClass('prod-user-margin')) {
23881                                        if(Number(removeCommas($('.prod-user-margin').val())) > 100) $(this).val('100');
23882                                    }
23883                                    if($(this).hasClass('prod-user-price')) {
23884                                        if(Number(removeCommas($('.prod-user-price').val())) > 1000000000) $(this).val('1,000,000,000');
23885                                    }
23886                                }
23887                            });
23888
23889                        });
23890                        break;
23891                    case "stock" :
23892                        setQuantity();
23893                        break;
23894                    default:
23895                        break;
23896                }
23897            });
23898            $(document).on('click','.gallery-add-items', function(e) {
23899                if($(this).hasClass('disabled')) {
23900                    ($(this).hasClass('gallery-need')) 
23901                    ? $(this).showModalFlat('안내', '화면 좌측의 갤러리 목록에서 갤러리 선택 후 상품을 추가할 수 있습니다.', true, false, '', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-okbtn-pbt70')
23902                    : $(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');
23903                    return false;
23904                }
23905
23906                var mode = $(this).attr('data-mode');
23907                if(typeof mode == 'undefined' || !mode) {
23908                    alert('Undefined gallery mode');
23909                    return false;
23910                }
23911                switch(mode) {
23912                    case 'shopping' : $.products.add(-1); break;
23913                    default:
23914                        setResourceBtn(false,{maxcount:0});
23915                        selectID = $('.gallery-modal').attr('data-pid');
23916                        $.resource.open();
23917                        break;
23918                }
23919            });
23920            $(document).on('blur','.item-title', function(e) {
23921                var title = $(this).val().trim(),
23922                    s = $(this).attr('data-title'),
23923                    seq = $(this).attr('data-seq'),
23924                    caption = $(this).attr('data-caption'),
23925                    hashtag = $(this).attr('data-hashtag'),
23926                    category = $(this).attr('data-category'),
23927                    datetime = $(this).attr('data-datetime'),
23928                    thumb = $(this).attr('data-url'),
23929                    file = (thumb.indexOf('googleusercontent') > -1) ? thumb : thumb.replace(/^.*[\\\/]/, ''),
23930                    $gitem = $('.' + $.gallery.block_id).find('.gallery-item[data-seq="'+seq+'"]'),
23931                    pathinfo = thumb.split('/');
23932
23933                    if($gitem.length == 0) {
23934                    if($(this).parents('.gallery-modal').attr('data-mode')=='gallery') {
23935                        $gitem = $('.gallery-popup').find('.gallery-item[data-seq="'+seq+'"]');
23936                    }
23937                }
23938
23939                if($('.' + $.gallery.block_id).attr('data-msny') == 'true') $.gallery.update = true;
23940
23941                if(title != s && title) {
23942                    if(typeof seq == 'undefined' || !seq) {
23943                        alert('Invalid item');
23944                        return false;
23945                    }
23946
23947                    $gitem.find('[data-gallery]').attr({'data-title':title});
23948                    if($('.gallery-items .item').length < 3) $('.gallery-popup').find('.gallery-item[data-seq="'+seq+'"]').find('[data-gallery]').attr({'data-title':title});
23949                    var type = 'ELEM',
23950                        s = '';
23951                    if(pathinfo[4]!= 'free') s = 'false';
23952                    else {
23953                        var p = pathinfo.slice(1,6);
23954                        p.unshift('');
23955                        p.push('');
23956                        s = p.join('/');
23957                    }
23958
23959                    $.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) {
23960                        var isCheck = checkError(data);
23961                        if(!isCheck) return false;
23962                        setLogs(type,'gallery.data.edit','modify',type,'product-manager','el');
23963                    }, 'json');    
23964
23965                    (title.length>0) ? $gitem.find('h5.figure').html(title) :  $gitem.find('h5.figure').text('Title');
23966                    $(this).attr({'value':title,'data-title':title});
23967                }
23968                $('.gallery-items').selectable('enable');
23969            });
23970            $(document).on('click', '.prod-button .modal-save, .prod-detail-edit', function(e) {
23971                var hasEmoji = false;
23972                $('.prod-input, .prod-input-value').each(function() {
23973                    var passEmoji = ($.inArray($(this).attr('id'),['prod-title', 'prod-desc']) > -1) ? true : false,
23974                        check_val = ($(this).is('div')) ? $(this).text().trim() : $(this).val().trim();
23975                    
23976                    if(!passEmoji && checkEmojis(check_val)) {
23977                        hasEmoji = true;
23978                        return false;
23979                    }
23980                });
23981                if(hasEmoji) {
23982                    e.preventDefault();
23983                    errorEmojisModal();
23984                    return false;
23985                }
23986
23987                var go = $(this).hasClass('prod-detail-edit') ? true : false;
23988                // var modal = $(this).showModalFlat('INFORMATION', '편집한 내용 저장 시 실 사이트에도 반영이 됩니다.<br>저장 하시겠습니까?', true, true, function() {
23989                //     modal.modal('hide');
23990                    $.products.save(go);
23991                // });
23992            });
23993            $(document).on('click', '.gallery-blocks .gallery-name[data-gallery-id]:not(.disabled)', function(e) {
23994                e.stopPropagation();
23995                var id = $(this).attr('data-gallery-id');
23996                if(typeof id == 'undefined') return false;
23997                $.gallery.block_id = id;
23998                $('#prod-pid').val(id);
23999                if(LUX) {
24000                    setProductParams({'category_no' : $(this).attr('data-category')});
24001                }
24002                clearLocalStorage();
24003                $.gallery.show($.gallery.block_id);
24004            });
24005            $(document).on('click','.gallery-items-loadmore', function(e) {
24006                var id = $(this).attr('data-pid'),
24007                    page = Number($(this).attr('data-page')),
24008                    cate_str = $(this).attr('data-category-str');
24009                page++;
24010                $.gallery.list(id,page,cate_str);
24011            });
24012            $(document).on('hover','.gallery-items .table-item', function(e) {
24013                if (e.type == "mouseenter") {
24014                    if(!LUX && $('.gallery-modal').attr('data-pid') != undefined) $(this).find('.item-handle').show();
24015                    $(this).find('.item-edit').show();
24016                } else { // mouseleave
24017                    if(!LUX) $(this).find('.item-handle').hide();
24018                    $(this).find('.item-edit').hide();
24019                    $(this).find('.item-edit').find('.item-submenu').hide();
24020                }
24021            });
24022            $(document).on('click', '.gallery-modal .item-edit li', function(e) {
24023                $('.item-submenu').hide();
24024                $('.submenu').removeClass('open');
24025                var $submenu = $(this).find('.item-submenu'),
24026                    display = $submenu.css('display');
24027                (display == 'none') ? $submenu.css('display','block') : $submenu.css('display','none');
24028                return;
24029            });
24030            $(document).on('click', '.gallery-modal .product-item-edit li', function(e) {
24031                var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item';
24032                var mode = $(this).attr('data-mode'),
24033                    seq = $(this).parent().attr('data-seq'),
24034                    // page = $('.gallery-modal').attr('data-page'),
24035                    page = $(group).attr('data-page'),
24036                    config_url = (CONFIG_URL) ? '_config' : 'config';
24037                if(typeof seq == 'undefined' || seq == '' || typeof page == 'undefined' || page == '') {
24038                    alert('Undefined product seq or page!');
24039                    return false;
24040                }
24041                page = encodeURIComponent(page);
24042                if(mode == 'prodInfo') {
24043                    $.gallery.item_of_page = $(this).parents('.table-item').attr('data-page');
24044                    $.products.add(seq);
24045                } else {
24046                    if(LUX) page = '_product';
24047                    // location.href = '/'+config_url+'/page/'+page+'/view/'+seq;
24048                    $.detail.open('/'+config_url+'/page/'+page+'/view/'+seq, mode);
24049                }
24050            });
24051            $(document).on('click', '.td-check input[type="checkbox"]', function(e) {
24052                e.stopPropagation();
24053                var seq = $(this).parents('.table-item').attr('data-seq'),
24054                    seq_idx = ($.gallery.seqs).indexOf(seq),
24055                    disabled = false, visible_button = false, no_price = false;
24056                    // disabled = ($(this).parents('.table-item').attr('data-product') == "false") ? true : false;
24057
24058                if($(this).is(':checked')) {
24059                    $(this).parents('.table-item').addClass('ui-selected return');
24060                    if(typeof seq != 'undefined')
24061                        $.gallery.seqs.push(seq);
24062                    $('.gallery-toolbar').addClass('hide_col');
24063                } else {
24064                    if(seq_idx > -1) ($.gallery.seqs).splice(seq_idx,1);
24065                    $(this).parents('.table-item').removeClass('ui-selected return');
24066                    if($.gallery.seqs.length == 0) $('.gallery-toolbar').removeClass('hide_col');
24067                }
24068                stickyToolbar();
24069
24070                $.each($('.gallery-items .table-item.ui-selected'), function(i,v) {
24071                    if($(this).attr('data-product') == "false") disabled = true;
24072                    if($(this).attr('data-out-datetime') == "1") visible_button = true;                    
24073                    if($(this).attr('data-pricechk') == "false") no_price = true;
24074                });
24075
24076                $('.gallery-items .table-item > div').addClass('hide-text');
24077                $('.table-toolbar > li').removeClass('open').find('.item-submenu').hide();
24078                $('.gallery-view-count').removeClass('open').find('.view-submenu').hide();
24079
24080                if($('.gallery-items .table-item.ui-selected').length == 0) {
24081                    $.gallery.seqs = [];
24082                    $('.gallery-toolbar').removeClass('hide_col');
24083                    $('.gallery-items .table-item > div').removeClass('hide-text');
24084                    $('.table-toolbar .toolbar-cmd').addClass('hide'); 
24085                    $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq','');
24086                    $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink','').attr('data-glink-target','');
24087                    $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible','0').text($.lang[LANG]['editor.gallery.icon.visible.off']);
24088                    $('.gallery-toolbar').addClass('hide');
24089                    $('.gallery-items .item-header').removeClass('hide');
24090                } else { 
24091                    var firstItem = $('.gallery-items .table-item.ui-selected').eq(0),
24092                        first_seq = firstItem.attr('data-seq'),
24093                        link = firstItem.attr('data-link'),
24094                        target = firstItem.attr('data-target'),
24095                        visible = firstItem.attr('data-visible'),
24096                        grade = firstItem.attr('data-grade'),
24097                        vstr = (visible == '1') ? $.lang[LANG]['editor.gallery.icon.visible.on'] : $.lang[LANG]['editor.gallery.icon.visible.off'],
24098                        gstr = (grade == 'ON') ? $.lang[LANG]['editor.gallery.icon.grade.off'] : $.lang[LANG]['editor.gallery.icon.grade.on'];
24099                    if(visible_button) {
24100                        $('.table-toolbar .toolbar-cmd.toolbar-visible').addClass('disabled');
24101                    } else $('.table-toolbar .toolbar-cmd.toolbar-visible').removeClass('disabled');
24102                    if($.gallery.block_id == -1) {
24103                        $('.table-toolbar .toolbar-cmd.toolbar-copy').addClass('disabled');
24104                    }
24105                    $('.table-toolbar .toolbar-cmd').removeClass('hide');
24106                    $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq',first_seq);
24107                    $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink',link).attr('data-glink-target',target);
24108                    $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible',visible).text(vstr);
24109                    $('.table-toolbar .toolbar-cmd i[data-cmd="grade"]').attr('data-grade',grade).text(gstr);
24110                    $('.gallery-toolbar').removeClass('hide');
24111                    $('.gallery-items .item-header').addClass('hide');
24112                }
24113                (no_price) ? $('.product-cmd').not('.toolbar-org-price').not('.toolbar-stock').addClass('no_price') : $('.product-cmd').removeClass('no_price');
24114                (disabled) ? $('.product-cmd').addClass('disabled') : $('.product-cmd').removeClass('disabled');
24115                if($('.gallery-modal').attr('data-pid') == undefined) {
24116                    $('.toolbar-sort.item-sort').addClass('disabled');
24117                }
24118                if($('.gallery-modal .table-item').length == $('.gallery-modal .table-item .td-input:checked').length) $('.table-toolbar .check-all').prop('checked', true);
24119                $.gallery.setNumber();
24120            });
24121            $(document).on('change','.category-onoff-check', function(e) {
24122                var gc = $(this).prop('checked'),
24123                    g_category_onoff = (gc) ? 'ON' : 'OFF',
24124                    settings = {
24125                        category_display : g_category_onoff
24126                    };
24127                $.gallery.update = true;
24128                if(gc) {
24129                    $('.gallery-category-menu').removeClass('hide');
24130                    $('.category-title-str').addClass('on');
24131                    $('.td-category').removeClass('hide');
24132                } else {
24133                    $('.gallery-category-menu').addClass('hide');
24134                    $('.category-title-str').removeClass('on');
24135                    $('.td-category').addClass('hide');
24136                }
24137                $.post('/template/settings', {sid: SID, settings : JSON.stringify(settings), el: $.gallery.block_id}, function(data) {
24138                    checkError(data);
24139                    $.gallery.show($.gallery.block_id);
24140                }, 'json');
24141                
24142                var type = (typeof selectEL != 'undefined') ? getElementType() : 'ELEM';
24143                setLogs(type,'gallery.category.' + gc,'toggle-' + gc, type,'product-manager','el');
24144            });
24145            $(document).on('click','.toolbar-category ul.item-submenu li', function(e) {
24146                if(($.gallery.seqs).length) {
24147                    $(this).toggleClass('active');
24148                    var click_cate = $(this).text(),
24149                        cate_str = $('.toolbar-category ul.item-submenu li.active').map(function() { return $(this).text(); }).get(),
24150                        text_str = cate_str.join(),
24151                        data_str = '|' + text_str.replace(/\,/g,'|,|') + '|';
24152
24153                    $.each($.gallery.seqs, function(i,v) {
24154                        if($('.gallery-modal').hasClass('shopping')) {
24155                            $('.table-item[data-seq="' + v + '"]').attr('data-category', data_str).find('.td-category').text(text_str).attr('data-original-title',text_str);
24156                            
24157                            if(text_str.indexOf(',') > -1) $('.table-item[data-seq="' + v + '"] .td-category').addClass('line');
24158                            else $('.table-item[data-seq="' + v + '"] .td-category').removeClass('line');
24159                        } else {
24160                            $('.gallery-items .item[data-seq="' + v + '"]').attr('data-category', data_str).find('.td-category').text(text_str);
24161                        }
24162
24163                        $.post('/template/gallery/category', { sid : SID, s : cate_str, mode : 'gallery', seq : v }, function(r) {
24164
24165                            if($('.element[data-id="' + $.gallery.block_id + '"] .gallery-category-nav li:nth-child(1)').hasClass('hide')) {
24166                                if($('.element[data-id="' + $.gallery.block_id + '"] .gallery-category-nav li.active a').text() == click_cate) {
24167                                    $.gallery.update = true;
24168                                }
24169                            }
24170
24171                        }, 'json');
24172                    });
24173                }
24174            });
24175            $(document).on('click','.toolbar-sort ul.item-submenu li', function(e) {
24176                if(($.gallery.seqs).length) {
24177                    var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item';
24178                    $.gallery.move = $.gallery.seqs;
24179                    if($(this).hasClass('sort-top')) {
24180                        $.gallery.drag = $(group).first().attr('data-seq');
24181                        // $.gallery.seqs = [];
24182                        var modal = $(this).showModalFlat($.lang[LANG]['config.gallery.order.move'],$.lang[LANG]['editor.gallery.move'],true,true,function() {
24183                            modal.modal('hide');
24184                            // $.gallery.mv();
24185                            var spos = $('.gallery-modal').scrollTop();
24186                            $.processON('move gallery item(s)...');
24187                            $.ajax({
24188                                url: '/template/gallery/sort-top',
24189                                data: { sid : SID, seq : $.gallery.seqs, block_id : $.gallery.block_id },
24190                                dataType: 'json',
24191                                type: 'POST',
24192                                async: false,
24193                                cache: false,
24194                                success: function (data) {
24195                                    checkError(data);
24196                                    var p = $.gallery.pages;
24197                                    $.gallery.show($.gallery.block_id,p.page,$.gallery.category, function() {
24198                                        $.each(data.seqs, function(i,v) {
24199                                            $(group + '[data-seq="' + v + '"]').addClass('return');
24200                                        });
24201                                        setTimeout(function() { 
24202                                            $('.gallery-modal').scrollTop(spos); 
24203                                            $.processOFF();
24204                                        }, 500);
24205                                    });
24206                                    $.gallery.update = true;
24207                                    $.gallery.reset();
24208                                    $.processOFF();
24209                                }
24210                            });                            
24211                        }, 'cancel','ok','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0',false, function() {
24212                            // cancel callback
24213                            $.gallery.seqs = $.gallery.move;
24214                        });
24215                    } else if($(this).hasClass('sort-bottom')) {
24216                        if($('.gallery-items-loadmore').length == 0) {
24217                            var last = $(group).last().attr('data-seq');
24218                            if($.gallery.seqs[0] == last) {
24219                                var s = (group == '.gallery-items .item') ? $.lang[LANG]['editor.gallery.select.front.last.1'] : $.lang[LANG]['editor.gallery.select.front.last.2'],
24220                                    contents2_str = (LANG =='ko') ? $.lang[LANG]['editor.gallery.select.contents.2'] : '';
24221
24222                                $(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');
24223                                return false;
24224                            }
24225                        }
24226
24227                        var modal = $(this).showModalFlat($.lang[LANG]['config.gallery.order.move'],$.lang[LANG]['editor.gallery.move'],true,true,function() {
24228                            var item = $(group).length,
24229                                cpage = Math.ceil(item/30),
24230                                spos = $('.gallery-modal').scrollTop();
24231
24232                            modal.modal('hide');
24233                            $.processON('move gallery item(s)...');
24234                            $.ajax({
24235                                url: '/template/gallery/sort-bottom',
24236                                data: { sid : SID, seq : $.gallery.seqs, block_id : $.gallery.block_id },
24237                                dataType: 'json',
24238                                type: 'POST',
24239                                async: false,
24240                                cache: false,
24241                                success: function (data) {
24242                                    checkError(data);
24243                                    var p = $.gallery.pages;
24244                                    $.gallery.show($.gallery.block_id,p.page,$.gallery.category, function() {
24245                                        $.each(data.seqs, function(i,v) {
24246                                            $(group + '[data-seq="' + v + '"]').addClass('return');
24247                                        });
24248                                        setTimeout(function() { 
24249                                            $('.gallery-modal').scrollTop(spos); 
24250                                            $.processOFF();
24251                                        }, 500);
24252                                    });
24253                                    $.gallery.update = true;
24254                                    $.gallery.reset();
24255                                    $.processOFF();
24256                                }
24257                            });
24258                        }, 'cancel','ok','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0', false, function() {
24259                            // cancel callback
24260                            $.gallery.seqs = $.gallery.move;
24261                        });
24262                    }
24263                }
24264            });
24265            $(document).on('click','.view-submenu li', function(e) {
24266                $.processON();
24267
24268                var view = (typeof $(this).attr('data-view') != 'undefined' && $(this).attr('data-view')) ? $(this).attr('data-view') : 30;
24269
24270                window.localStorage.setItem('gallery-product-view',view);
24271                $.gallery.show($.gallery.block_id,'',$.gallery.category,function() {
24272                    setTimeout(function() { 
24273                        $.processOFF();
24274                    }, 500);
24275                });
24276            });
24277            $(document).on('click', '.gallery-modal .edit-gallery-detail', function(e) {
24278                var seq = $(this).attr('data-seq'),
24279                    mode = $(this).attr('data-mode');
24280                var page = $('.gallery-modal').attr('data-page');
24281                var config_url = (CONFIG_URL) ? '_config' : 'config';
24282                if(typeof seq == 'undefined') return;
24283                // location.href = '/'+config_url+'/page/' + page + '/view/' + seq;
24284                $.detail.open('/'+config_url+'/page/' + page + '/view/' + seq, 'gallery');
24285            });
24286            $(document).on('click','.gallery-name-edit', function(e) {
24287                e.stopPropagation();
24288                $('.gallery-name-edit-input').remove();
24289                var v = $(this).parents('.gallery-name').text(),
24290                    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>';
24291                $(this).parents('.gallery-name').append(s);
24292            });
24293            $(document).on('click','.gallery-name-edit-inputbox',function(e) {
24294                e.stopPropagation();
24295            });
24296            $(document).on('keypress', '.gallery-name-edit-inputbox', function(e) {
24297                var keyCode = e.keyCode,
24298                    blockname = $(this).val().trim();
24299
24300                if(keyCode == 13) {
24301                    saveGalleryBlockName($(this), blockname);
24302                }
24303            });
24304            $(document).on('click','.gallery-name-edit-save',function(e) {
24305                e.stopPropagation();
24306                var blockname = $('.gallery-name-edit-inputbox').val().trim(),
24307                    $input = $('.gallery-name-edit-inputbox');
24308
24309                if(checkEmojis(blockname)) {
24310                    e.preventDefault();
24311                    var open_el = $(this).closest('.gallery-blocks').find('.btn-group'),
24312                        focus_el = $(this).closest('.gallery-name-edit-input').find('.gallery-name-edit-inputbox');
24313                    errorEmojisModal('','','',function() {
24314                        open_el.addClass('open');
24315                        focus_el.focus();
24316                    });
24317                    return false;
24318                }
24319                saveGalleryBlockName($input, blockname);
24320            });
24321            $(document).on('click','.gallery-name-edit-close',function(e) {
24322                e.stopPropagation();
24323                $(this).parents('.gallery-name-edit-input').remove();
24324            });
24325        },
24326        cp : function() {
24327            var seqs = $.gallery.copy,
24328                page = $('.gallery-modal').attr('data-page'),
24329                pid = $('.gallery-modal').attr('data-pid');
24330
24331            seqs = seqs.reverse();
24332            if(typeof seqs.length == 0 || seqs == '') {
24333                alert('Invalid variable');
24334                return false;
24335            }
24336            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() {
24337                var count = seqs.length;
24338
24339                modal.modal('hide');
24340                var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item',
24341                    item = $(group).length,
24342                    cpage = Math.ceil(item/30),
24343                    spos = $('.gallery-modal').scrollTop();
24344
24345                $.processON('copy gallery item(s)...');
24346                // console.log('ModalPlugin cp ');
24347                // console.log(seqs);
24348                $.ajax({
24349                    url: '/template/gallery/copy',
24350                    data: { s: seqs, sid : SID, page : page, block_id : $.gallery.block_id },
24351                    dataType: 'json',
24352                    type: 'POST',
24353                    async: true,
24354                    cache: false,
24355                    success: function (data) {
24356                        checkError(data);
24357                        // console.log(data);
24358                        galleryStatusInit();
24359                        $.gallery.copy = [];
24360                        var type = (typeof selectEL != 'undefined') ? getElementType() : 'ELEM';
24361                        setLogs(type,'gallery.item.clone','clone',type,'product-manager','el');
24362
24363                        $.gallery.show($.gallery.block_id,cpage,$.gallery.category,function() {
24364                            $.each(data.r, function(i,v) {
24365                                // console.log(v.seq);
24366                                $(group + '[data-seq="' + v.seq + '"]').addClass('return');
24367                            });
24368                            setTimeout(function() { 
24369                                $('.gallery-modal').scrollTop(spos); 
24370                                $.processOFF();
24371                            }, 500);
24372                        });
24373    
24374                        $.gallery.update = true;                        
24375                    }
24376                });
24377            }, 'cancel','ok','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0');
24378        },
24379        mv : function(func) {
24380            var seqs = $.gallery.move,
24381                page = $('.gallery-modal').attr('data-page');
24382            // seqs = seqs.reverse();
24383            if(typeof seqs.length == 0 || seqs == '') {
24384                alert('Invalid variable');
24385                return false;
24386            }
24387            clicking = false;
24388            var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item';
24389
24390            if($.gallery.drag) {
24391                if(($.gallery.drag == seqs[0] || 
24392                    $.gallery.drag == $(group + '[data-seq="' + seqs[0] + '"]').next().attr('data-seq')) ||
24393                    $.gallery.drag == $(group + '[data-seq="' + seqs[0] + '"]').next().hasClass('prev')) {
24394                    if($('.clone-item').length) {
24395                        $('.clone-item').remove();
24396                        // $.gallery.seqs = [];
24397                        return false;
24398                    } else {
24399                        if($('.item-sort').hasClass('open')) {
24400                            var s = (group == '.gallery-items .item') ? $.lang[LANG]['editor.gallery.select.front.first.1'] : $.lang[LANG]['editor.gallery.select.front.first.2'],
24401                                contents2_str = (LANG =='ko') ? $.lang[LANG]['editor.gallery.select.contents.2'] : '';
24402                            $.gallery.seqs = $.gallery.move;
24403                            $(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');
24404                            return false;
24405                        }
24406                    }
24407                }
24408            }
24409            var count = seqs.length,
24410                selected = $.gallery.drag;
24411
24412            var item = $(group).length
24413                cpage = Math.ceil(item/30),
24414                spos = $('.gallery-modal').scrollTop();
24415
24416            // modal.modal('hide');
24417            $.processON('move gallery item(s)...');
24418            $.ajax({
24419                url: '/template/gallery/move',
24420                data: { s: seqs, sid : SID, page : page, block_id : $.gallery.block_id, selected : selected, last : $.gallery.last },
24421                dataType: 'json',
24422                type: 'POST',
24423                async: true,
24424                cache: false,
24425                success: function (data) {
24426                    checkError(data);
24427                    $.gallery.update = true;
24428                    $.gallery.drag = '';
24429                    $.gallery.last = '';
24430                    if(typeof func == 'function') {
24431                        func();
24432                    } else {
24433                        $.gallery.show($.gallery.block_id,cpage,$.gallery.category, function() {
24434                            $.each(data.seqs, function(i,v) {
24435                                $(group + '[data-seq="' + v + '"]').addClass('return');
24436                            });
24437                            setTimeout(function() { 
24438                                $('.gallery-modal').scrollTop(spos); 
24439                                $.processOFF();
24440                            }, 500);
24441                        });
24442                    }
24443
24444                }
24445            });
24446        },
24447        del : function() {
24448            var seqs = $.gallery.delete,
24449                page = $('.gallery-modal').attr('data-page'),
24450                pid = $('.gallery-modal').attr('data-pid'),
24451                total = seqs.length,
24452                title = (LANG == 'ko') ? '갤러리 데이터를 삭제중입니다...' : 'Deleting gallery data...',
24453                sub_des = (LANG == 'ko') ? '데이터를 삭제중입니다' : 'Deleting',
24454                loading = '<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i> ';
24455
24456            if(typeof seqs.length == 0 || seqs == '') {
24457                alert('Invalid variable');
24458                return false;
24459            }   
24460            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() {
24461                var count = seqs.length;
24462                modal.modal('hide');
24463                $.progressON(title);
24464
24465                var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item',
24466                    item = $(group).length,
24467                    item = ((item - count) < 0) ? 1 : item - count,
24468                    cpage = Math.ceil(item/30),
24469                    spos = $('.gallery-modal').scrollTop(),
24470                    done = 0,
24471                    pid = $('.gallery-modal').attr('data-pid'),
24472                    mode = $('.gallery-modal').attr('data-mode');
24473
24474                $.each(seqs, function(i,v) {
24475                    $(group + '[data-seq="' + v + '"]').fadeOut(100, function() { $(this).remove(); });
24476
24477                    var t = setTimeout(function() {
24478                        if(CANCEL) {
24479                            if(ABORT) {
24480                                // 리스트 갱신 작업
24481                                $.gallery.show($.gallery.block_id,cpage,$.gallery.category, function() {
24482                                    setTimeout(function() { 
24483                                        $.gallery.move = [];
24484                                        $('.gallery-modal').scrollTop(spos); 
24485                                        $.processOFF();
24486                                    }, 500);
24487                                });
24488                                ABORT = false;
24489                                $.progressOFF();
24490                            }
24491                            i=0; return false;
24492                        }
24493                        galleryDeleteItem(v,function(data) {
24494                            done++;
24495                            progress = parseInt((done / total) * 100,10);
24496                            $('.file-upload-progress .progress-bar').
24496css('width',progress + "%");
24497                            $('.progressModal .info2').text(done.toString() + ' / ' + total.toString());
24498
24499                            var d = data.data;
24500                            $.each(d, function(i,o) {
24501                                blockBookmarkDelete(o.sid,o.seq);
24502                            });
24503
24504                            glItemDelete(v,page);
24505                            if(v==VIEW) $.gallery.unlink = true;
24506
24507                            if(total == done) {
24508                                var type = getElementType();
24509                                setLogs(type,'gallery.item.delete','delete',type,'product-manager','el');
24510                                $.gallery.reset();
24511                                $.gallery.update = true;
24512
24513                                $.gallery.show($.gallery.block_id,cpage,$.gallery.category, function() {
24514                                    setTimeout(function() { 
24515                                        $.gallery.move = [];
24516                                        $('.gallery-modal').scrollTop(spos); 
24517                                        $.progressOFF();
24518                                    }, 500);
24519                                });
24520                            } else {
24521                                moving = $(group + '[data-seq="' + seqs[i+1] + '"] .td-title .item-title-str').text();
24522                                if(moving == "") moving = sub_des;
24523                                $('.progressModal .info1').html(loading + moving);
24524                            }
24525                        });
24526                    },500*i);
24527                });
24528            }, 'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0');
24529        },
24530        show : function(id,page,category,func) {
24531            // if(typeof id == 'undefined' || !id) {
24532            //     alert('Undefined gallery ID');
24533            //     return false;
24534            // }
24535
24536            if(typeof page =='undefined' || !page) page = 1;
24537            if(typeof category =='undefined') category = '';
24538            if(typeof id == 'undefined') id = '';
24539            // var params = ($('.gallery-modal').length) ? getProductParams() : getSearchURL();
24540
24541            var params = getProductParams(),
24542                product_name = getStorageItem('gallery-product-name'),
24543                product_filter = getStorageItem('gallery-product-filter'),
24544                product_view = getStorageItem('gallery-product-view'),
24545                sort = getStorageItem('gallery-product-sort'),
24546                by = getStorageItem('gallery-product-by'),
24547                manager = (id == '' || id == -1) ? SID : '';
24548
24549            $.gallery.seqs = [];
24550            $.gallery.block_id = (id == '') ? -1 : id;
24551            $.gallery.category = category;
24552            $.processON();
24553            $.ajax({
24554                type: 'POST',
24555                url : '/template/gallery/show',
24556                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 },
24557                dataType : 'json',
24558                async: true,
24559                cache: false,
24560                success : function(data) {
24561                    $.processOFF();
24562                    if(LUX && data.mode == 'shopping' && params) {
24563                        setProductParams(params);
24564                    }
24565                    if(data.error != 'undefined' && data.error) {
24566                        alert(data.error);
24567                        return false;
24568                    }
24569                    $.gallery.site_settings = data.settings;
24570                    // premium block
24571                    if( !$('#el-blockConfig').hasClass('open') && 
24572                        $('.element[data-id="' + $.gallery.block_id + '"][data-type="gallery"] input.gjs').length > 0 
24573                    ) {
24574                        stopGalleryJS($('.element[data-id="' + $.gallery.block_id + '"]'));
24575                    }
24576
24577                    $.gallery.mode = data.mode;
24578                    $.gallery.SMENU = data.SMENU;
24579                    $.gallery.SFOLDER = data.SFOLDER;
24580                    $.gallery.valid_plan = data.valid_plan;
24581                    $.gallery.valid_type = data.valid_type;
24582                    $.gallery.one = data.one;
24583                    $.gallery.service = data.service;
24584                    $.gallery.block_el = ($.gallery.block_id == '-1') ? 'el_prod' : data.gallerys[$.gallery.block_id].el;
24585                    var $backdrop = $('<div id="dummy-drop" style="position:fixed;top:0;left:0;right:0;bottom:0;background-color:#fff;z-index:1039;"></div>');
24586                    if($('#dummy-drop').length == 0)
24587                        $('body').append($backdrop);
24588    
24589                    $('.gallery-modal').hide().remove();
24590                    $('#gallery-style').remove();
24591                    $('#gallery-modal-script').remove();
24592                    $m = $(data.r).hide();
24593                    $('body').append($m);
24594                    
24595                    if($.gallery.mode != 'shopping') $('.gallery-list-filter').remove();
24596                    if(data.name) $('.selected-gallery-name').text(data.name);
24597                    if(typeof id == 'undefined' || !id || id == -1) {
24598                        $('.gallery-category').addClass('product-all-items');
24599                        $('.gallery-category .category-title-str').hide();
24600                        $('.gallery-category .gallery-category-onoff').hide();
24601                        $('.gallery-blocks .all-items').addClass('active');
24602                        $('.gallery-block-select, .selected-gallery-name').text('전체상품');
24603                        $('.gallery-add-items').addClass('disabled gallery-need');
24604                    } else {
24605                        $('.gallery-blocks .all-items').removeClass('active');  
24606                        $('.gallery-category').show();
24607                        $('.gallery-category').removeClass('product-all-items');
24608                        $('.gallery-add-items').removeClass('disabled gallery-need');
24609                    }
24610
24611                    $('.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);
24612                    (data.mode == 'shopping') ? $('.gallery-modal').addClass('shopping') : $('.gallery-modal .gallery-items').addClass('mod-gallery');
24613                    if(data.mode == 'shopping' && LUX) $('.gallery-modal').addClass('lux');
24614                    $('#gallery-name').text(data.name);
24615                    $('.gallery-add-items').attr('data-mode',data.mode).attr('data-page',data.page);
24616                    var check_only_cate = (typeof data.only_category != 'undefined' && data.only_category === true) ? true : false;
24617                    if(!check_only_cate && data.id == '') $('.gallery-add-items').hide();
24618                    (data.mode == 'shopping') ? $('.gallery-modal-title').text($.lang[LANG]['bc.tp.gallery-contents.shopping']) : $('.gallery-modal-title').text($.lang[LANG]['editor.block.gallery.title']);
24619                    $('.view-submenu li[data-view="' + data.view + '"]').addClass('active');
24620                    $('#gallery_view').text(data.view);
24621                    var icon = '';
24622                    $.gallery.blocks = []; var idx = 0, menu_name = '';
24623                    $.gallery.pages = [];
24624                    $.each(data.lists, function(i,v) {
24625                        $.gallery.blocks.push(v);
24626                        $.each(v, function(m, menus) {
24627                            $('.gallery-blocks').append('<ul class="menus" data-name="' + m + '"><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> ' + m + '</li>');
24628                            if(menus.length) {
24629                                menu_name = m;
24630                                for(var key in menus) {
24631                                    var value = menus[key];
24632                                    switch(value.mode) {
24633                                        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;
24634                                        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;
24635                                        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;
24636                                    }
24637                                    if(value.id == id) $.gallery.block_name = value.name;
24638                                    var gb_li_class = (value.id == id) ? 'active' : '',
24639                                        gb_li_attr = '';
24640
24641                                    if(gb_li_class == 'active') $('.gallery-block-select').text(value.name);
24642
24643                                    if(!value.isActive) {
24644                                        gb_li_class += 'disabled editor-upgrade-popup';
24645                                        gb_li_attr = 'data-mode="gallery.primeum"';
24646                                    }
24647
24648                                    if(LUX) {
24649                                        gb_li_attr += ' data-category="' + value.lux_category_no + '" ';
24650                                    }
24651    
24652                                    var gb_li_html = '\
24653                                        <li class="gallery-name ' + gb_li_class + '" data-gallery-id="' + value.id + '" ' + gb_li_attr + '>\
24654                                            <span class="gallery-block-name">' + value.name + '</span>\
24655                                            <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>\
24656                                        </li>\
24657                                    ';
24658    
24659                                    $('.gallery-blocks ul[data-name="' + m + '"]').append(gb_li_html);
24660                                    cates = cates + '<li class="gallery-name" data-gallery-id="' + value.id + '">' + value.name + '</li>';
24661                                    // if(value.id == id) $.gallery.blocks[idx][menu_name].splice(k,1);
24662                                    $.gallery.pages[value.id] = menu_name;
24663                                }
24664                            }
24665                        });
24666                        idx++;
24667                    });
24668
24669                    if((data.lists).length == 0) $('.gallery-modal .gallery-add-items').addClass('disabled');
24670                    var cates = '';
24671                    var show = (data.cate_onoff == 'ON') ? '' : 'hide';
24672                    if(show) $('.gallery-cog').addClass('hide');
24673                    $.each(data.category, function(i,v) {
24674                        var active = (data.cate_str == v) ? 'active' : '';
24675                        $('.gallery-category .gallery-category-onoff').before('<li class="category-text gallery-category-menu ' + show + ' ' + active + '">' + v + '</li>');
24676                        cates = cates + '<li>' + v + '</li>';
24677                        if(data.cate_str == '') {
24678                            $('.gallery-category > li:nth-child(2)').addClass('active');
24679                        }
24680                    });
24681                    $.gallery.cates = cates;
24682                    if(data.cate_onoff == 'ON') {
24683                        $('.category-onoff-check').prop('checked','checked');
24684                        $('.category-title-str').addClass('on');
24685                    } else {
24686                        $('.category-onoff-check').prop('checked','');
24687                        $('.gallery-category > li:nth-child(2)').addClass('hide');
24688                        // $('.gallery-category > li:last-child').addClass('hide');
24689                    }
24690                    var selected_category = '',
24691                        $tag = $('.gallery-modal > .container');
24692
24693                    // lux shopping
24694                    if(LUX) {
24695                        $('.gallery-category').hide();
24696                        $tag.prepend('<div class="shop-filter-header open"></div>');
24697                        shopHeaderDisplay($tag.find('.shop-filter-header'),data);
24698
24699                        $('.gallery-list-filter').hide();
24700                        $('.selected-gallery-name').hide();
24701                        $('.gallery-category').hide();
24702                    } else {
24703                        // shopping filter
24704                        if(data.mode == 'shopping') {                        
24705                            var s = '\
24706                                <ul class="filter">\
24707                                    <li data-val="all" class="active">전체</li>\
24708                                    <li data-val="on">판매중</li>\
24709                                    <li data-val="off">판매중지</li>\
24710                                    <li data-val="out">품절</li>\
24711                                    <li data-val="hide">숨김</li>\
24712                                    <li data-val="wait">판매예정</li>\
24713                                    <li data-val="end">판매종료</li>\
24714                                </ul>\
24715                            ';
24716                            $('.gallery-list-filter').append(s);
24717                        }
24718                    }
24719
24720                    var keys = {'title' : '', 'date' : '', 'orig' : '', 'disc' : '', 'price' : ''},
24721                        keys_by = {'title' : '', 'date' : '', 'orig' : '', 'disc' : '', 'price' : ''},
24722                        checked = {'title' : '','date' : '', 'orig' : '', 'disc' : '', 'price' : ''},
24723                        icons = {
24724                            'title' : $.gallery.sort_icon_desc,
24725                            'date' : $.gallery.sort_icon_desc,
24726                            'orig' : $.gallery.sort_icon_desc,
24727                            'disc' : $.gallery.sort_icon_desc,
24728                            'price' : $.gallery.sort_icon_desc
24729                        };
24730                    switch(sort) {
24731                        case '' : break;
24732                        default : 
24733                            keys[sort] = 'sorted';
24734                            checked[sort] = '\
24735                                <span class="product-sort-checked">' + 
24736                                $.gallery.sort_icon_checked + '</span>\
24737                            ';
24738                        break;
24739                    }
24740                    if(sort) {
24741                        keys_by[sort] = by;
24742                        icons[sort] = (by == 'desc') ? $.gallery.sort_icon_desc : $.gallery.sort_icon_asc;
24743                    }
24744
24745                    var filter = getStorageItem('gallery-product-filter');
24746                    if(filter != null && filter.length) {
24747                        $('.gallery-list-filter .filter li').removeClass('active');
24748                        $('.gallery-list-filter .filter li[data-val="' + filter + '"]').addClass('active');
24749                    }
24750                    var s = '<ul class="table-toolbar">';
24751                    // lux shopping
24752                    if(LUX) {
24753                        s = s + '<li class="checkbox-cmd toolbar-cmd hide"><i class="" data-glseq="" data-cmd="checkall"></i> <input type="checkbox" class="check-all"></li>';
24754                        s = s + '<li class="toolbar-copy toolbar-cmd hide"><i class="" data-glseq="" data-cmd="copy"></i>' + $.lang[LANG]['editor.gallery.icon.clone'] + '</li>';
24755                        s = s + '<li class="toolbar-margin toolbar-cmd hide"><i class="" data-glseq="" data-cmd="margin"></i>마진율</li>';
24756                        s = s + '<li class="toolbar-delete toolbar-cmd hide"><i class="" data-glseq="" data-cmd="delete"></i>' + $.lang[LANG]['editor.gallery.icon.delete'] + '</li>';
24757                    } else {
24758                        s = s + '<li class="checkbox-cmd toolbar-cmd hide"><i class="" data-glseq="" data-cmd="checkall"></i> <input type="checkbox" class="check-all"></li>';
24759                        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>';
24760                        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>';
24761                        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>';
24762                        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>';
24763                        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>';
24764
24765                        if(!$('.gallery-modal .gallery-category .gallery-all').hasClass('hide')) {
24766                            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>';
24767                            s = s + '<ul class="item-submenu">' + cates + '</ul>';
24768                            s = s + '</li>';
24769                        }                        
24770
24771                        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>\
24772                                    <ul class="item-submenu">\
24773                                        <li class="sort-top">' + $.lang[LANG]['editor.gallery.icon.order.shopping.front'] + '</li>\
24774                                        <li class="sort-bottom">' + $.lang[LANG]['editor.gallery.icon.order.shopping.end'] + '</li>\
24775                                    </ul>\
24776                                </li>';
24777                        // 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>';
24778
24779                        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>';
24780                                               
24781                        s = s + '\
24782                                <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>\
24783                                <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>\
24784                                <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>\
24785                                <li class="toolbar-copy toolbar-cmd hide"><i class="" data-glseq="" data-cmd="copy"></i>' + $.lang[LANG]['editor.gallery.icon.clone'] + '</li>\
24786                                <li class="toolbar-delete toolbar-cmd hide"><i class="" data-glseq="" data-cmd="delete"></i>' + $.lang[LANG]['editor.gallery.icon.delete'] + '</li>\
24787                        ';
24788                        if(id == '') {
24789                            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>';
24790                        } else {
24791                            s = s + ((data.cate_onoff == 'ON' || !id || id == -1) ? 
24792                                '<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>' : 
24793                                '<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>');
24794                        }
24795                        s = s + '\
24796                                <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>\
24797                                <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>\
24798                                <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>\
24799                                <li class="dummy dm-quantity">재고</li>\
24800                                <li class="dummy dm-status">상태</li>\
24801                            </ul>\
24802                        ';
24803                    }
24804                    var $tool_back = $('<div class="toolbar sort
24804-disabled sticky">' + s + '</div>');
24805                    if(data.mode == 'shopping') {
24806                        $('.gallery-toolbar').append($tool_back).addClass('hide');
24807                    }
24808
24809                    var badge_settings = (data.badge_settings !== undefined && data.badge_settings)? JSON.stringify(data.badge_settings) : '{}';
24810                    var badge_imgs = (data.badge_imgs !== undefined && data.badge_imgs)? data.badge_imgs : '';
24811                    localStorage.setItem('badge_settings', badge_settings);
24812                    localStorage.setItem('badge_imgs', badge_imgs);
24813                    localStorage.setItem('before_badge_settings', badge_settings);
24814
24815                    var num = (page > 1) ? data.total : data.total - ((page-1) * data.view);
24816                    if((data.items).length && data.mode == 'shopping') {
24817                        var item_header = '\
24818                        <div class="item-header sticky">\
24819                            <div class="td-handle"></div>\
24820                            <div class="td-check"><input type="checkbox" class="check-all"></div>\
24821                            <div class="td-number">번호</div>\
24822                            <div class="td-img"></div>\
24823                            <div class="td-title">제목<span class="product-sort ' + keys['title'] + '" data-sort="title" data-by="' + keys_by['title'] + '">' + icons['title'] + '</span>' + checked['title'] + '\
24824                            </div>\
24825                        ';
24826
24827                        item_header+= (typeof id == 'undefined' || !id || id == -1) ? '<div class="td-gallery">갤러리</div>' : '';
24828                        item_header+='\
24829                            <div class="td-date">등록일<span class="product-sort ' + keys['date'] + '" data-sort="date" data-by="' + keys_by['date'] + '">' + icons['date'] + '</span>' + checked['date'] + '</div>\
24830                        ';
24831                        item_header+= (data.cate_onoff == 'ON' || !id || id == -1) ? '<div class="td-category">카테고리</div>' : '';
24832                        item_header+= '\
24833                            <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>\
24834                            <div class="td-discount">할인율<span class="product-sort ' + keys['disc'] + '" data-sort="disc" data-by="' + keys_by['disc'] + '">' + icons['disc'] + '</span>' + checked['disc'] + '</div>\
24835                            <div class="td-price">판매가<span class="product-sort ' + keys['price'] + '" data-sort="price" data-by="' + keys_by['price'] + '">' + icons['price'] + '</span>' + checked['price'] + '</div>\
24836                            <div class="td-quantity">재고</div>\
24837                            <div class="td-status">상태</div>\
24838                        </div>\
24839                        ';
24840                        $('.gallery-items').append(item_header);
24841                    }
24842
24843                    if(window.localStorage.getItem('product-gallery-closed') == 'true' || $(document).width() < 1440) {
24844                        var $list = $('.product-gallery-list'),
24845                            $category = $('.gallery-category'),
24846                            $more = $('.gallery-items-loadmore'),
24847                            $items = $('.gallery-items'),
24848                            $toggle = $('.product-gallery-list-toggle'),
24849                            $pagination = $('.pagination-wrap'),
24850                            $filter = $('.gallery-list-filter'),
24851                            $name = $('.selected-gallery-name'),
24852                            $lux_filter = $('.shop-filter-header');
24853                        $list.removeClass('open');
24854                        $category.removeClass('open');
24855                        $more.removeClass('open');
24856                        $items.removeClass('open');
24857                        $toggle.removeClass('open');
24858                        $pagination.removeClass('open');
24859                        $filter.removeClass('open');
24860                        $name.removeClass('open');
24861                        $lux_filter.removeClass('open');
24862                    }
24863                    $.each(data.items, function(i,v) {
24864                        var settings = (v.gsettings) ? $.parseJSON(v.gsettings) : {},
24865                            link = (typeof settings.glink != 'undefined') ? settings.glink : '',
24866                            link_icon = (typeof settings.glink != 'undefined' && settings.glink) ? clSVG('gallery-link','20','20',true,'info-link') : '',
24867                            target = (typeof settings.glink_target != 'undefined') ? settings.glink_target : '',
24868                            cp_class = ($.inArray(v.seq,$.gallery.copy) > -1) ? ' active copy' : '',
24869                            mv_class = ($.inArray(v.seq,$.gallery.move) > -1) ? ' active move' : '',
24870                            invisible = (v.visible == '1') ? true : false;
24871                            // file = ((v.image).indexOf('googleusercontent') > -1) ? v.image : v.url
24872                            imgPATH = (typeof settings.storage == 'undefined') ? RPATH : settings.storage,
24873                            // src_s250 = getServeImage(v.image,'250',imgPATH);
24874                            src_s250 = v.url,
24875                            grade_onoff = (settings.grade_onoff) ? settings.grade_onoff : '';
24876
24877                        link = Base64.decode(link);
24878                        if(data.mode == 'shopping') {
24879                            var yet = (v.price == null) ? 'yet' : '';
24880                            $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 +'">');
24881                            // lux
24882                            if(LUX) {
24883                                v.sale = (v.price < v.sale) ? v.sale : '';
24884                                if(v.prod_case) $table.attr('data-pcase',v.prod_case);
24885                            }
24886
24887                            var title = (v.title) ? v.title : '상품명을 입력하세요',
24888                                price = (v.price != null && v.price !== '') ? addCommas(v.price) : '-',
24889                                sale = (v.sale != null && v.sale !== '') ? addCommas(v.sale) : '-',
24890                                soldout = '',
24891                            
24892                            quantity = (v.quantity_on == 'on' && v.quantity) ? addCommas(v.quantity) : 0;
24893                            var discount_settings = (settings.discount)? settings.discount : '';
24894                            var discount_rate = (discount_settings.rate !== undefined && discount_settings.rate)? discount_settings.rate : '';
24895                            var discount_unit = (discount_settings.unit !== undefined && discount_settings.unit)? discount_settings.unit : '';
24896
24897                            var discount = addCommas(discount_rate) + discount_unit;
24898                            var use_badge = (settings.use_badge)? settings.use_badge : '';
24899                            var status = '';
24900
24901                            if(invisible) $table.addClass('invisible');
24902
24903                            var is_soldout = false,
24904                                is_soldout_label = false,
24905                                saleStatus = '',
24906                                badgeList = '';
24907
24908                            quantity = (v.quantity_on == 'off' || v.quantity_on == null)  ? '-' : quantity;
24909
24910                            if(LUX) {
24911                                if(v.soldout) is_soldout = is_soldout_label = true;
24912                            } else {
24913                                if(v.quantity_on == 'off' || v.quantity_on == null || v.quantity_on == '') {
24914                                    if(v.status == 'off' || v.status == '') is_soldout = true;
24915                                } else {
24916                                    if(v.status == 'off' || v.status == '') is_soldout = true;
24917                                    if(v.quantity == 0) is_soldout = is_soldout_label = true;
24918                                }
24919                                if(v.status == 'lim') {
24920                                    saleStatus = '<span class="item-limit" data-toggle="tooltip" data-placement="top" data-original-title="' + v.sales_start + ' ~ ' + v.sales_end + '">기간한정판매</span>';
24921                                    $table.attr('data-out-datetime', (v.sale_now) ? '0' : '1');
24922                                }
24923
24924                                if(use_badge) {
24925                                    var badge_settings = $.parseJSON(localStorage.getItem('badge_settings'));
24926                                    badgeList = drawBadgeList(use_badge, badge_settings);
24927                                }
24928                            }
24929                            if(is_soldout) {
24930                                $table.addClass('soldout');
24931                                if(is_soldout_label) soldout = '<span class="item-soldout">품절</span>';
24932                            }
24933
24934                            switch(v.status) {
24935                                case "on": status = "판매중"; break;
24936                                case "off": status = "판매중지"; break;
24937                                default: status = "판매중지"; break;
24938                            }
24939                            // if(v.quantity_on == 'on' && v.quantity == 0) status = "품절";
24940                            if(sale == '') sale = price;
24941                            if(price == 0 && sale == 0) {
24942                                v.sale_per = 0;
24943                                sale = price;
24944                            }
24945                            if(invisible) $table.addClass('invisible');
24946
24947                            if(LUX) {
24948                                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/>',
24949                                    add_info = '\
24950                                <div class="add-info">\
24951                                    <span class="brand">' + v.brand_name + '</span/>\
24952                                    <span class="sale-rate" data-retail="' + v.retail_price + '">' + ((v.price < v.sale) ? '할인율 <span class="rate">' + v.sale_rate + '</span>%' : '') + '</span/>\
24953                                    '+ margin_str + '\
24954                                </div>';
24955                                soldout += add_info;
24956                            }
24957    
24958                            var empty_title = (v.title == '' || price == '-') ? ' empty' : '';
24959                            var s = '\
24960                                <div class="td-handle"><div class="item-handle cl-sort-handle">' + clSVG('move_handle', 20, 20) + '</div></div>\
24961                                <div class="td-check"><input type="checkbox" name="item_check[]" class="td-input" data-ownproduct="' + (LUX && v.seq >= 1000000000 ? 'Y' : 'N') + '"></div>\
24962                                <div class="td-number">' + (num - i) + '</div>\
24963                                <div class="td-img"><img src="' + src_s250 + '" class="img-responsive">' + link_icon + '</div>\
24964                                <div class="td-title' + empty_title + '"><span class="item-title-str">' + title + '</span>' + saleStatus + badgeList + soldout +'\
24965                                    <ul class="product-item-edit" data-seq="' + v.seq + '">\
24966                                        <li class="edit-gallery-item" data-mode="prodDetail">'+ $.lang[LANG]['editor.block.gallery.product.detail'] +'</li>\
24967                                        <li class="edit-gallery-item" data-mode="prodInfo">'+ $.lang[LANG]['editor.block.gallery.product.info'] +'</li>\
24968                                    </ul>\
24969                                </div>\
24970                                ';
24971                            if(typeof id == 'undefined' || !id || id == -1)
24972                                if(typeof data.gallerys[v.pid] != 'undefined')
24973                                    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>';
24974                                else 
24975                                    s+= '<div class="td-gallery"></div>';
24976
24977                            s+= '<div class="td-date">' + v.datetime2 + '</div>';
24978                            if(LUX) {
24979                                s+= '\
24980                                <div class="td-category">' + v.category_name + '</div>\
24981                                ';
24982                            } else {
24983                                if(typeof data.gallerys[v.pid] != 'undefined') {
24984                                    s+= '\
24985                                    <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>\
24986                                    ';
24987                                } else {
24988                                    s+= '\
24989                                    <div class="td-category' + empty_title + ((data.cate_onoff == 'OFF') ? ' hide' : '') + ((v.item_category.indexOf(',') > -1) ? ' line' : '') + '"></div>\
24990                                    ';
24991                                }
24992                            }
24993                            var edit_button = '', str_quantity = '', hint_quantity = '';
24994                                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>' : '';
24995                            if(v.quantity_on == 'on') {
24996                                if(v.normal_options == false && v.add_options == false) {
24997                                    edit_button = '<div class="edit-button">' + $.gallery.edit_icon + '</div><div class="close-button" data-val="' + quantity + '">' + $.gallery.close_icon + '</div>';
24998                                } else {
24999                                    edit_button = '<div class="edit-button conf">' + $.gallery.edit_icon + '</div>';
25000                                }
25001                            }
25002
25003                            str_quantity = (v.add_options == true && v.quantity_on == "on") ? quantity + '|' + addCommas(v.quantity_add_op) : addCommas(quantity);
25004                            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) + '"' : '';
25005                            var product_status = status;
25006                            if(v.status == 'lim') {
25007                                product_status = ((v.sale_now) ? '판매중' : (v.sale_fin) ? '판매종료' : '판매예정'); 
25008                                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
25008ox="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;
25009                            }
25010                            var status_select = changeStatus(v.status, v.seq);
25011                            if(LUX) {
25012                                s+= '\
25013                                    <div class="td-orig-price' + empty_title + '">' + sale + '</div>\
25014                                    <div class="td-discount' + empty_title + '">' + (LUX ? v.sale_rate : v.sale_per) + '</div>\
25015                                    <div class="td-price' + empty_title + '">' + price + '</div>\
25016                                    <div class="td-quantity' + empty_title + '">' + quantity_need  + str_quantity + '</div>\
25017                                    <div class="td-status">' + product_status + '</div>\
25018                                ';
25019                            } else {
25020                                var sale_per = (v.sale_per) ? v.sale_per : ((typeof v.sale_per === 'number') ? 0 : '-');
25021                                s+= '\
25022                                    <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>\
25023                                    <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>\
25024                                    <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>\
25025                                    <div class="td-quantity' + empty_title + '">' + quantity_need + '<span class="prev-value" ' + hint_quantity + '>' + str_quantity + '</span>' + edit_button + '</div>\
25026                                    <div class="td-status">' + product_status + status_select + '</div>\
25027                                ';
25028                            }
25029    
25030                            $table.append(s);
25031                            
25032                            if ($table.find('.td-title > span').length > 4) {
25033                                $table.find('.td-title .item-title-str').addClass('fw-title-block')
25034                            }
25035
25036                            $('.gallery-items').append($table);
25037                        } else {
25038                            var $info = $('<div class="info"></div>'),
25039                                $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>');
25040
25041                            // if(mv_class) $item.addClass('active move');
25042                            // if(cp_class) $item.addClass('active copy');
25043                            $info.empty();
25044                            if(invisible) $item.addClass('invisible');
25045                            if(typeof settings.glink != 'undefined' && settings.glink) {
25046                                $info.append(link_icon);
25047                                $item.append($info);
25048                            }
25049    
25050                            $('.gallery-items').append($item);
25051                        }
25052                    });
25053                    
25054                    $('.gallery-items-loadmore').remove();
25055                    if(data.mode == 'shopping') {
25056                        if($('.gallery-modal').find('.pagination-wrap').length == 0 && data.total > 0) {
25057                            $('.gallery-items').after('<div class="pagination-wrap open"><ul class="pagination" id="product-pagination"></ul></div>');
25058                            var totalPage = (data.total > 0) ? Math.ceil(data.total/data.view) : 1;
25059                            $.jqPaginator('#product-pagination', {
25060                                totalPages: totalPage,
25061                                totalCounts: data.total,
25062                                currentPage: 1,
25063                                visiblePages: 10,
25064                                onPageChange: function (num, type) {
25065                                    if(type == 'change') {
25066                                        $.gallery.list($.gallery.block_id,num,$.gallery.category,'list');   
25067                                        $.gallery.update = true;
25068                                    }
25069                                    window.localStorage.setItem('gallery-product-page',num);
25070                                }
25071                            });
25072                        }
25073                        if(data.total == 0) {
25074                            var msg = (data.mode == 'shopping') ? $.lang[LANG]['editor.gallery.product.empty'] : $.lang[LANG]['editor.gallery.list.empty'];
25075                            msg = (data.search) ? '결과가 없습니다' : msg;
25076                            $('.gallery-items').append('<p class="text-center sort-disabled category-empty"> ' + msg + '</p>');
25077                        }
25078                    } else {
25079                        if((data.items).length == 0) {
25080                            var msg = (data.mode == 'shopping') ? $.lang[LANG]['editor.gallery.product.empty'] : $.lang[LANG]['editor.gallery.list.empty'];
25081                            msg = (data.search) ? '결과가 없습니다' : msg;
25082                            $('.gallery-items').append('<p class="text-center sort-disabled category-empty"> ' + msg + '</p>');
25083                        } else {
25084                            if((data.items).length < data.total) {
25085                                var count = (data.mode == 'shopping') ? $('.gallery-items .table-item').length : $('.gallery-items .item').length;
25086                                $('.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>');
25087                            }
25088                        }
25089                    }
25090                    if(product_name != null && product_name.length) {
25091                        $('.gallery-list-search-text').val(product_name);
25092                        // $('.gallery-list-search-submit').hide();
25093                        // $('.gallery-list-search-cancel').show();
25094                    }
25095                    $('.gallery-ctrl-category').attr('data-category',data.category.toString()).attr('data-pid',data.pid);
25096    
25097                    var handle = (data.mode == 'shopping') ? '.td-handle' : '.item-ctrl';
25098                    var $item = $('.gallery-items .item');
25099                    
25100                    var gallery_items_handle = (LUX) ? '' : ', .td-handle';
25101                    $('.gallery-items').selectable({
25102                        // distance: 3,
25103                        filter : '.table-item,.item',
25104                        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,
25105                        stop : function(event,ui) {
25106                            if($('#user-edit').length) $('#user-edit').blur(); 
25107                            $.gallery.selected(event,ui);
25108                        }
25109                    });
25110                    $('.item-header').removeClass('ui-selectee');
25111    
25112                    $m.fadeIn(300, function() {
25113                        if(typeof func == 'function') func();
25114                        $('#dummy-drop').remove();
25115                    });
25116    
25117                    $('.gallery-modal').off('scroll').on('scroll', function(e) {
25118                        if($('.gallery-blocks').length && $(this).scrollTop() < 65) {
25119                            $('.product-gallery-list').css('top','93px'); 
25120                        } else $('.product-gallery-list').css('top','0px'); 
25121                        stickyToolbar();
25122                    });
25123                    // resizeGalleryModal();
25124                    setLanguage(LANG);
25125
25126                    if(typeof GALLERY_MODE != 'undefined') {
25127                        GALLERY_MODE.push({
25128                            seq : data.pid,
25129                            mode : data.mode
25130                        });
25131                    }
25132                    
25133                    if(data.gallery_mode != 'shopping' || LUX) {
25134                        $('.gallery-blocks .all-items').addClass('hide');
25135                        if(data.pid) {
25136                            $('.gallery-blocks .menus li[data-gallery-id="' + data.pid +'"]').addClass('active');
25137                            $.gallery.block_id = data.pid;
25138                        }
25139                    }
25140                },
25141                error : function(xhr, status, error) {
25142                    $.processOFF();
25143                    alert("Error " + xhr.status + " : 관리자에게 문의");
25144                }
25145            });
25146        },
25147        list : function(id, page, category, type) {
25148            // if(typeof id == 'undefined' || !id) {
25149            //     alert('Undefined gallery ID');
25150            //     return false;
25151            // }
25152            $.gallery.seqs = [];
25153            if(typeof page =='undefined') page = 1;
25154            if(typeof category =='undefined') category = '';
25155            if(typeof type == 'undefined') type = 'load';
25156            // $('.gallery-items-loadmore').addClass('spinner');
25157            var params = ($('.gallery-modal').length) ? getProductParams() : getSearchURL(),
25158                product_name = getStorageItem('gallery-product-name'),
25159                product_filter = getStorageItem('gallery-product-filter'),
25160                product_view = getStorageItem('gallery-product-view'),
25161                sort = getStorageItem('gallery-product-sort'),
25162                by = getStorageItem('gallery-product-by'),
25163                manager = (id == '' || id == -1) ? SID : '';
25164
25165            $.processON();                
25166            $.ajax({
25167                type: 'POST',
25168                url : '/template/gallery/show',
25169                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 },
25170                dataType : 'json',
25171                async: true,
25172                cache: false,
25173                success : function(data) {
25174                    $.processOFF();
25175                    if(data.error != 'undefined' && data.error) {
25176                        alert(data.error);
25177                        return false;
25178                    }
25179                    (typeof id == 'undefined' || !id) ? $('.gallery-category').hide() : $('.gallery-category').show();
25180                    if(LUX) {
25181                        $('.gallery-list-filter').hide();
25182                        $('.selected-gallery-name').hide();
25183                        $('.gallery-category').hide();
25184                    }
25185                    if(type == 'list') $('.gallery-items').find('.table-item').remove();
25186                    var num = data.total - ((page-1) * data.view);
25187                    $.each(data.items, function(i,v) {
25188                        var settings = (v.gsettings) ? $.parseJSON(v.gsettings) : {},
25189                            link = (typeof settings.glink != 'undefined') ? settings.glink : '',
25190                            link_icon = (typeof settings.glink != 'undefined' && settings.glink) ? clSVG('gallery-link','16','16',true,'info-link') : '',
25191                            target = (typeof settings.glink_target != 'undefined') ? settings.glink_target : '',
25192                            cp_class = ($.inArray(v.seq,$.gallery.copy) > -1) ? ' active copy' : '',
25193                            mv_class = ($.inArray(v.seq,$.gallery.move) > -1) ? ' active move' : '',
25194                            invisible = (v.visible == '1') ? true : false;
25195                            // file = ((v.image).indexOf('googleusercontent') > -1) ? v.image : v.url
25196                            imgPATH = (typeof settings.storage == 'undefined') ? RPATH : settings.storage,
25197                            // src_s250 = getServeImage(v.image,'250',imgPATH);
25198                            src_s250 = v.url,
25199                            grade_onoff = (settings.grade_onoff) ? settings.grade_onoff : '';
25200
25201                        link = Base64.decode(link);
25202                        if(data.mode == 'shopping') {
25203                            var yet = (v.price == null) ? 'yet' : '';
25204                            $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 +'">');
25205                            // lux
25206                            if(LUX) {
25207                                v.sale = (v.price < v.sale) ? v.sale : '';
25208                                if(v.prod_case) $table.attr('data-pcase',v.prod_case);
25209                            }
25210
25211                            var title = (v.title) ? v.title : '상품명을 입력하세요',
25212                                price = (v.price != null && v.price !== '') ? addCommas(v.price) : 0,
25213                                sale = (v.sale != null && v.sale !== '') ? addCommas(v.sale) : 0,
25214                                soldout = '',
25215                                quantity = (v.quantity_on == 'on' && v.quantity) ? addCommas(v.quantity) : '-';
25216                            var discount_settings = (settings.discount)? settings.discount : '';
25217                            var discount_rate = (discount_settings.rate !== undefined && discount_settings.rate)? discount_settings.rate : '';
25218                            var discount_unit = (discount_settings.unit !== undefined && discount_settings.unit)? discount_settings.unit : '';
25219                            var discount = addCommas(discount_rate) + discount_unit;
25220
25221                            var use_badge = (settings.use_badge)? settings.use_badge : '';
25222                            // console.log('use_badge', use_badge);
25223                            if(invisible) $table.addClass('invisible');
25224
25225                            var is_soldout = false,
25226                                is_soldout_label = false,
25227                                saleStatus = '',
25228                                badgeList = '';
25229
25230                            quantity = (v.quantity_on == 'off' || v.quantity_on == null)  ? '-' : quantity;
25231                            if(LUX) {
25232                                if(v.soldout) is_soldout = is_soldout_label = true;
25233                            } else {
25234                                if(v.quantity_on == 'off' || v.quantity_on == null || v.quantity_on == '') {
25235                                    if(v.status == 'off' || v.status == '') is_soldout = true;
25236                                } else {
25237                                    if(v.status == 'off' || v.status == '') is_soldout = true;
25238                                    if(v.quantity == 0) is_soldout = is_soldout_label = true;
25239                                }
25240                                if(v.status == 'lim') {
25241                                    saleStatus = '<span class="item-limit" data-toggle="tooltip" data-placement="top" data-original-title="' + v.sales_start + ' ~ ' + v.sales_end + '">기간한정판매</span>';
25242                                    $table.attr('data-out-datetime', (v.sale_now) ? '0' : '1');
25243                                }
25244
25245                                if(use_badge) {
25246                                    var badge_settings = $.parseJSON(localStorage.getItem('badge_settings'));
25247                                    badgeList = drawBadgeList(use_badge, badge_settings);
25248                                }
25249                            }
25250                            if(is_soldout) {
25251                                $table.addClass('soldout');
25252                                if(is_soldout_label) soldout = '<span class="item-soldout">품절</span>';
25253                            }
25254
25255                            switch(v.status) {
25256                                case "on": status = "판매중"; break;
25257                                case "off": status = "판매중지"; break;
25258                                default: status = "판매중지"; break;
25259                            }
25260                            // if(v.quantity_on == 'on' && v.quantity == 0) status = "품절";
25261                            if(sale == '') sale = price;
25262                            if(price == 0 && sale == 0) {
25263                                v.sale_per = 0;
25264                                sale = price
25265                            }
25266                            if(invisible) $table.addClass('invisible');
25267
25268                            if(LUX) {
25269                                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/>',
25270                                    add_info = '\
25271                                <div class="add-info">\
25272                                    <span class="brand">' + v.brand_name + '</span/>\
25273                                    <span class="sale-rate" data-retail="' + v.retail_price + '>' + ((v.price < v.sale) ? '할인율 <span class="rate">' + v.sale_rate + '</span>%' : '') + '</span/>\
25274                                    ' + margin_str + '\
25275                                </div>';
25276                                soldout += add_info;
25277                            }
25278    
25279                            var empty_title = (v.title == '' || price == '-') ? ' empty' : '';
25280                            var s = '\
25281                                <div class="td-handle"><div class="item-handle cl-sort-handle">' + clSVG('move_handle', 20, 20) + '</div></div>\
25282                                <div class="td-check"><input type="checkbox" name="item_check[]" class="td-input" data-ownproduct="' + (LUX && v.seq >= 1000000000 ? 'Y' : 'N') + '"></div>\
25283                                <div class="td-number">' + (num - i) + '</div>\
25284                                <div class="td-img"><img src="' + src_s250 + '" class="img-responsive">' + link_icon + '</div>\
25285                                <div class="td-title' + empty_title + '"><span class="item-title-str">' + title + '</span>' + saleStatus + badgeList + soldout + '\
25286                                    <ul class="product-item-edit" data-seq="' + v.seq + '">\
25287                                        <li class="edit-gallery-item" data-mode="prodDetail">상세페이지</li>\
25288                                        <li class="edit-gallery-item" data-mode="prodInfo">상품설정</li>\
25289                                    </ul>\
25290                                </div>\
25291                            ';
25292                                // <!--<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>-->\
25293                            s+= '<div class="td-date">' + v.datetime2 + '</div>';
25294                            if(LUX) {
25295                                s+= '\
25296                                <div class="td-category">' + v.category_name + '</div>\
25297                                ';
25298                            } else {
25299                                s+= '\
25300                                <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>\
25301                                ';
25302                            }
25303                            var edit_button = '', str_quantity = '', hint_quantity = '';
25304                                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>' : '';
25305                            if(v.quantity_on == 'on') {
25306                                if(v.normal_options == false && v.add_options == false) {
25307                                    edit_button = '<div class="edit-button">' + $.gallery.edit_icon + '</div><div class="close-button" data-val="' + quantity + '">' + $.gallery.close_icon + '</div>';
25308                                } else {
25309                                    edit_button = '<div class="edit-button conf">' + $.gallery.edit_icon + '</div>';
25310                                }
25311                            }
25312
25313                            str_quantity = (v.add_options == true && v.quantity_on == "on") ? addCommas(quantity) + '|' + addCommas(v.quantity_add_op) : addCommas(quantity);
25314                            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) + '"' : '';
25315                            var product_status = status;
25316                            if(v.status == 'lim') {
25317                                product_status = ((v.sale_now) ? '판매중' : (v.sale_fin) ? '판매종료' : '판매예정');
25318                                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
25318ox="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;
25319                            }
25320                            var status_select = changeStatus(v.status, v.seq);
25321                            if(LUX) {
25322                                s+= '\
25323                                    <div class="td-orig-price' + empty_title + '">' + sale + '</div>\
25324                                    <div class="td-discount' + empty_title + '">' + (LUX ? v.sale_rate : v.sale_per) + '</div>\
25325                                    <div class="td-price' + empty_title + '">' + price + '</div>\
25326                                    <div class="td-quantity' + empty_title + '">' + quantity_need  + str_quantity + '</div>\
25327                                    <div class="td-status">' + product_status + '</div>\
25328                                ';
25329                            } else {
25330                                var sale_per = (v.sale_per) ? v.sale_per : ((typeof v.sale_per === 'number') ? 0 : '-');
25331                                s+= '\
25332                                    <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>\
25333                                    <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>\
25334                                    <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>\
25335                                    <div class="td-quantity' + empty_title + '">' + quantity_need + '<span class="prev-value" ' + hint_quantity + '>' + str_quantity + '</span>' + edit_button + '</div>\
25336                                    <div class="td-status">' + product_status + status_select + '</div>\
25337                                ';
25338                                /*                                
25339                                s+= '\
25340                                    <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>\
25341                                    <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>\
25342                                    <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>\
25343                                    <div class="td-quantity' + empty_title + '">' + quantity_need + '<span class="prev-value">' + str_quantity + '</span>' + edit_button + '</div>\
25344                                    <div class="td-status">' + product_status + status_select + '</div>\
25345                                ';
25346                                */
25347                            }
25348
25349                            $table.append(s);
25350                            $('.gallery-items').append($table);
25351                        } else {
25352                            var $info = $('<div class="info"></div>'),
25353                                $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>');
25354    
25355                            $info.empty();
25356                            if(invisible) $item.addClass('invisible');
25357                            if(typeof settings.glink != 'undefined' && settings.glink) {
25358                                $info.append(link_icon);
25359                                $item.append($info);
25360                            }
25361    
25362                            $('.gallery-items').append($item);
25363                        }
25364                    });
25365                    
25366                    $('.gallery-toolbar').addClass('hide');
25367                    if(product_name != null && product_name.length) {
25368                        $('.gallery-list-search-text').val(product_name);
25369                        // $('.gallery-list-search-submit').hide();
25370                        // $('.gallery-list-search-cancel').show();
25371                    }
25372
25373                    if(type == 'load') {
25374                        $('.gallery-items-loadmore').remove();
25375                        var itemCheck = (data.mode == 'shopping') ? '.table-item' : '.item';
25376        
25377                        if($('.gallery-items ' + itemCheck).length < data.total) {
25378                            $('.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>');
25379                        }
25380                    }
25381    
25382                    // $('.gallery-items').sortable('refresh');                
25383                },
25384                error : function(xhr, status, error) {
25385                    $.processOFF();
25386                    alert("Error " + xhr.status + " : 관리자에게 문의");
25387                }
25388            });
25389        },
25390        setNumber: function() {
25391            var items = $.gallery.seqs;
25392            if(items.length) {
25393                var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item';
25394                $.each(items, function(i,v) {
25395                    $(group+'[data-seq="' + v + '"]').attr('data-index',(i+1));
25396                });
25397            }
25398
25399            if(LUX) {
25400                if($.gallery.seqs.length > 0) {
25401                    var checkDefault = ($('.gallery-items .table-item.ui-selected:not([data-pcase="O"])').length > 0) ? true : false,
25402                        checkPcaseO = ($('.gallery-items .table-item.ui-selected[data-pcase="O"]').length > 0) ? true : false,
25403                        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;
25404
25405                    if(checkPcaseO && !checkDefault) $('.table-toolbar .toolbar-delete').removeClass('hide');
25406                    else $('.table-toolbar .toolbar-delete').addClass('hide');
25407
25408                    if(!checkPcaseO && checkDefault && checkMargin) $('.table-toolbar .toolbar-margin').removeClass('hide');
25409                    else $('.table-toolbar .toolbar-margin').addClass('hide');
25410
25411                    if($('.gallery-items .table-item.ui-selected').length == $('.gallery-items .table-item').length) $('.checkbox-cmd > input[type="checkbox"]').prop('checked',true);
25412                    else $('.checkbox-cmd > input[type="checkbox"]').prop('checked',false);
25413                } else {
25414                    $('.gallery-toolbar').removeClass('hide_col');
25415                    $('.table-toolbar .toolbar-cmd').addClass('hide');
25416                    $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq','');
25417                    $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink','').attr('data-glink-target','');
25418                    $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible','0').text($.lang[LANG]['editor.gallery.icon.visible.off']);
25419                    $('.checkbox-cmd > input[type="checkbox"], .col-check > input[type="checkbox"]').prop('checked',false);
25420                    $('.gallery-toolbar').addClass('hide');
25421                    $('.gallery-items .item-header').removeClass('hide');
25422                }
25423            }
25424        },
25425        selected: function(e,ui) {
25426            $.gallery.seqs = [];
25427            var disabled = false, visible_button = false; no_price = false;
25428            if($.gallery.mode == 'shopping') {
25429                $('.table-item .td-check > input[type="checkbox"]').prop('checked',false);
25430                $.each($('.gallery-items .table-item.ui-selected'), function(i,v) {
25431                    if($(this).attr('data-product') == "false") disabled = true;
25432                    if($(this).attr('data-out-datetime') == "1") visible_button = true;
25433                    if($(this).attr('data-pricechk') == "false") no_price = true;
25434                    $(this).find('.td-check > input[type="checkbox"]').prop('checked',true);
25435                    ($.gallery.seqs).push($(v).attr('data-seq'));
25436                });
25437
25438                if($.gallery.seqs.length > 0) {
25439                    if($('.gallery-items .table-item.ui-selected').length && $('.gallery-items .table-item').length) {
25440                        $('.table-toolbar li').removeClass('hide open');
25441                        $('.gallery-toolbar').addClass('hide_col');
25442                    }
25443                    var firstItem = $('.gallery-items .table-item.ui-selected').eq(0),
25444                        first_seq = firstItem.attr('data-seq'),
25445                        seq = firstItem.attr('data-seq'),
25446                        pid = firstItem.attr('data-pid'),
25447                        link = firstItem.attr('data-link'),
25448                        target = firstItem.attr('data-target'),
25449                        visible = firstItem.attr('data-visible'),
25450                        grade = firstItem.attr('data-grade'),
25451                        vstr = (visible == '1') ? $.lang[LANG]['editor.gallery.icon.visible.on'] : $.lang[LANG]['editor.gallery.icon.visible.off'],
25452                        gstr = (grade == 'ON') ? $.lang[LANG]['editor.gallery.icon.grade.off'] : $.lang[LANG]['editor.gallery.icon.grade.on'];
25453                    if(visible_button) {
25454                        $('.table-toolbar .toolbar-cmd.toolbar-visible').addClass('disabled');
25455                    } else $('.table-toolbar .toolbar-cmd.toolbar-visible').removeClass('disabled');
25456                    if($.gallery.block_id == -1) {
25457                        $('.table-toolbar .toolbar-cmd.toolbar-copy').addClass('disabled');
25458                    }
25459                    $('.table-toolbar .toolbar-cmd').removeClass('hide');
25460                    $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq',first_seq);
25461                    $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink',link).attr('data-glink-target',target);
25462                    $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible',visible).text(vstr);
25463                    $('.table-toolbar .toolbar-cmd i[data-cmd="grade"]').attr('data-grade',grade).text(gstr);
25464                    $('.gallery-toolbar').removeClass('hide');
25465                    $('.gallery-items .item-header').addClass('hide');
25466                    stickyToolbar();
25467                    $.gallery.setNumber();
25468                } else {
25469                    $('.gallery-items .table-item > div').removeClass('hide-text');
25470                    $('.table-toolbar .toolbar-cmd').addClass('hide');
25471                    $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq','');
25472                    $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink','').attr('data-glink-target','');
25473                    $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible','0').text($.lang[LANG]['editor.gallery.icon.visible.off']);
25474                    $('.gallery-toolbar').addClass('hide');
25475                    $('.gallery-items .item-header').removeClass('hide');
25476                }
25477            } else {
25478                $.each($('.gallery-items .item.ui-selected'), function(i,v) {
25479                    ($.gallery.seqs).push($(v).attr('data-seq'));
25480                });
25481                $.gallery.toolbar();
25482                stickyToolbar();
25483            }
25484
25485            (no_price) ? $('.product-cmd').not('.toolbar-org-price').not('.toolbar-stock').addClass('no_price') : $('.product-cmd').removeClass('no_price');
25486            (disabled) ? $('.product-cmd').addClass('disabled') : $('.product-cmd').removeClass('disabled');
25487            if($('.gallery-modal').attr('data-pid') == undefined) {
25488                $('.toolbar-sort.item-sort').addClass('disabled');
25489            }
25490
25491            $('.item-submenu, .view-submenu').hide();
25492            $('.toolbar-sort, .gallery-view-count').removeClass('open');
25493            $('.gallery-blocks .btn-group').removeClass('open');
25494        },
25495        toolbar : function() {
25496            $('.gallery-list-filter').remove();
25497            $('.gallery-items').find('.toolbar.mod-gallery').remove();
25498            if($.gallery.seqs.length == 0) return false;
25499            var $s = $('.gallery-items .item[data-seq="' + $.gallery.seqs[0] + '"]'),
25500                seq = $s.attr('data-seq'),
25501                pid = $s.attr('data-pid'),
25502                link = $s.attr('data-link'),
25503                target = $s.attr('data-target'),
25504                visible = $s.attr('data-visible'),
25505                edit_name = ($.gallery.mode == 'gallery') ? $.lang[LANG]['editor.block.gallery.item.edit.image'] : $.lang[LANG]['editor.block.gallery.item.edit'];
25506
25507            var l = ($s.index()%7 > 3) ? 'right' : '',
25508                mode = $('.gallery-add-items').attr('data-mode');
25509
25510            var vstr = (visible == "1") ? $.lang[LANG]["editor.gallery.icon.visible.on"] : $.lang[LANG]["editor.gallery.icon.visible.off"],
25511                vicon = (visible == "1") ? 'cl_icon_hide02' : 'cl_icon_show',
25512                editable = ($.gallery.seqs.length > 1) ? "disabled" : "";
25513
25514            var s = '\
25515                <ul>\
25516                    <li class="active gallery-item-edit submenu' + editable + ' edit-'+ $.gallery.mode +'">\
25517                ';
25518            if($.gallery.mode == 'project') {
25519                s = s + '\
25520                        ' + $.lang[LANG]['editor.block.gallery.item.edit'] + '</span> <i class="fa fa-caret-down"></i>\
25521                        <ul class="item-submenu">\
25522                            <li class="edit-gallery-item"><i class="" data-glseq="' + seq + '" data-cmd="edit">'+$.lang[LANG]["editor.gallery.icon.thumnail.config"]+'</i></li>\
25523                            <li class="edit-gallery-detail" data-seq="' + seq + '" >'+$.lang[LANG]["editor.gallery.icon.Project.page"]+'</li>\
25524                        </ul>\
25525                    </li>\
25526                ';
25527            } else {
25528                s = s + '\
25529                        <i class="" data-glseq="' + seq + '" data-cmd="edit"></i>' + edit_name + '\
25530                    </li>\
25531                ';
25532            }
25533            s = s + '<li><i class="" data-glseq="' + seq + '" data-cmd="copy"></i>' + $.lang[LANG]['editor.gallery.icon.clone'] + '</li>';
25534
25535            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>\
25536                        <ul class="item-submenu">\
25537                            <li class="sort-top">' + $.lang[LANG]['editor.gallery.icon.order.front'] + '</li>\
25538                            <li class="sort-bottom">' + $.lang[LANG]['editor.gallery.icon.order.end'] + '</li>\
25539                        </ul>\
25540                    </li>';
25541            if(!$('.gallery-modal .gallery-category .gallery-all').hasClass('hide')) {
25542                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>';
25543                s = s + '<ul class="item-submenu">' + $.gallery.cates + '</ul>';
25544                s = s + '</li>';
25545            }
25546            
25547            s = s + '\
25548                    <li><i class="" data-glseq="' + seq + '" data-glink="' + link + '" data-glink-target="' + target + '" data-cmd="link"></i>' + $.lang[LANG]['editor.gallery.icon.link'] + '</li>\
25549            ';
25550            s = s + '\
25551                    <li><i class="" data-glseq="' + seq + '" data-visible="' + visible + '" data-cmd="visible">' + vstr + '</i></li>\
25552                    <li><i class="" data-glseq="' + seq + '" data-cmd="move">' + $.lang[LANG]['editor.block.gallery.item.move'] + '</i></li>\
25553                    <li><i class="" data-glseq="' + seq + '" data-cmd="delete"></i>' + $.lang[LANG]['editor.gallery.icon.delete'] + '</li>\
25554                </ul>\
25555            ';
25556            var $tool_back = $('<div class="toolbar mod-gallery ' + l + '">' + s + '</div>');
25557            $('.gallery-toolbar').empty();
25558            $('.gallery-toolbar').append($tool_back).removeClass('hide');
25559
25560            if($.gallery.seqs.length > 1) { 
25561                $('.gallery-toolbar .toolbar .gallery-item-edit').addClass('disabled');
25562            } else {
25563                $('.gallery-toolbar .toolbar .gallery-item-edit').removeClass('disabled');
25564            }
25565            // $('.gallery-items').selectable('disable');
25566        },
25567        pages : function() {
25568            var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item',
25569                item = $(group).length,
25570                cpage = Math.ceil(item/30),
25571                spos = $('.gallery-modal').scrollTop();
25572            return {
25573                page : cpage, pos : spos
25574            }
25575        },
25576        close : function() {
25577            $.gallery.mode = '';
25578            localStorage.removeItem('gallery-product-view');
25579
25580            if($('.gallery-modal').hasClass('view-detail') && $.gallery.unlink) { // 상세페이지가 삭제됐을경우 리스트로 이동
25581                var go_url = PAGE.split(",");
25582                location.replace('/'+CONFIG_URL+'config/page/' + go_url[0]);
25583            } else {
25584                if($('.gallery-modal').length) {
25585                    localStorage.removeItem('badge_settings');
25586                    localStorage.removeItem('badge_imgs');
25587                    localStorage.removeItem('before_badge_settings');
25588                    $('.gallery-modal').fadeOut(300, function() {
25589                        $('#gallery-style').remove();
25590                        $('#gallery-modal-script').remove();
25591                        $(this).remove();
25592                    });
25593                }
25594
25595                if($.gallery.update) {
25596                    if(typeof showPageCallback == 'function')
25597                        showPageCallback(showPage);
25598                }
25599
25600                // premium block
25601                if( !$('#el-blockConfig').hasClass('open') && $('.element[data-id="' + $.gallery.block_id + '"][data-type="gallery"][data-type2="premium"]').length > 0) {
25602                    if(typeof elGalleryJS[selectID] != 'undefined') elGalleryJS[selectID] = true;
25603                    startGalleryJS($('.element[data-id="' + $.gallery.block_id + '"]'));
25604                }
25605            }
25606        },
25607        save : function() {
25608            var dlink = (typeof PUBDOMAIN != 'undefined' && PUBDOMAIN)? PUBDOMAIN.replace('http://', '') : $('#pubhost a').text();
25609            var publish_str = $.lang[LANG]['editor.publish.info'] + '<p class="publish-site-link">' + dlink + '</p>' + $.lang[LANG]['editor.publish.confirm'];
25610            var modal = $(this).showModalFlat($.lang[LANG]['config.information'], publish_str, true, true, function() {
25611                modal.modal('hide');
25612                $(this).sitePublishByConfig(SID);
25613            }, 'cancel', '', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-publish-confirm');
25614        },
25615    }
25616
25617    $.detail = {
25618        open : function(product, mode) {
25619            var $detail = $('.product-detail-modal'),
25620                title = '';
25621            if($.gallery.mode) {
25622                title = ($.gallery.mode == 'shopping') ? '상품 상세페이지' : '상세페이지';
25623            } else {
25624                title = (mode == 'shopping') ? '상품 상세페이지' : '상세페이지';
25625            }
25626            if($detail.length == 0) {
25627                var s = '\
25628                <div class="product-detail-modal">\
25629                    <div class="detail-page"><iframe class="detail-iframe" src="' + product + '#detail"></iframe></div>\
25630                </div>\
25631                ';
25632                $('body').append(s);
25633                setTimeout(function() { 
25634                    $('.product-detail-modal').addClass('open'); 
25635                },50);
25636            }
25637            $(document).on('click', '.product-detail-modal .modal-close', function(e) {
25638                $.detail.close();
25639            });
25640        },
25641        close : function() {
25642            if($('.product-detail-modal').length) {
25643                $('.product-detail-modal').removeClass('open');
25644                setTimeout(function() { $('.product-detail-modal').remove(); },750);
25645            }            
25646        }
25647    }
25648
25649    var setBadgeColorPicker = function() {
25650        // console.log('setBadgeColorPicker');
25651        $('.color-picker-badge').each(function(idx, v){
25652            $(v).colpick({
25653                onBeforeShow: function(picker) {
25654                    var this_color = style.getHex($(v).css('background-color'));
25655                    $(this).colpickSetColor(this_color);
25656                },
25657                onShow: function(picker) {
25658                    if($(v).hasClass('disabled')){
25659                        $(picker).colpickHide();
25660                        return false;
25661                    }
25662                },
25663                onSubmit: function(hsb, hex, rgb, root_picker) {
25664                    var $optionRow = $(root_picker).closest('.badge-option-row');
25665                    var pn = $(root_picker).attr('pn');
25666                    var val = '#'+hex;
25667
25668                    switch(pn) {
25669                        case 'border-color':
25670                            $optionRow.find('input[name="border_color"]').val(val);
25671                            break;
25672                        case 'background-color':
25673                            $optionRow.find('input[name="background_color"]').val(val);
25674                            break;
25675                        case 'color':
25676                            $optionRow.find('input[name="font_color"]').val(val);
25677                            break;
25678                    }
25679                    // console.log($optionRow.find('.product-badge'), pn, val);
25680                    $optionRow.find('.product-badge-view > .product-badge').css(pn, val);
25681                    $('.cl-change-badge-design').removeClass('reset-design');
25682                    // $('.modal-product-badge').eq(0).removeClass('return-prev');
25683
25684                    $(root_picker).css('background-color', val);
25685                    $(root_picker).colpickHide();
25686                }
25687            });
25688        });
25689    }
25690    $.badgeSettings = {
25691        init: function(badge_settings){
25692            $.each(badge_settings, function(k, v) {
25693                var $badge = $('.badge-view .product-badge[data-type="'+k+'"]');
25694                if(v.type == 'edit') {
25695                    var badgeType = (v.type)? v.type : 'edit';
25696                    var badgeStyle = (v.style)? v.style : 'default-1 small';
25697                    var badgeText = (v.badge_text)? v.badge_text : $.lang[LANG]['gallery.shopping.badge.'+k]
25698                    var badgeBorderColor = (v.border_color)? v.border_color : '';
25699                    var badgeBackgroundColor = (v.background_color)? v.background_color : '';
25700                    var badgeFontColor = (v.font_color)? v.font_color : '';
25701
25702                    $badge.attr('class', 'change-badge-design hand product-badge '+badgeStyle);
25703                    if(badgeBorderColor) $badge.css('border-color', badgeBorderColor);
25704                    if(badgeBackgroundColor) $badge.css('background-color', badgeBackgroundColor);
25705                    if(badgeFontColor) $badge.css('color', badgeFontColor);
25706                    $badge.html(badgeText);
25707                } else {
25708                    // console.log('img',v.image_src);
25709                    $badge.attr('class', 'change-badge-design hand product-badge');
25710                    $badge.removeAttr('style');
25711                    $badge.html('<img src="'+v.image_src+'">');
25712                }
25713            });
25714        },
25715        initDesign: function(badgeArr, badge_settings) {
25716            var changeBadgeDsgnRow = '';
25717            $.each(badgeArr, function(idx, type) {
25718                var bsettings = (typeof badge_settings[type] != 'undefined')? badge_settings[type] : {};
25719                        
25720                var badgeType = (typeof bsettings.type != 'undefined' && bsettings.type)? bsettings.type : 'edit';
25721                var badgeStyle = (typeof bsettings.style != 'undefined' && bsettings.style)? bsettings.style : 'default-1 small';
25722                var badgeText = (typeof bsettings.badge_text != 'undefined' && bsettings.badge_text)? bsettings.badge_text : $.lang[LANG]['gallery.shopping.badge.'+type];
25723                var badgeBorderColor = (typeof bsettings.border_color != 'undefined' && bsettings.border_color)? bsettings.border_color : '';
25724                var badgeBackgroundColor = (typeof bsettings.background_color != 'undefined' && bsettings.background_color)? bsettings.background_color : '';
25725                var badgeFontColor = (typeof bsettings.font_color != 'undefined' && bsettings.font_color)? bsettings.font_color : '';
25726                var badgeImgSrc = (typeof bsettings.image_src != 'undefined' && bsettings.image_src)? bsettings.image_src : '';
25727                var badgeImgName = (typeof bsettings.image_name != 'undefined' && bsettings.image_name)? bsettings.image_name : '';
25728                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>')
25729                                                : $('<span class="product-badge"><img src="'+badgeImgSrc+'"></span>');
25730                if(badgeBorderColor) $badge.css('border-color', badgeBorderColor);
25731                if(badgeBackgroundColor) $badge.css('background-color', badgeBackgroundColor);
25732                if(badgeFontColor) $badge.css('color', badgeFontColor);
25733                var disabled = (badgeType == 'image')? 'disabled' : '';
25734
25735                changeBadgeDsgnRow += '\
25736                    <div class="divTableRow badge-option-row" data-idx="' + idx + '" data-default="' + type + '">\
25737                        <div class="divTableCell product-badge-view">'+ $badge[0].outerHTML +'</div>\
25738                        <div class="divTableCell product-badge-option">\
25739                            <div class="select-style-btn hand">선택</div>\
25740                        </div>\
25741                        <div class="divTableCell product-badge-option">\
25742                            <input type="text" name="badge_text" value="'+ badgeText +'" maxlength="7" ' + disabled + '>\
25743                        </div>\
25744                        <div class="divTableCell product-badge-option">\
25745                            <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>\
25746                        </div>\
25747                        <div class="divTableCell product-badge-option">\
25748                            <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>\
25749                        </div>\
25750                        <div class="divTableCell product-badge-option">\
25751                            <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>\
25752                        </div>\
25753                        <input type="hidden" name="type" value="' + badgeType + '">\
25754                        <input type="hidden" name="style" value="' + badgeStyle + '">\
25755                        <input type="hidden" name="border_color" value="' + badgeBorderColor + '">\
25756                        <input type="hidden" name="background_color" value="' + badgeBackgroun
25756dColor + '">\
25757                        <input type="hidden" name="font_color" value="' + badgeFontColor + '">\
25758                        <input type="hidden" name="image_src" value="'+badgeImgSrc+'">\
25759                        <input type="hidden" name="image_name" value="'+badgeImgName+'">\
25760                    </div>\
25761                ';
25762            });
25763
25764            return changeBadgeDsgnRow;
25765        },
25766        initStylePopup: function($selection) {
25767            var optionIdx = $selection.closest('.badge-option-row').attr('data-idx');
25768            var badgeText = $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="badge_text"]').val();
25769            var badgeType = $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="type"]').val();
25770            var badgeStyle = $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="style"]').val();
25771            var badgeImgSrc = (badgeType == 'image')? $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="image_src"]').val() : '';
25772
25773            if(!badgeText) badgeText = $.lang[LANG]['gallery.shopping.badge.'+$selection.closest('.badge-option-row').attr('data-default')]
25774            $('.badge-style-popup .badge-tab-edit .select-badge .product-badge').html(badgeText);
25775
25776            if(badgeType) {
25777                $('.badge-type-tab li').removeClass('active');
25778                $('.badge-type-tab li[data-tab="'+badgeType+'"]').addClass('active');
25779            }
25780            // console.log('initStylePopup', localStorage.getItem('badge_imgs'))
25781
25782            var popoverObj = {
25783                trigger: 'hover',
25784                container: '.cl-change-badge-design',
25785                placement: 'top',
25786                html: true,
25787                content: '이미지가 삭제되었습니다.'
25788            };
25789
25790            $('.badge-style-popup .select-badge-table img').each(function(idx, v){
25791                // console.log($(v).attr('src'));
25792                $(v).error(function(){
25793                    $(this).attr('src', '//storage.googleapis.com/i.addblock.net/icon_broken_img.png');
25794                    $(this).closest('.product-badge').popover(popoverObj);
25795                });
25796
25797                if($(v).attr('src').indexOf('//storage.googleapis.com/i.addblock.net/icon_broken_img.png') > -1) {
25798                    $(v).closest('.product-badge').popover(popoverObj);
25799                }
25800
25801                if(badgeType == 'image' && badgeImgSrc == $(v).attr('src') && !$('.badge-style-popup .badge-tab-image .select-badge').hasClass('selected')) {
25802                    $(v).closest('.select-badge').addClass('selected');
25803                }
25804            });
25805
25806            if(badgeType == 'edit') {
25807                $('.badge-type-tab > li').removeClass('active');
25808                $('.badge-type-tab > li[data-tab="edit"]').addClass('active');
25809                $('.badge-type-tab-content').addClass('hide');
25810                $('.badge-style-popup .badge-style-footer > span').addClass('hide');
25811                $('.badge-tab-edit').removeClass('hide');
25812
25813                var badgeStyleArr = badgeStyle.split(' ');
25814                var style = badgeStyleArr[0];
25815                var size = badgeStyleArr[1];
25816                // console.log(style, size);
25817                $('.badge-style-popup .badge-size-tab > span').removeClass('active');
25818                $('.badge-style-popup .select-badge-table .product-badge').removeClass('small medium large');
25819                $('.badge-style-popup .select-badge-table .select-badge').removeClass('selected');
25820                
25821                $('.badge-style-popup .badge-size-tab > span[data-size="'+size+'"]').addClass('active');
25822                $('.badge-style-popup .select-badge-table').attr('data-size', size);
25823                $('.badge-style-popup .select-badge-table .product-badge').addClass(size);
25824                $('.badge-style-popup .select-badge-table .select-badge').removeClass('selected');
25825                $('.badge-style-popup .select-badge-table .select-badge[data-style="'+style+'"]').addClass('selected');
25826            } else { //이미지형
25827                $('.badge-type-tab > li').removeClass('active');
25828                $('.badge-type-tab > li[data-tab="image"]').addClass('active');
25829                $('.badge-type-tab-content').addClass('hide');
25830                $('.badge-tab-image').removeClass('hide');
25831                $('.badge-style-popup .badge-style-footer > span').removeClass('hide');
25832            }
25833        },
25834        handleSelection: function($selection, idx){
25835            var optionIdx = $selection.closest('.badge-option-row').attr('data-idx');
25836            var badgeTab = $selection.closest('.badge-type-tab-content');
25837            var badgeEL = $selection.find('.product-badge').clone();
25838
25839            $('.badge-option-row[data-idx="'+optionIdx+'"] .product-badge-view > .product-badge').attr('class', 'product-badge');
25840            $('.cl-change-badge-design').removeClass('reset-design');
25841            // $('.modal-product-badge').eq(0).removeClass('return-prev');
25842
25843            if($selection.closest('.badge-type-tab-content').hasClass('badge-tab-edit')) { //편집형
25844                var $selectedBadge = $selection.find('.product-badge');
25845                var badgeStyle = $selectedBadge.attr('class').replace('product-badge ', '');
25846
25847                var badgeBorderColor = style.getHex($selectedBadge.css('border-color'));
25848                var badgeBackgroundColor = style.getHex($selectedBadge.css('background-color'));
25849                var badgetextColor = style.getHex($selectedBadge.css('color'));
25850
25851                $('.badge-option-row[data-idx="'+optionIdx+'"] .product-badge-view').html(badgeEL);
25852
25853                $('.badge-option-row[data-idx="'+optionIdx+'"]').find('.color-picker-badge').removeClass('disabled');
25854                $('.badge-option-row[data-idx="'+optionIdx+'"]').find('input[name="badge_text"]').prop('disabled', false);
25855
25856                $('.badge-option-row[data-idx="'+optionIdx+'"]').find('.color-picker-badge[pn="border-color"]').css('background-color', badgeBorderColor);
25857                $('.badge-option-row[data-idx="'+optionIdx+'"]').find('.color-picker-badge[pn="background-color"]').css('background-color', badgeBackgroundColor);
25858                $('.badge-option-row[data-idx="'+optionIdx+'"]').find('.color-picker-badge[pn="color"]').css('background-color', badgetextColor);
25859
25860                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="type"]').val('edit');
25861                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="style"]').val(badgeStyle.trim());
25862                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="border_color"]').val(badgeBorderColor);
25863                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="background_color"]').val(badgeBackgroun
25863dColor);
25864                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="font_color"]').val(badgetextColor);
25865                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="image_src"]').val('');
25866                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="image_name"]').val('');
25867            } else { //이미지형
25868                var imgSrc = $selection.find('.product-badge > img').attr('src');
25869                var imgName = $selection.find('.product-badge > img').attr('alt');
25870                if(imgSrc == '//storage.googleapis.com/i.addblock.net/icon_broken_img.png') {
25871                    return false;
25872                }
25873                
25874                $('.badge-option-row[data-idx="'+optionIdx+'"] .product-badge-view').html(badgeEL);
25875
25876                $('.badge-option-row[data-idx="'+optionIdx+'"]').find('.color-picker-badge').addClass('disabled');
25877                // $('.badge-option-row[data-idx="'+optionIdx+'"]').find('input[name="badge_text"]').val('');
25878                $('.badge-option-row[data-idx="'+optionIdx+'"]').find('input[name="badge_text"]').prop('disabled', true);
25879
25880                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="type"]').val('image');
25881                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="style"]').val('');
25882                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="border_color"]').val('');
25883                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="background_color"]').val('');
25884                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="font_color"]').val('');
25885                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="image_src"]').val(imgSrc);
25886                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="image_name"]').val(imgName);
25887            }
25888
25889            setBadgeColorPicker();
25890        }
25891    }    
25892})(jQuery);
25893
25894var getSelectedProductList = function(sid, cmd, gallery_seqs) {
25895    var returnHtml = '';
25896    var route = (CONFIG_URL) ? '/_admin' : '';
25897    $.ajax({
25898        url: route  + '/shopping/productListInfo',
25899        type: 'post',
25900        data: { sid : sid, cmd : cmd, gseqs : JSON.stringify(gallery_seqs) },
25901        dataType: 'html',
25902        success: function (list_html) {
25903            // $('.order-list-area').html(list_html);
25904            returnHtml += list_html;
25905        }, error: function () {
25906
25907        }, complete: function () {
25908            // $.processOFF();
25909        }
25910    });
25911   
25912    return returnHtml;
25913}
25914
25915var SFOLDER_ACTIVE = '';
25916var updateOutputFolder = function (e) {
25917    var list = e.length ? e : $(e.target),
25918        output = list.data('output');
25919
25920    if (window.JSON && list.attr('class') == 'dd') {
25921        output.val(window.JSON.stringify(list.nestable('serialize')));
25922    } else {
25923        if (typeof output != 'undefined') output.val('JSON browser support required');
25924    }
25925
25926    if (SID) {
25927        SFOLDER = JSON.parse($('#nestableFolder-output').val());
25928        $.ajaxSetup({ async : false });
25929        $.post('/template/update/type/folder', { s: $('#nestableFolder-output').val(), id: SID }, function (data) {
25930            checkError(data);
25931        }, 'json');
25932    }
25933}
25934
25935function sortFolderFavoritesTop() {
25936    var $list = $('#nestableFolder > .dd-list');
25937    if (!$list.length) return null;
25938
25939    var $items = $list.children('li.dd-item');
25940    if (!$items.length) return null;
25941
25942    var $all = $items.filter(function () {
25943        return String($(this).attr('data-id')) === 'all';
25944    });
25945
25946    var $rest = $items.not($all);
25947    var $fav = $rest.filter(function () {
25948        return String($(this).attr('data-favorite') || '0') === '1';
25949    });
25950    var $non = $rest.not($fav);
25951
25952    $list.append($all).append($fav).append($non);
25953    $list.children('li.dd-item').removeClass('fli-favorite fli-nonfavorite fli-group-divider');
25954    $fav.addClass('fli-favorite');
25955    $non.addClass('fli-nonfavorite');
25956    if ($fav.length && $non.length) {
25957        $non.first().addClass('fli-group-divider');
25958    }
25959
25960    var raw = $('#nestableFolder-output').val() || '[]';
25961    var data = [];
25962    if (SFOLDER && Array.isArray(SFOLDER) && SFOLDER.length) {
25963        data = $.extend(true, [], SFOLDER);
25964    } else {
25965        try { data = JSON.parse(raw); } catch (e) { data = []; }
25966    }
25967
25968    if (!data.length) return raw;
25969
25970    var map = {};
25971    for (var i = 0; i < data.length; i++) {
25972        map[String(data[i].id)] = data[i];
25973    }
25974
25975    var order = [];
25976    $list.children('li.dd-item').each(function () {
25977        var fid = $(this).attr('data-fid');
25978        if (fid !== undefined && fid !== null && String(fid).trim() !== '') {
25979        order.push(String(fid));
25980        }
25981    });
25982
25983    if (order.indexOf('0') === -1 && map['0']) order.unshift('0');
25984
25985    var out = [];
25986    for (var j = 0; j < order.length; j++) {
25987        var key = order[j];
25988        if (map[key]) out.push(map[key]);
25989    }
25990
25991    for (var k in map) {
25992        if (!map.hasOwnProperty(k)) continue;
25993        var exists = false;
25994        for (var t = 0; t < out.length; t++) {
25995            if (String(out[t].id) === String(k)) { exists = true; break; }
25996        }
25997        if (!exists) out.push(map[k]);
25998    }
25999
26000    var nextVal = JSON.stringify(out);
26001    $('#nestableFolder-output').val(nextVal);
26002    SFOLDER = out;
26003
26004    return nextVal;
26005}
26006
26007var setResourceSelectedBox = function(mode) {
26008    var setResourceTab = $('.modal-resourcebox #'+mode+'storage'),
26009        setResourceSelectedInfo = setResourceTab.find('.resource-ctrl-selectedinfo'),
26010        setResourceSelected = setResourceTab.find('.resource-selected-ul');
26011    setResourceTab.find('.resource-ctrl-btns').removeClass('active');
26012    setResourceSelected.find('.selected-hover').popover('destroy');
26013    if(setResourceSelected.children('li').length > 0) {
26014        if(mode == 'my') {
26015            setResourceTab.find('.resource-ctrl-btns').addClass('active');
26016            var size = 0; 
26017            setResourceSelected.children('li').map(function() { return $(this).data('size')}).each(function(){ size += this;});
26018            setResourceSelectedInfo.find('.size').text('('+formatFileSize(size,2,'str')+')');
26019
26020        }
26021        setResourceTab.find('.resource-useit').addClass('active');
26022        setResourceSelectedInfo.find('.count').text(setResourceSelected.children('li').length);
26023        setResourceSelectedInfo.find('label').show();
26024
26025        setResourceSelected.find('.selected-hover').popover({
26026            container: 'body',
26027            trigger: 'hover',
26028            html: true,
26029            content: $.lang[LANG]['editor.resource.selected.cancel'],
26030            placement: function(context, source) {
26031                $(context).addClass('resource-selected-cancel-popover');
26032                return 'auto top';
26033            }
26034        });
26035
26036    } else {
26037        setResourceTab.find('.resource-useit').removeClass('active');
26038        if(setResourceSelectedInfo.length > 0) {
26039            setResourceSelectedInfo.find('label').hide()
26040            setResourceSelectedInfo.find('.count').text('0');
26041        }
26042    }
26043}
26044
26045var resourceGetPage = function(page,ffolder,fsort,fsearch) {
26046    if(typeof fsort == 'undefined') fsort = 'date_desc';
26047    if(typeof fsearch == 'undefined') fsearch = '';
26048
26049    var activeResourceTab = $('.modal.in .modal-resourcebox .tab-content > .tab-pane.active').last(),
26050        activeResourceTabId = activeResourceTab.attr('id') || '',
26051        iconStorageActive = (
26052            activeResourceTabId == 'iconstorage' ||
26053            $('#el-iconstorage').hasClass('in') ||
26054            $('#el-iconstorage').is(':visible') ||
26055            $('#el-iconstorage').attr('aria-hidden') == 'false'
26056        ),
26057        property = $('.resource-useit').eq(0).attr('data-property'),
26058        checkFileLink = (!iconStorageActive && property == 'flink-change') ? true : false,
26059        checkIconStorage = (iconStorageActive || (typeof property!='undefined' && property.indexOf('icon') > -1)) ? true : false,
26060        // checkGabia = (HOST.indexOf('gabia') > -1 || SERVICE.indexOf('gabia') > -1) ? true : false,
26061        checkGabia = (window.getServiceHost().indexOf('gabia') > -1) ? true : false,
26062        sfl = 'default';
26063                        
26064    var thisResourceTab = (checkFileLink) ?  $('#filestorage') : $('#mystorage');
26065    thisResourceTab = (checkIconStorage) ? $('#iconstorage') : thisResourceTab;
26066
26067    var thisResourceFiles = thisResourceTab.find('ul.files'),
26068        thisResourceSelected = thisResourceTab.find('.resource-selected-ul');
26069
26070    thisResourceFiles.removeClass('empty');
26071    ffolder = (typeof ffolder == 'undefined') ? SFOLDER_ACTIVE : ffolder;
26072    if(checkFileLink) {
26073        ffolder = 'flink@';
26074        if(thisResourceFiles.find('.fitem.selected').length == 0) thisResourceTab.find('.resource-useit').removeClass('active');
26075        if(thisResourceTab.find('#flink-sfl').length > 0) sfl = thisResourceTab.find('#flink-sfl option:selected').val();
26076    } else {
26077        if(thisResourceTab.find('#nestableFolder .fln-group').length > 0) thisResourceTab.find('#nestableFolder .fln-group .btn-fln-cancel').click();
26078    }
26079
26080    if(checkIconStorage) {
26081        fsearch = (typeof fsearch == 'string') ? fsearch.trim() : '';
26082        sfl = (typeof getIconStorageType == 'function') ? getIconStorageType() : ($('#iconstorage .icon_type.active').attr('data-icontype') || 'default');
26083        if(typeof normalizeIconStorageType == 'function') sfl = normalizeIconStorageType(sfl);
26084        else if($.inArray(sfl, ['default', 'google', 'fontawesome']) < 0) sfl = 'default';
26085        fsort = (fsort && fsort != 'date_desc') ? fsort : (thisResourceTab.find('.fitem-category.active').attr('data-category') || 'total');
26086        if(fsearch) {
26087            fsort = 'total';
26088            sfl = 'all';
26089            if(typeof setIconStorageSearchState == 'function') setIconStorageSearchState(true, true);
26090        } else {
26091            if(typeof setIconStorageMaterialState == 'function') setIconStorageMaterialState(sfl);
26092            if(typeof setIconStorageSearchState == 'function') setIconStorageSearchState(false, false);
26093        }
26094    }
26095    var iconstorage_url = (checkIconStorage) ? `/type/icon/category/${encodeURIComponent(fsort)}` : '';
26096
26097    fsearch = (checkIconStorage && typeof fsearch == 'string') ? fsearch.trim() : fsearch;
26098
26099    if(checkIconStorage && !fsearch && typeof isIconStorageHybridType == 'function' && isIconStorageHybridType(sfl) && typeof loadIconStorageCategoryPage == 'function') {
26100        if(page == 1 && (!fsort || fsort == 'total') && typeof getIconImage == 'function') {
26101            getIconImage(fsort, sfl);
26102            cPage = page;
26103            setResourceSelectedBox('my');
26104            thisResourceTab.find('.resource-search-btn').removeClass('clicked');
26105            return;
26106        }
26107
26108        loadIconStorageCategoryPage(fsort, sfl, page, { render: true })
26109            .always(function() {
26110                thisResourceTab.find('.resource-search-btn').removeClass('clicked');
26111                thisResourceFiles.removeClass('ready');
26112                thisResourceFiles.find('.listprogress:not([data-category])').remove();
26113                if(thisResourceFiles.data('uiSelectableScroll')) thisResourceFiles.data('uiSelectableScroll').refresh();
26114                fillResourceViewport(thisResourceTab, thisResourceFiles, page, ffolder, fsort, fsearch);
26115            });
26116
26117        cPage = page;
26118        setResourceSelectedBox('my');
26119        return;
26120    }
26121
26122    if(checkIconStorage && fsearch && typeof stopIconStoragePrefetch == 'function') stopIconStoragePrefetch();
26123
26124    $.ajax({
26125        type : 'post',
26126        url: '/template/resource/files/page/' + page + iconstorage_url +'/sfl/' + encodeURIComponent(sfl) + '/ffolder/' + ffolder,
26127        data: { fsort: fsort, fsearch: fsearch },
26128        dataType: 'json',
26129        async: false,
26130        success: function (data) {
26131            if (typeof(data.error) != 'undefined' && data.error) {
26132                checkError(data);
26133                $.resource.modalFilesEmpty(thisResourceFiles, 'No files uploaded');
26134            } else {
26135                if(page == 1) thisResourceFiles.empty();
26136
26137                cTotal = (!checkFileLink) ? $.resource.getMystorageFlc() : data.total;
26138                if(cTotal <= 0) cTotal = data.total;
26139                var active_category = fsort;
26140                if(checkIconStorage) {
26141                    active_category = (typeof getIconStorageActiveCategory == 'function') ? getIconStorageActiveCategory(data, fsort, sfl) : (data.active_category || fsort);
26142                    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);
26143                }
26144                var path = data.path;
26145
26146                if(checkFileLink) {
26147                    var checkPlan = (typeof property.VALIDPLAN == 'undefined') ? ((typeof VALIDPLAN == 'undefined') ? $.gallery.valid_plan : VALIDPLAN) : property.VALIDPLAN,
26148                        checkPType = (typeof property.VALIDTYPE == 'undefined') ? ((typeof VALIDTYPE == 'undefined') ? $.gallery.valid_type : VALIDTYPE) : property.VALIDTYPE,
26149                        flink_max = (checkPlan) ? 15 : 0;
26150
26151                    if(checkPType == 'BN') flink_max = 100;
26152                    else if(checkPType == 'SM') flink_max = $.lang[LANG]['editor.link.file.unlimited'];
26153    
26154                    thisResourceTab.find('.flink-capacity .flink-cnt').text(cTotal);
26155                    thisResourceTab.find('.flink-capacity .flink-max').text(flink_max);
26156    
26157                    if(cTotal >= flink_max) thisResourceTab.find('.flink-fileinput').addClass('flink-disabled');
26158                    else thisResourceTab.find('.flink-fileinput').removeClass('flink-disabled');
26159    
26160                    if(cTotal > page * 100) {
26161                        thisResourceTab.find('.resource-row.bottom').addClass('active');
26162                        thisResourceTab.find('.resource-loadmore').attr('onclick', 'resourceGetPage(' + (page+1) + ')');
26163                    } else {
26164                        thisResourceTab.find('.resource-row.bottom').removeClass('active');
26165                        thisResourceTab.find('.resource-loadmore').removeAttr('onclick');
26166                    }
26167    
26168                    if(data.file.length == 0) $.resource.modalFilesEmpty(thisResourceFiles, $.lang[LANG]['editor.link.file.list.empty']);
26169                    $.each(data.file, function (idx, val) {
26170
26171                        var file_s = (/^[0-9.]*$/.test(val.filesize)) ? val.filesize * 1 : 0,
26172                            fsize_obj = formatFileSize(file_s, 2, 'obj'),
26173                            tag = '\
26174                                    <li class="fitem">\
26175                                        <div class="fitem-wrap">\
26176                                            <p class="fitem-name" data-seq="' + val.seq + '" data-source="' + val.f
26176ilename + '">' + val.origname + '</p>\
26177                                            <p class="fitem-size"><span class="size" data-size="' +file_s +'" data-unit="' + fsize_obj['unit'] + '">' + fsize_obj['val'] + '</span></p>\
26178                                            <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>\
26179                                        </div>\
26180                                    </li>\
26181                        ';
26182
26183                        thisResourceFiles.append(tag);
26184                    });
26185    
26186                } else if(checkIconStorage) {
26187                    if(fsearch != thisResourceTab.find('.resource-search-stx').val()) thisResourceTab.find('.resource-search-stx').val(fsearch);
26188                    if(typeof renderIconStorageCategories == 'function') renderIconStorageCategories(thisResourceTab, data, active_category, sfl);
26189
26190                    if(data.total == 0 && fsearch) {
26191                        var no_result_str = `<span class="no_result_data">${$.lang[LANG]['editor.resource.noresult']}</span>`;
26192                        $('#iconstorage ul.files').html(no_result_str);
26193                    } else {
26194                        if(typeof renderIconStorageFiles == 'function') renderIconStorageFiles(thisResourceTab, data, sfl, page > 1);
26195                    }
26196                    thisResourceTab.find('.resource-search-btn').removeClass('clicked');
26197
26198                } else {
26199                    if(fsort != thisResourceTab.find('.resource-ctrl-sort select').val()) thisResourceTab.find('.resource-ctrl-sort select').val(fsort).change();
26200
26201                    if(thisResourceTab.find('#nestableFolder').hasClass('ready')) {
26202                        $.resource.setMystorageFolder('set_fll');
26203                        if(ffolder && thisResourceTab.find('#nestableFolder .fli[data-id="' + ffolder + '"]').length > 0) thisResourceTab.find('#nestableFolder .fli[data-id="' + ffolder + '"]').addClass('active').siblings().removeClass('active');
26204                        else thisResourceTab.find('#nestableFolder .fli[data-id="all"]').addClass('active').siblings().removeClass('active');
26205                    }
26206                    
26207                    var selected = new Array();
26208                    thisResourceSelected.children('li').each(function() {
26209                        selected.push($(this).attr('data-seq'));
26210                    });
26211    
26212                    page = (data.file.length < 2) ? page-1 : page;
26213                    page = (page) ? page : 1;
26214                    
26215                    thisResourceFiles.removeClass('empty');
26216                    thisResourceFiles.find('.resource-empty-area').remove();
26217                    $.each(data.file, function (idx, val) {
26218                        var tag = resourceFileTag(val.filename, val.seq, path, selected, val.ffolder, page, val.origname, val.filesize, val.w, val.h, val.magic, val.date);
26219                        thisResourceFiles.append(tag);
26220                    });
26221    
26222                    if(cTotal==0) {
26223                        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'];
26224                        $.resource.modalFilesEmpty(thisResourceFiles, empty_msg);
26225                    } else {
26226                        var upgrade_link = (checkGabia) ? 'https://www.gabia.com/mygabia/service' : '/upgrade/site/' + SID,
26227                            load_btn = '\
26228                                    <img src="https://storage.googleapis.com/i.addblock.net/image-upload.gif">&nbsp;&nbsp;\
26229                                    <span class="resource-info"><span data-lang="config.file.browse">' + $.lang[LANG]["config.file.browse"] + '</span></span>\
26230                                    <input id="mystorageUploadBtn" class="upload-resource-button" type="file" name="files[]" multiple>\
26231                            ',
26232                            upgrade_btn = '\
26233                                <a href="' + upgrade_link + '" style="color: #fff; text-decoration:none;">\
26234                                    <i class="fa fa-level-up" aria-hidden="true" style="margin-right: 5px;"></i>\
26235                                    <span class="resource-info">' + $.lang[LANG]["plan.upgrade"] + '</span>\
26236                                </a>\
26237                            ';
26238    
26239                        if(typeof thisResourceTab.find('.fileinput-button').attr('data-limit') == 'undefined') {
26240                            var check_langs = (typeof SLANG != 'undefined' && !$.isEmptyObject(SLANG.lists) && SLANG.lists.length > 1) ? true : false;
26241                            var str = (data.is_limit) ? upgrade_btn : load_btn,
26242                                css_str = (data.is_limit) ? { 'background-color':'#4889e7', 'margin-left':'5px' } : {}, 
26243                                max_str = (data.is_limit) ? '<span class="error">' + $.lang[LANG]['plan.disk-space.limit.info'] + '</span> ' : '';
26244                            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>';
26245
26246                            thisResourceTab.find('.fileinput-button').attr('data-limit',data.is_limit).html(str).css(css_str);
26247                            thisResourceTab.find('.upload-max-size').html(max_str);
26248                        }
26249                    }
26250                    thisResourceTab.find('.resource-search-btn').removeClass('clicked');
26251                
26252                }
26253                if(thisResourceFiles.data('uiSelectableScroll')) thisResourceFiles.data('uiSelectableScroll').refresh();
26254            }
26255            thisResourceFiles.removeClass('ready');
26256            thisResourceFiles.find('.listprogress').remove();
26257        },
26258        error: function() {
26259            $.resource.modalFilesEmpty(thisResourceFiles, 'No files uploaded');
26260        },
26261        complete: function() {
26262            thisResourceTab.find('.resource-search-btn').removeClass('clicked');
26263            thisResourceFiles.removeClass('ready');
26264            thisResourceFiles.find('.listprogress').remove();
26265        }
26266    });
26267
26268    cPage = page;
26269    setResourceSelectedBox('my');
26270    if(!(checkIconStorage && fsearch)) fillResourceViewport(thisResourceTab, thisResourceFiles, page, ffolder, fsort, fsearch);
26271}
26272
26273var fillResourceViewport = function(thisResourceTab, thisResourceFiles, page, ffolder, fsort, fsearch) {
26274    if(!thisResourceTab.length || !thisResourceFiles.length) return;
26275    if(!thisResourceFiles.closest('.modal.in').length) return;
26276    if(thisResourceFiles.hasClass('empty') || thisResourceFiles.find('.resource-empty-area').length > 0) return;
26277    if(thisResourceFiles.find('.listprogress').length > 0 || thisResourceFiles.data('resourceAutoFill')) return;
26278
26279    var rmode = thisResourceTab.attr('id').replace(/storage$/gi,'');
26280    if($.inArray(rmode, ['my','icon']) < 0) return;
26281    if(rmode == 'icon' && typeof isIconStorageHybridMode == 'function' && isIconStorageHybridMode()) return;
26282
26283    var fitem_cnt = thisResourceFiles.find('.fitem').length,
26284        filesEl = thisResourceFiles.get(0);
26285
26286    if(!filesEl || fitem_cnt <= 0 || fitem_cnt >= cTotal) return;
26287    if(filesEl.scrollHeight > filesEl.clientHeight + 1) return;
26288
26289    thisResourceFiles.data('resourceAutoFill', true);
26290    setTimeout(function() {
26291        thisResourceFiles.removeData('resourceAutoFill');
26292
26293        if(!thisResourceFiles.closest('.modal.in').length) return;
26294        if(thisResourceFiles.find('.listprogress').length > 0) return;
26295
26296        fitem_cnt = thisResourceFiles.find('.fitem').length;
26297        if(fitem_cnt >= cTotal) return;
26298        if(filesEl.scrollHeight > filesEl.clientHeight + 1) return;
26299
26300        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>');
26301        resourceGetPage(page + 1, ffolder, fsort, fsearch);
26302    }, 0);
26303}
26304
26305var resourcePaging = function(page,total,ffolder) {
26306    view = RVIEW;
26307    $('.modal.in .modal-resourcebox .resource-paging').empty();
26308
26309    page_view = 10;
26310    start = Math.floor((page-1) / page_view) * page_view;
26311    pages = Math.ceil(total/view);
26312    end = (Math.floor((page-1) / page_view) + 1) * page_view;
26313    end = (end>pages) ? pages : end;
26314
26315    prev = (start > 0) ? start : 1;
26316    next = ((end+1) > pages) ? pages : end+1;
26317
26318    ffolder = (ffolder) ? 'ffolder' : 'all';
26319
26320    var str = '\
26321    <ul class="pagination pagination-sm" data-pages="'+pages+'">\
26322        <li><a href="javascript:;" onclick="resourceGetPage(' + prev + ')">&laquo;</a></li>\
26323    ';
26324    for(i=start;i<end;i++) {
26325        active = ((i+1)==page) ? 'active' : '';
26326        str = str + '\
26327        <li class="' + active + '"><a href="javascript:;" onclick="resourceGetPage(' + (i+1) + ')">' + (i+1) + '</a></li>\
26328        ';
26329    }
26330    str = str + '\
26331        <li><a href="javascript:;" onclick="resourceGetPage(' + next+ ')">&raquo;</a></li>\
26332    </ul>\
26333    ';
26334
26335    if(total) $('.modal.in .modal-resourcebox .resource-paging').append(str);
26336}
26337
26338function formatFileSize(bytes,decimalPoint,return_style) {
26339    if(typeof return_style == 'undefined' || !return_style)  return_style = 'str';
26340
26341    var return_val = {'val': 0, 'unit': 'Bytes'};
26342    
26343    if(bytes == 0) {
26344        return (return_style == 'obj') ? return_val : '0 KB';
26345    }
26346
26347    var k = 1024,
26348        dm = decimalPoint || 2,
26349        sizes = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
26350        i = Math.floor(Math.log(bytes) / Math.log(k));
26351
26352    return_val['val'] = parseFloat((bytes / Math.pow(k, i)).toFixed(dm));
26353    return_val['unit'] = sizes[i];
26354
26355    if(return_style == 'obj') return return_val
26356    else return return_val['val'] + ' ' + return_val['unit'];
26357}
26358
26359var resourceFileTag = function (source, seq, path, selected, ffolder, page, origname, filesize, file_w, file_h, magic, date) {
26360
26361    filesize = (/^[0-9.]*$/.test(filesize)) ? filesize * 1 : 0;
26362    file_w = (/^[0-9.]*$/.test(file_w)) ? file_w * 1 : 0;
26363    file_h = (/^[0-9.]*$/.test(file_h)) ? file_h * 1 : 0;
26364
26365    var active = ($.inArray(seq,selected)>-1) ? ' ui-selected' : '',
26366        blank = (magic == '') ? path + '/' + source : getServeImage(magic,'0','');
26367        image = (magic == '') ? path + '/800/' + source : magic,
26368        fsize_obj = formatFileSize(filesize, 2, 'obj');
26369    
26370    var ftag_str = '\
26371        <li class="fitem' + active + '">\
26372            <div class="fitem-wrap">\
26373                <div class="fitem-visual">\
26374                    <div class="fitem-thumb">\
26375                        <div class="fitem-mold"><img src="https://storage.googleapis.com/i.addblock.net/sample/sns_cm_1.png"/></div>\
26376                        <img class="fitem-img" src="' + image + '" alt="' + source + '">\
26377                    </div>\
26378                    <div class="fitem-name visible-layout-list"><span>'+origname+'</span></div>\
26379                    <div class="fitem-ctrl">\
26380                        <ul data-ffolder="'+ffolder+'" data-page="'+page+'" data-source="'+source+'" data-seq="'+seq+'" data-fsize="'+filesize+'">\
26381                            <li class="hover">\
26382                                <a class="fitem-ctrl-imgview" data-url="' + blank + '" data-img-original="ON">\
26383                                    <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>\
26384                                </a>\
26385                            </li>\
26386                            <li class="hover">\
26387                                <a class="fitem-ctrl-down" href="/down/fetchimg?s=' + blank + '" alt="' + source + '" download="' + origname + '" target="_self">\
26388                                    <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>\
26389                                </a>\
26390                            </li>\
26391                            <li class="hover">\
26392                                <span class="fitem-ctrl-del">\
26393                                    <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>\
26394                                </span>\
26395                            </li>\
26396                            <li class="visible-layout-list w132"><span class="fitem-date">' + date + '</span></li>\
26397                            <li class="visible-layout-list w85"><span class="fitem-size2">' + file_w + 'x' + file_h + '</span></li>\
26398                            <li class="visible-layout-list w82"><span class="fitem-size3" data-unit="'+fsize_obj['unit']+'">'+fsize_obj['val']+'</span></li>\
26399                        </ul>\
26400                    </div>\
26401                </div>\
26402                <div class="fitem-content visible-layout-grid">\
26403                    <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>\
26404                    <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>\
26405                    <p class="visible-layout-grid fitem-date2">' + date + '</p>\
26406                </div>\
26407            </div>\
26408        </li>\
26409    ';
26410
26411    return $(ftag_str);
26412}
26413
26414
26415var myStorageActive = function() {
26416    return ($('#mystorage').hasClass('active')) ? true : false;
26417}
26418
26419var frStorageUpload = function(v,w,id) {
26420    var deferred = $.Deferred(),
26421        id = (typeof id != 'undefined' && id) ? id : $('li[data-source="' + v + '"]').attr('data-id');
26422
26423    var ex = v.split("|"),
26424        s = [];
26425    if(ex.length>1) {
26426        $.each(ex, function(i,d) {
26427            s[i] = $('li[data-source="' + d + '"]').attr('data-id');
26428        });
26429    } else {
26430        s[0] = id;
26431    }
26432    var ids = s.join("|");
26433
26434    setTimeout(function() {
26435        $.ajax({
26436            type : 'post',
26437            url: '/template/frstorage/upload',
26438            data: { img : v, sid : SID, w : w, ids : ids },
26439            dataType: 'json',
26440            async: false,
26441            success: function (data) {
26442                $.processOFF();
26443                if(data.error) { 
26444                    alert(data.error);
26445                    deferred.reject(data.error);
26446                    return false;
26447                }
26448                deferred.resolve(data);
26449            },
26450            error: function(xhr, status) {
26451                $.processOFF();
26452                var msg = (status == 'parsererror') ? '이미지 업로드 응답을 처리하지 못했습니다.' : '이미지 업로드 중 오류가 발생했습니다.';
26453                alert(msg);
26454                deferred.reject(msg);
26455            }
26456        });
26457    });
26458    return deferred.promise();
26459}
26460
26461var uploadReviewQnaImg = function (e) {
26462    var mode = e.data.mode;
26463    if(mode != 'qna' && mode != 'review'){
26464        return false;
26465    }
26466    var imageCnt = $('.'+mode+'-files-list').children('li').length;
26467    if (imageCnt >= 5) {
26468        alert('이미지는 최대 5개까지 등록이 가능합니다.');
26469        return false;
26470    }
26471
26472    var sid = $('#'+mode+'-file').attr('data-sid'),
26473        uid = $('#'+mode+'-file').attr('data-uid');
26474
26475    $.uploadON();
26476    $(this).fileupload({
26477        url: '/_upload/type/'+mode+'/sid/'+sid+'/uid/'+uid,
26478        dataType: 'json',
26479        pasteZone: null,
26480        async: true,
26481        sequentialUploads: true,
26482        change: function(e, data) {
26483            var fileCount = $('.'+mode+'-files-list>li').length + data.files.length;
26484            if(fileCount > 5) {
26485                alert('이미지는 최대 5개까지 등록이 가능합니다.');
26486                return false;
26487            }
26488
26489            var ext = ['gif', 'jpg', 'jpeg', 'png', 'webp'];
26490            var maxSize  = 1024 * 1024 * 10;
26491            var flag = true;
26492            $.each(data.fileInput[0]['files'], function(idx, item){
26493                var extAry = item['name'].toLowerCase().split('.');
26494                if (ext.indexOf(extAry[extAry.length - 1]) == -1) {
26495                    alert($.lang[LANG]['editor.upload.error.ext']);
26496                    flag = false;
26497                    return false;
26498                }
26499
26500                var fileSize = item['size'];
26501                if (fileSize > maxSize) {
26502                    alert($.lang[LANG]['editor.upload.max.1'] + $.lang[LANG]['editor.upload.max.2']);
26503                    flag = false;
26504                    return false;
26505                }
26506            });
26507            
26508            if(flag === false) {
26509                return false;
26510            }
26511            
26512        },
26513        add: function(e, data) {
26514            var r = $.upload_add(e,data,'image');
26515
26516            if(r.submit) {
26517                var jqXHR = data.submit();
26518                UPLOAD++;
26519            } else {
26520                data.context.find('.loading').html('<i class="fa fa-times error"></i>');
26521                data.context.find('.ing').addClass('error').text(r.err);
26522            }
26523
26524            $('.uploadModal .upload-cancel .btn, .uploadModal .upload-close').off('click').on('click', function(e) {
26525                if(jqXHR != undefined) jqXHR.abort();
26526                data.context.fadeOut().remove();
26527                $('.uploadModal #file-upload-progress').css('width','0%');
26528                $.uploadOFF();
26529                UPLOAD = 0;
26530                UPLOADED = 0;
26531                PROGRESS = 0;
26532            });
26533        },
26534        progress: function(e, data) {
26535            $.upload_progress(e,data);
26536        },                        
26537        done: function(e, data) {
26538            $.upload_done(e,data);
26539            if(typeof data.result.error != 'undefined' && data.result.error) {
26540                $.processOFF();
26541                return false;
26542            }
26543            
26544            UPLOADED++;
26545            var src = (typeof data.result.magic != 'undefined') ? data.result.magic : data.result.src;
26546            var src_orig = (typeof data.result.magic != 'undefined') ? data.result.src_orig : '';
26547            var uploadedImg = '\
26548                <li id="'+mode+'-image-'+imageCnt+'">\
26549                    <img src="'+src+'" class="img-responsive" />\
26550                    <input type="hidden" name="'+mode+'_image[]" value="'+src+'" />\
26551                    <input type="hidden" name="'+mode+'_image_orig[]" value="'+src_orig+'" />\
26552                    <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
26552-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>\
26553                </li>\
26554            ';
26555
26556            $('.'+mode+'-files-list').append(uploadedImg);
26557            imageCnt++;
26558
26559            if(UPLOADED) {
26560                if(UPLOAD==UPLOADED) {
26561                    setTimeout(function() {
26562                        $.uploadOFF();
26563                        UPLOAD = 0;
26564                        UPLOADED = 0;
26565                        PROGRESS = 0;
26566                    },1000);
26567                }
26568            }
26569        },
26570        progressall: function (e, data) {
26571            $.upload_progressall(e,data);
26572        },
26573        start : function(e, data) {
26574            $.upload_start(e,data);
26575            progress1 = 0; progress2 = 0; PROGRESS = 0;
26576        },
26577        dragover : function(e, data) {
26578            e.preventDefault();
26579        },
26580    }).prop('disabled', !$.support.fileInput)
26581        .parent().addClass($.support.fileInput ? undefined : 'disabled');
26582}
26583
26584var deleteReviewQnaImg = function(e) {
26585    var mode = e.data.mode;
26586    if(mode != 'qna' && mode != 'review'){
26587        return false;
26588    }
26589    var parent = $(this).closest('li');
26590    var src_orig = parent.find('input[name="'+mode+'_image_orig[]"]').val();
26591    var seq = $('#'+mode+'-file').data('seq');
26592    var src_files = '';
26593    var src_files_orig = '';
26594
26595    if(seq) {
26596        if($('.'+mode+'-files-list').children('li').length > 0) {
26597            $('.'+mode+'-files-list').children('li').each(function() {
26598                if(src_orig != $(this).find('input[name="'+mode+'_image_orig[]"]').val()) {
26599                    if(src_files != '')  src_files +='||';
26600                    src_files += $(this).find('input[name="'+mode+'_image[]"]').val();
26601                    if(src_files_orig != '')  src_files_orig +='||';
26602                    src_files_orig += $(this).find('input[name="'+mode+'_image_orig[]"]').val();
26603                }
26604            });
26605        }
26606    }
26607
26608    $.processON('Deleting File...');
26609    $.ajax({
26610        type: 'POST',
26611        url: '/_image_delete',
26612        data: {
26613            s: src_orig,
26614            seq: seq,
26615            src_files: src_files,
26616            src_files_orig: src_files_orig,
26617            mode: mode,
26618        },
26619        async: true,
26620        success: function(data) {
26621            // console.log(data);
26622            checkError(data);
26623            parent.remove();
26624            $.processOFF();
26625        }
26626    });
26627}
26628
26629var addrSearchModal = function(input_mode) {
26630    if(typeof input_mode == 'undefined' || input_mode.length == 0)  input_mode = 'input';
26631
26632    if($('script[src="https://t1.kakaocdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js"]').length === 0) {
26633        $.getScript('https://t1.kakaocdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js')
26634            .done(function() { 
26635                $('head').append('<script src="https://t1.kakaocdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js"></script>'); 
26636                setTimeout(function() { addrSearchModal(input_mode); }, 500);
26637            }).fail(function() { console.log('daum maps script fail'); });
26638    } else {
26639
26640        if($('#addr-modal').length === 0) {
26641            var add_position = ($('.mall-mypage-wrap').length > 0) ? $('.mall-mypage-wrap') : $('body'),
26642                as_backdrop = '<div class="addr-modal-backdrop" style="display: none;"></div>';
26643                as_modal = '<div id="addr-modal" style="display: none;">\
26644                                <div class="close">\
26645                                    주소 찾기\
26646                                    <div id="btn-addr-close"><img src="https://storage.googleapis.com/i.addblock.net/fa-close-modal.png" alt="close"></div>\
26647                                </div>\
26648                                <div id="addr-body"></div>\
26649                            </div>';
26650
26651            add_position.append(as_backdrop + as_modal);
26652        } else {
26653            $('#addr-body').html('');
26654        }
26655
26656
26657        $(document).on('click','#btn-addr-close, .addr-modal-backdrop', function() {
26658            $('#addr-modal').fadeOut(300);
26659            $('.addr-modal-backdrop').fadeOut(300, function() { $(this).removeClass('in'); });
26660        });
26661
26662
26663
26664        // Internet Explorer 6-11
26665        var isIE = /*@cc_on!@*/false || !!document.documentMode;
26666
26667        if(isIE && input_mode == 'my-input') {
26668
26669            kakao.postcode.load(function(){
26670                new kakao.Postcode({
26671                    oncomplete: function(data) {
26672                        var addr = ''; // 주소 변수
26673                        var extraAddr = ''; // 참고항목 변수
26674
26675                        if (data.userSelectedType === 'R') { // 사용자가 도로명 주소를 선택했을 경우
26676                            addr = data.roadAddress;
26677                        } else { // 사용자가 지번 주소를 선택했을 경우(J)
26678                            addr = data.jibunAddress;
26679                        }
26680
26681                        if(data.userSelectedType === 'R'){
26682                            if(data.bname !== '' && /[동|로|가]$/g.test(data.bname)){
26683                                extraAddr += data.bname;
26684                            }
26685
26686                            if(data.buildingName !== '' && data.apartment === 'Y'){
26687                                extraAddr += (extraAddr !== '' ? ', ' + data.buildingName : data.buildingName);
26688                            }
26689
26690                            if(extraAddr !== ''){
26691                                extraAddr = ' (' + extraAddr + ')';
26692                            }
26693                        }
26694
26695                        $('#'+input_mode+"-postcode").attr('value',data.zonecode);
26696                        $('#'+input_mode+"-addr1").attr('value',addr+extraAddr).addClass('has-value');
26697
26698                        setTimeout(function() {
26699                            $('#'+input_mode+"-addr2").focus();
26700                        },200);
26701
26702                    },
26703                    width : '100%',
26704                    height : '100%',
26705                    maxSuggestItems : 5
26706                }).open();
26707            });
26708
26709        } else if(input_mode =="addrPopup"){
26710           kakao.postcode.load(function(){
26711                new kakao.Postcode({
26712                    oncomplete: function(data) {
26713                        var addr = ''; // 주소 변수
26714                        var extraAddr = ''; // 참고항목 변수
26715
26716                        if (data.userSelectedType === 'R') { // 사용자가 도로명 주소를 선택했을 경우
26717                            addr = data.roadAddress;
26718                        } else { // 사용자가 지번 주소를 선택했을 경우(J)
26719                            addr = data.jibunAddress;
26720                        }
26721
26722                        if(data.userSelectedType === 'R'){
26723                            if(data.bname !== '' && /[동|로|가]$/g.test(data.bname)){
26724                                extraAddr += data.bname;
26725                            }
26726
26727                            if(data.buildingName !== '' && data.apartment === 'Y'){
26728                                extraAddr += (extraAddr !== '' ? ', ' + data.buildingName : data.buildingName);
26729                            }
26730
26731                            if(extraAddr !== ''){
26732                                extraAddr = ' (' + extraAddr + ')';
26733                            }
26734                        }
26735                         $('#'+input_mode+"-postcode").attr('value',data.zonecode);
26736                        $('#'+input_mode+"-addr1").attr('value',addr+extraAddr).addClass('has-value');  
26737                        
26738                        $('#addr-modal').fadeOut(300);
26739                        $('.addr-modal-backdrop').fadeOut(300, function() { $(this).removeClass('in'); });
26740
26741                         setTimeout(function() {
26742                             $('#'+input_mode+"-addr2").focus();
26743                         },200);
26744
26745                    },
26746                    width : '100%',
26747                    height : '100%',
26748                    maxSuggestItems : 5
26749                }).embed(document.getElementById('addr-body'));
26750
26751                $('#addr-modal').fadeIn(300);
26752                $('.addr-modal-backdrop').fadeIn(300, function() { $(this).addClass('in'); });
26753            });            
26754        } else {
26755            kakao.postcode.load(function(){
26756                new kakao.Postcode({
26757                    oncomplete: function(data) {
26758                        var addr = ''; // 주소 변수
26759                        var extraAddr = ''; // 참고항목 변수
26760
26761                        if (data.userSelectedType === 'R') { // 사용자가 도로명 주소를 선택했을 경우
26762                            addr = data.roadAddress;
26763                        } else { // 사용자가 지번 주소를 선택했을 경우(J)
26764                            addr = data.jibunAddress;
26765                        }
26766
26767                        if(data.userSelectedType === 'R'){
26768                            if(data.bname !== '' && /[동|로|가]$/g.test(data.bname)){
26769                                extraAddr += data.bname;
26770                            }
26771
26772                            if(data.buildingName !== '' && data.apartment === 'Y'){
26773                                extraAddr += (extraAddr !== '' ? ', ' + data.buildingName : data.buildingName);
26774                            }
26775
26776                            if(extraAddr !== ''){
26777                                extraAddr = ' (' + extraAddr + ')';
26778                            }
26779                        }
26780                         $('#'+input_mode+"-postcode").attr('value',data.zonecode);
26781                        $('#'+input_mode+"-addr1").attr('value',addr+extraAddr).addClass('has-value');  
26782                        $('#addr-modal').fadeOut(300);
26783                        $('.addr-modal-backdrop').fadeOut(300, function() { $(this).removeClass('in'); });
26784
26785                        setTimeout(function() {
26786                            $('#'+input_mode+"-addr2").focus();
26787                        },200);
26788
26789                    },
26790                    width : '100%',
26791                    height : '100%',
26792                    maxSuggestItems : 5
26793                }).embed(document.getElementById('addr-body'));
26794
26795                $('#addr-modal').fadeIn(300);
26796                $('.addr-modal-backdrop').fadeIn(300, function() { $(this).addClass('in'); });
26797            });
26798
26799        }
26800    }
26801}
26802var stickyToolbar = function() {
26803    if($('.gallery-header').length == 0) return;
26804    var sticky = $('.gallery-modal > .container').offset().top - 50,
26805        w = $('.gallery-items .table-item').width();
26806    if($('.gallery-modal > .container').outerHeight() + sticky < 0) { 
26807        $('.gallery-modal .toolbar, .gallery-modal .table-col').addClass('sticky');
26808        $('.table-toolbar').css('width',w + 'px');
26809    } else {
26810        $('.gallery-modal .toolbar, .gallery-modal .table-col').removeClass('sticky');
26811        $('.table-toolbar').css('width','auto');
26812    }
26813}            
26814
26815var saveGalleryBlockName = function($this,blockname) {
26816    var blockID = $this.parents('.gallery-name').attr('data-gallery-id');
26817    if(typeof blockID == "undefined" || !blockID) {
26818        $this.showModalFlat('ERROR',$.lang[LANG]['board.error-setting-value'],true,false,'','ok');
26819        return false;
26820    }
26821    var settings = (typeof SETTINGS =='undefined') ? $.gallery.site_settings : SETTINGS;
26822    var bookmark_list = (typeof settings.blockBookmarkList != 'undefined' && settings.blockBookmarkList) ? settings.blockBookmarkList : {},
26823        isBookmark = (typeof bookmark_list['bookmark'+blockID] != 'undefined' && bookmark_list['bookmark'+blockID]) ? true : false,
26824        before_bookmark_name_arr = [],
26825        blockname_list = (typeof settings.blocknameList != 'undefined' && settings.blocknameList) ? settings.blocknameList : {},
26826        regex = /[\{\}\[\]\/!?.,;:|\)*~`^\-+<>@\#$%&\\\=\(\'\"]/gi,
26827        err_str = '', 
26828        isUpdate = false;
26829
26830    if(!$.isEmptyObject(bookmark_list)) { // 이전 bookmark name 설정한 블럭 이름 포함
26831        $.each(bookmark_list, function(k,v) { 
26832            if(typeof blockname_list[k.replace('bookmark','blockname')] == 'undefined') {
26833                before_bookmark_name_arr.push(v);
26834            }
26835        });
26836    }
26837
26838    var blockname_list_arr = (!$.isEmptyObject(blockname_list)) ? Object.keys(blockname_list).map(function(e) { return blockname_list[e]; }) : new Array();
26839
26840    if(typeof blockname_list['blockname'+blockID] != 'undefined' && blockname_list['blockname'+blockID] == blockname) {
26841        $('.blockname-edit').remove();
26842        return false;
26843    } else if (blockname.length == 0 || blockname.length > 20) {
26844        err_str = $.lang[LANG]['config.blockinfo.name.length'];
26845    } else if (regex.test(blockname)) {
26846        err_str = $.lang[LANG]['config.blockinfo.name.specialchar'];
26847    } else if ($.inArray(blockname,blockname_list_arr) > -1 || $.inArray(blockname,before_bookmark_name_arr) > -1) {
26848        err_str = $.lang[LANG]['config.blockinfo.name.overlap'];
26849    } else {
26850        $.post('/template/element/type/blockname/seq/'+blockID, { sid: SID, val: blockname }, function(data) {
26851            if(typeof data.error != 'undefined' && data.error) {
26852                err_str = data.error;
26853            } else {
26854                isUpdate = true;
26855            }
26856        }, 'json');
26857    }
26858
26859    if(err_str.length > 0 ) {
26860        $this.showModalFlat($.lang[LANG]['config.information'],err_str,true,false,'','ok', '', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
26861    } else {
26862        $this.parents('.gallery-name').find('.gallery-block-name').text(blockname);
26863        $this.parents('.gallery-name-edit-input').remove();
26864        if($.gallery.block_id == blockID) {
26865            $('#gallery-name').text(blockname);
26866        }
26867    }
26868
26869    if(!isUpdate) return false;
26870    blocknameUpdate(SID,blockID,blockname);
26871    blocknameListUpdate('update',SID,blockID,blockname);
26872    if(isBookmark) blockBookmarkListUpdate('update',SID,blockID,blockname);
26873}
26874
26875var blocknameDelete = function(sid, seq) {
26876    var settings = (typeof SETTINGS =='undefined') ? $.gallery.site_settings : SETTINGS;
26877    if (typeof seq == 'undefined' || typeof sid == 'undefined' || !seq || !sid) return false;
26878
26879    var hasBookmark = (typeof settings.blockBookmarkList != 'undefined' && typeof settings.blockBookmarkList['bookmark' + seq] != 'undefined');
26880    if (hasBookmark && $('#tpl-menu li a[href="@' + seq + '"][attr-bookmark]').length > 0) {
26881        resetLink($('#tpl-menu li a[href="@' + seq + '"][attr-bookmark]').text());
26882    }
26883
26884    blocknameUpdate(sid, seq, '');
26885    blocknameListUpdate('delete', sid, seq);
26886}
26887
26888var blocknameUpdate = function(sid, id, name) {
26889    var elsettings = { blockname: name },
26890        delete_key = (typeof name == 'undefined' || !name) ? 'blockname' : '';
26891
26892    $.post('/template/settings', { sid: sid, settings: JSON.stringify(elsettings), el: id, delete: delete_key }, function(data) {
26893        var isCheck = checkError(data);
26894        if (!isCheck) return false;
26895
26896        $('.property-blockname-wrap .blockname-txt').text(name);
26897    }, 'json');
26898}
26899
26900var blocknameListUpdate = function(fn, sid, id, name) {
26901    var settings = (typeof SETTINGS =='undefined') ? $.gallery.site_settings : SETTINGS;
26902
26903    if (typeof settings.blocknameList == 'undefined') { settings.blocknameList = {}; }
26904    var blockname_list = {};
26905
26906    if (fn == 'update') {
26907        var blockname_item = {};
26908        blockname_item['blockname' + id] = name;
26909        blockname_list = $.extend({}, settings.blocknameList, blockname_item);
26910    } else if (fn == 'delete') {
26911        if (typeof settings.blocknameList['blockname' + id] == 'undefined') { return false; }
26912        delete settings.blocknameList['blockname' + id];
26913        blockname_list = settings.blocknameList;
26914    }
26915
26916    var update = { blocknameList: blockname_list },
26917        delete_key = ($.isEmptyObject(blockname_list)) ? 'blocknameList' : '';
26918
26919    $.post('/template/settings', { sid: sid, settings: JSON.stringify(update), el: 'site_settings', delete: delete_key }, function(data) {
26920        var isCheck = checkError(data);
26921        if (!isCheck) return false;
26922        settings.blocknameList = blockname_list;
26923    }, 'json');
26924}
26925
26926var blockBookmarkDelete = function(sid, seq) {
26927    var settings = (typeof SETTINGS =='undefined') ? $.gallery.site_settings : SETTINGS;
26928    if (typeof seq == 'undefined' || typeof sid == 'undefined' || !seq || !sid || typeof settings.blockBookmarkList == 'undefined' || typeof settings.blockBookmarkList['bookmark' + seq] == 'undefined') return false;
26929    if ($('#tpl-menu li a[href="@' + seq + '"][attr-bookmark]').length > 0) {
26930        resetLink($('#tpl-menu li a[href="@' + seq + '"][attr-bookmark]').text());
26931    }
26932    blockBookmarkUpdate(sid, seq, false);
26933    blockBookmarkListUpdate('delete', sid, seq);
26934}
26935
26936var blockBookmarkUpdate = function(sid, id, onoff) {
26937    var elsettings = { bookmark: onoff };
26938    var delete_key = (onoff) ? '' : 'bookmark';
26939
26940    $.post('/template/settings', { sid: sid, settings: JSON.stringify(elsettings), el: id, delete: delete_key }, function(data) {
26941        var isCheck = checkError(data);
26942        if (!isCheck) return false;
26943
26944        if (onoff) $('.element[data-id="' + id + '"]').attr('data-bookmark', id);
26945        else $('.element[data-id="' + id + '"]').removeAttr('data-bookmark');
26946    }, 'json');
26947}
26948
26949var blockBookmarkListUpdate = function(fn, sid, id, name) {
26950    var settings = (typeof SETTINGS =='undefined') ? $.gallery.site_settings : SETTINGS;
26951    if (typeof settings.blockBookmarkList == 'undefined') { settings.blockBookmarkList = {}; }
26952    var bookmark_list = {};
26953
26954    if (fn == 'update') {
26955        var bookmark_item = {};
26956        bookmark_item['bookmark' + id] = name;
26957        bookmark_list = $.extend({}, settings.blockBookmarkList, bookmark_item);
26958    } else if (fn == 'delete') {
26959        if (typeof settings.blockBookmarkList['bookmark' + id] == 'undefined') { return false; }
26960        delete settings.blockBookmarkList['bookmark' + id];
26961        bookmark_list = settings.blockBookmarkList;
26962    }
26963
26964    var update = { blockBookmarkList: bookmark_list },
26965        delete_key = ($.isEmptyObject(bookmark_list)) ? 'blockBookmarkList' : '';
26966
26967    $.post('/template/settings', { sid: sid, settings: JSON.stringify(update), el: 'site_settings', delete: delete_key }, function(data) {
26968        var isCheck = checkError(data);
26969        if (!isCheck) return false;
26970        settings.blockBookmarkList = bookmark_list;
26971    }, 'json');
26972
26973    if (fn == 'delete') { //gallery item - link(attr-bookmark) unset
26974        $.post('/template/element/type/gitem-bookmarklink-delete/seq/' + id, { sid: SID }, function(data) {
26975            checkError(data);
26976        }, 'json');
26977    }
26978}
26979
26980var makeBookmarkList = function(bookmarklist, type, id, link) {
26981    var str = '',
26982        isActive = '';
26983
26984    if (typeof bookmarklist == 'undefined' || !bookmarklist) return str;
26985    if (bookmarklist == '{}') bookmarklist = {};
26986    var hideArray = bookmarklist?.hide || [];
26987
26988    $.each(bookmarklist, function(k, v) {
26989        var n_k = k.replace('bookmark', '');
26990        if (k != 'hide') {
26991            isActive = (k == link.replace(/^\@/g, 'bookmark')) ? 'active' : '';
26992            if (hideArray.length > 0) {
26993                if (hideArray.includes(n_k)) {
26994                    return true;
26995                } else {
26996                    str = str + '<li class="' + isActive + '" data-bookmark="' + k + '" data-bookmark-name="' + v + '"><a href="javascript:;">' + v + '</a></li>';
26997                }
26998            } else {
26999                str = str + '<li class="' + isActive + '" data-bookmark="' + k + '" data-bookmark-name="' + v + '"><a href="javascript:;">' + v + '</a></li>';
27000            }
27001        }
27002    });
27003    return str;
27004}
27005
27006var galleryStatusInit = function() {
27007    $('.gallery-items > div').removeClass('active ui-selected').find('input').prop('checked','');
27008    // $('.table-toolbar > li').addClass('disabled').find('i[data-cmd="visible"]').text('숨김');
27009    $('.table-toolbar > li').find('i[data-cmd="visible"]').text('숨김');
27010    $('.gallery-toolbar .toolbar.mod-gallery').remove();
27011}
27012
27013var shoppingGalleryResize = function() {
27014    var $list = $('.product-gallery-list'),
27015        $category = $('.gallery-category'),
27016        $more = $('.gallery-items-loadmore'),
27017        $items = $('.gallery-items'),
27018        $toggle = $('.product-gallery-list-toggle'),
27019        $pagination = $('.pagination-wrap'),
27020        $filter = $('.gallery-list-filter'),
27021        $name = $('.selected-gallery-name'),
27022        $lux_filter = $('.shop-filter-header'),
27023        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>',
27024        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>',
27025        status = window.localStorage.getItem('product-gallery-closed');
27026    var w = $('.gallery-modal')[0]['clientWidth'],
27027        t = ($('.gallery-modal').hasClass('shopping')) ? true : false,
27028        g = (t) ? 1440 : 0,
27029        o = ($('.product-gallery-list').hasClass('open')) ? true : false;
27030
27031    if(g > 0 && w <= g && o == true) {
27032        $toggle.removeClass('open');
27033        $list.removeClass('open');
27034        $category.removeClass('open');
27035        $more.removeClass('open');
27036        $items.removeClass('open');
27037        $pagination.removeClass('open');
27038        $filter.removeClass('open');
27039        $name.removeClass('open');
27040        $lux_filter.removeClass('open');
27041        if($toggle.hasClass('open')) {
27042            $toggle.html(svg_open);
27043        } else {
27044            $toggle.html(svg_close);
27045        }
27046    } 
27047    if(w > g && status == 'false') {
27048        $toggle.addClass('open');
27049        $list.addClass('open');
27050        $category.addClass('open');
27051        $more.addClass('open');
27052        $items.addClass('open');
27053        $pagination.addClass('open');
27054        $filter.addClass('open');
27055        $name.addClass('open');
27056        $lux_filter.addClass('open');
27057        if($toggle.hasClass('open')) {
27058            $toggle.html(svg_open);
27059        } else {
27060            $toggle.html(svg_close);
27061        }
27062    }
27063}
27064
27065var resizeGalleryModal = function() {
27066    var w = $('.gallery-modal')[0]['clientWidth'],
27067        $c_p = $('.gallery-modal > .gallery-header'),
27068        $c_m = $('.gallery-modal > .container, .gallery-modal > .gallery-items, .gallery-modal > .gallery-items-loadmore'),
27069        t = ($('.gallery-modal').hasClass('shopping')) ? true : false,
27070        g = (t) ? 1124 : 1146,
27071        p = ((w-g) > 0) ? (w-g)/2 : 0,
27072        scroll_bar = ($.browser.safari == undefined) ? 17 : 8;
27073    if(p < 50) p = 50;
27074    $c_p.css({'padding-left': p + 'px', 'padding-right': p + 'px'});
27075    $c_m.css({'margin-left': p + 'px', 'margin-right': p + 'px', 'width': 'auto', 'max-width': '100%'});
27076    document.querySelector('.gallery-modal').style.setProperty('--gallery-modal-pl', p+'px', null);
27077    document.querySelector('.gallery-modal').style.setProperty('--gallery-modal-pr', (p+scroll_bar)+'px', null);
27078}
27079
27080var switchDownload = function(option_onoff) {
27081    if($('#download-product').is(':checked') === true) { //다운로드 상품
27082        var firstOption = $('.prod-option[data-option_mode="normal"] .prod-option-list > li').eq(1);
27083        var noneOption = $('.prod-option[data-option_mode="normal"] .prod-option-list > li').eq(0);
27084        
27085        var downloadContent = '';
27086        var state = false;
27087
27088        if ($('#none-option-file').length > 0 && option_onoff == 'on') {
27089            if ($('#none-option-file .file-name').length > 0) {
27090                // var optionSeq = (firstOption.find('.prod-option-title').attr('data-seq')!='')? firstOption.find('.prod-option-title').attr('data-seq') : '';
27091                var fileUrl = $('#none-option-file .file-url').text(),
27092                    fileSize = $('#none-option-file .file-size').text(),
27093                    fileNameDetail = $('#none-option-file .file-name-detail').text(),
27094                    realFileName = $('#none-option-file .real-file-name').text();
27095                state = true;
27096            } else if($('#none-option-file .none-file-name').length > 0) {
27097                // var optionSeq = (firstOption.find('.prod-option-title').attr('data-seq')!='')? firstOption.find('.prod-option-title').attr('data-seq') : '';
27098                var fileUrl = $('#none-option-file .none-file-url').text(),
27099                    fileSize = $('#none-option-file .none-file-size').text(),
27100                    fileNameDetail = $('#none-option-file .none-file-name-detail').text(),
27101                    realFileName = $('#none-option-file .none-real-file-name').text();
27102
27103                state = true;        
27104            }
27105
27106            var dataPn = $('#none-option-file .cl_icon_close').attr('data-pn'),
27107                dataFile = $('#none-option-file .cl_icon_close').attr('data-file');
27108            var fileCnt = 2;
27109            var optionSeq = $('#none-option-file .cl_icon_close').attr('data-seq');
27110        }
27111        if(firstOption.find('.file-name').length > 0 && option_onoff == 'off'){
27112            var optionSeq = (noneOption.find('.prod-option-title').attr('data-seq')!='')? noneOption.find('.prod-option-title').attr('data-seq') : '';
27113            var fileUrl = firstOption.find('.file-url').text(),
27114                fileSize = firstOption.find('.file-size').text(),
27115                fileNameDetail = firstOption.find('.file-name-detail').text(),
27116                realFileName = firstOption.find('.real-file-name').text(),
27117                dataPn = firstOption.find('.cl_icon_close').attr('data-pn'),
27118                dataFile = firstOption.find('.cl_icon_close').attr('data-file');
27119            var fileCnt = 1;
27120            state = true;
27121        }
27122        // console.log(state);
27123        if(state === true) {
27124            downloadContent = '\
27125                <div class="file-name file-name-'+fileCnt+'">\
27126                    <span class="real-file-name">'+realFileName+'</span>\
27127                    <span class="file-name-detail" title="'+realFileName+'">'+fileNameDetail+'</span>\
27128                    <span class="file-size">'+fileSize+'</span>\
27129                    <span class="cl-icon cl_icon_close" data-cnt="1" data-pn="'+dataPn+'" data-file="'+dataFile+'" data-seq="'+optionSeq+'"></span>\
27130                    <span class="file-url">'+fileUrl+'</span>\
27131                </div>\
27132            ';
27133        }
27134        // console.log(downloadContent);
27135        if ($('#normal-option').is(':checked') === true) {
27136            // console.log(firstOption.find('.file-box-list'));
27137            firstOption.find('.file-box-list').html(downloadContent);
27138            firstOption.find('.prod-option-status').text('판매').attr('data-val', 'S');
27139
27140            $('#add-upload-check .product-upload').remove();
27141            noneOption.find('.file-name').remove();   
27142        } else {
27143            var html = '\
27144                <div class="product-upload">\
27145                    <div class="title">파일 업로드</div>\
27146                    <div class="download-contents">\
27147                        <span class="cl_icon_upload02" data-cnt="0">업로드</span>\
27148                        <div id="none-option-file">'+downloadContent+'</div>\
27149                    </div>\
27150                </div>';
27151
27152            $('#add-upload-check').prepend(html);
27153            noneOption.find('.file-box-list').html(downloadContent);
27154            if ($('#none-option-file').length == 0) {
27155                $('.switch-product[value="off"]').prop('checked', true);
27156                $('#status-append').fadeOut(0);
27157                $('#sale-calendar').hide();
27158            }
27159            // firstOption.find('.file-name').remove();;
27160        }
27161    }
27162}
27163
27164var 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>';
27165
27166var addProductOption = function(optionMode) {
27167    var $parent;
27168    var option_mode; //일반, 입력, 추가
27169    
27170    if(optionMode=='normal' || optionMode=='text' || optionMode=='additional'){
27171        $parent = $('.prod-option[data-option_mode="'+optionMode+'"]');
27172        option_mode = optionMode; //일반, 입력, 추가
27173    } else {
27174        $parent = $(this).parent();
27175        option_mode = $parent.data('option_mode'); //일반, 입력, 추가
27176    }
27177    
27178    if($parent.find('.prod-option-item.hide').length) {
27179        $parent.find('.prod-option-item.hide').closest('li').addClass('err').find('.edit-option-title input').focus();
27180        r = shoppingSetOption($parent.find('.prod-option-item.hide'));
27181        if(r == false) return r;
27182    }
27183
27184    var state = 'normal-product';
27185    $('.cl_product_state_check').each(function () {
27186        if ($(this).hasClass('active') === true) {
27187            state = $(this).attr('for');
27188        }
27189    });
27190    var status = true;
27191    var productNumber = $('#prod-no').val();
27192    
27193    // if (option_mode == "normal" && productNumber) {
27194    //     if($('.prod-option[data-option_mode="normal"] .prod-option-list>li').length <= 1) {
27195    //         $.ajax({
27196    //             url: '/shopping/download_list_check',
27197    //             type: 'post',
27198    //             dataType: 'json',
27199    //             data: {'product_number': productNumber},
27200    //             success: function (data) {
27201    //                 if (data.code == 'fail') {
27202    //                     alert(data.message);
27203    //                     status = false;
27204    //                     return false;
27205    //                 }
27206    //             }
27207    //         });
27208    //     }
27209    // }
27210    
27211    // if (status == false) return false;
27212    
27213    var tax = $('#tax').attr('data-total-tax'),
27214        check_quantity = $('.prod-detail-wrap .switch-quantity').prop('checked');
27215
27216    var item = '';
27217    if(option_mode == "text") {
27218        if($parent.find('li').length >= 6) {
27219            $('.prod-option[data-option_mode="text"] > .prod-option-add').addClass('disabled');
27220        }
27221        if($parent.find('li').length >= 7) {
27222            alert('입력형 옵션은 최대 7개까지 추가할 수 있습니다.');    
27223            return false;
27224        }
27225        item = '\
27226            <li>\
27227                <div class="prod-option-item hide">\
27228                    <span class="prod-option-title"></span>\
27229                    <span class="prod-option-require"></span>\
27230                </div>\
27231                <div class="prod-option-edit">\
27232                    <div class="form-wrap">\
27233                        <div class="form-group edit-option-title">\
27234                            <input type="text" maxlength="20" placeholder="안내문구 입력 (예:두께를 mm단위로 입력해주세요.)"/>\
27235                        </div>\
27236                        <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>\
27237                    </div>\
27238                </div>';
27239    } else {
27240        item = '\
27241            <li>\
27242                <div class="prod-option-item hide">\
27243                    <span class="prod-option-move cl-sort-handle">' + clSVG('move_handle', 20, 20) + '</span>\
27244                    <span class="prod-option-title"></span>\
27245                    <span class="prod-option-price"></span>\
27246                    <span class="prod-option-quantity"></span>\
27247                    <span class="prod-option-status"></span>\
27248                    <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>\
27249                </div>\
27250                <div class="prod-option-edit">\
27251                    <div class="form-wrap">\
27252                        <span class="prod-option-move cl-sort-handle">' + clSVG('move_handle', 20, 20) + '</span>\
27253                        <div class="form-group edit-option-title">\
27254                            <input type="text" maxlength="60" placeholder="옵션값"/>\
27255                        </div>\
27256                        <div class="form-group edit-option-price">\
27257                            <input type="text" class="option-price-number sign" placeholder="0" numberonly/>\
27258                        </div>\
27259                        <div class="form-group edit-option-quantity" ' + ((check_quantity) ? '' : 'style="display:none"') + '>\
27260                            <input type="text" class="option-price-quantity" maxlength="5" placeholder="0" numberonly/>\
27261                        </div>\
27262                        <div class="form-group edit-option-select">';
27263                        if (state == 'download-product' && $parent.attr('data-option_mode') == "normal") item += '<div class="option-price-status-str hand" data-val="O">품절</div>';
27264                        else item += '<div class="option-price-status-str hand" data-val="S">판매</div>';
27265                        item += '<ul class="option-price-status-select">\
27266                                <li data-val="S">판매</li>\
27267                                <li data-val="O">품절</li>\
27268                                <li data-val="H">숨김</li>\
27269                            </ul>\
27270                        </div>\
27271                        <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>\
27272                    </div>\
27273                </div>';
27274        if (state == 'download-product' && $parent.attr('data-option_mode') == "normal") {
27275            item += '\
27276                <div class="form-group product-status">\
27277                    <div class="product-state-box">\
27278                        <div class="product-upload">\
27279                            <div class="title">파일 업로드</div>\
27280                            <div class="download-contents">\
27281                                <span class="cl_icon_upload02" data-cnt="'+fileUpdateCnt+'">업로드</span>\
27282                                <div class="file-box-list" id="file-box-'+fileUpdateCnt+'"></div>\
27283                            </div>\
27284                        </div>\
27285                    </div>\
27286                </div>';
27287            fileUpdateCnt++;
27288        }
27289    }
27290    
27291    
27292        item += '</li>';
27293    var $item = $(item);
27294    
27295    $parent.find('.prod-option-list').append($item);
27296    $('.prod-option[data-option_mode="'+option_mode+'"] .prod-option-list>li:last-child').find('.edit-option-title input').focus();
27297
27298    $('.plus-price').removeClass('hide');
27299    // $('.plus-quantity').removeClass('hide');
27300    $('.plus-status').removeClass('hide');
27301
27302    // if(option_mode == "normal") {
27303    //     $('.plus-price').text('추가금액');
27304    //     $('.plus-quantity').text('수량');
27305    //     $('.plus-status').text('상태');
27306    // } else if(option_mode == "additional") {
27307    //     $('#plus-addt-price').text('금액');
27308    //     $('#plus-addt-quantity').text('수량');
27309    //     $('#plus-addt-status').text('상태');
27310    // } else if (option_mode == "text") {
27311    //     $('#check-require').text('필수여부');
27312    // }
27313    
27314    if($('.switch-quantity').is(":checked") == true) {
27315        if($('#normal-option').is(':checked') === true) {
27316            // $('#prod-quantity').attr('readonly','true').removeClass('hide').attr('placeholder','옵션에서 재고 관리');
27317            $('.quantity-label').addClass('on');
27318            $('.plus-quantity').removeClass('hide');
27319        } else if($('#normal-option').is(':checked') === false && $('#additional-option').is(':checked') === true) {
27320            $('.quantity-label').removeClass('on');
27321            $('#prod-quantity').removeAttr('readonly').removeClass('hide');
27322            $('.plus-quantity').removeClass('hide');
27323        } else {
27324            $('.quantity-label').removeClass('on');
27325            $('#prod-quantity').removeAttr('readonly').removeClass('hide');
27326            $('.plus-quantity').addClass('hide');
27327        }
27328    } else {
27329        $('.quantity-label').removeClass('on');
27330        $('.switch-quantity').parents('.form-wrap').addClass('disabled');
27331        $('#prod-quantity').addClass('hide');
27332        $('.prod-option-quantity, .prod-plus-quantity, .edit-option-quantity').hide();
27333        $('.plus-quantity').addClass('hide');
27334    }
27335
27336    return true;
27337}
27338
27339var shoppingSetOption = function(optionItem) {
27340
27341    if($('.prod-option-item.hide').length) {
27342        var $o = (optionItem)? optionItem : $('.prod-option-item.hide');
27343        var ret = true;
27344
27345        $o.each(function(){
27346            var $t = $(this).parent().find('.prod-option-edit input');
27347            // console.log($t);
27348
27349            var $title = $t.closest('.form-wrap').find('.edit-option-title input'),
27350                $desc = $t.closest('.form-wrap').find('.edit-option-desc input'),
27351                $price = $t.closest('.form-wrap').find('.edit-option-price input'),
27352                $quantity = $t.closest('.form-wrap').find('.edit-option-quantity input'),
27353                $status = $t.closest('.form-wrap').find('.option-price-status-str'),
27354                $text_require = $t.closest('.form-wrap').find('.option-require-str');
27355        
27356            var price = removeCommas($price.val()), quantity = removeCommas($quantity.val());
27357            if (!price) price = 0;
27358            if (!quantity) quantity = 0;
27359
27360            if(typeof quantity == 'string') {
27361                quantity = quantity.replace(/,/gi,'') ;
27362            }
27363
27364            quantity = Number(quantity);
27365
27366            price = parseInt(price);
27367            quantity = (quantity * 1);
27368            if(String(price) == "NaN") price = 0;
27369            var abs_price = Math.abs(price),
27370                str_price = abs_price.toString(),
27371                str_quantity = quantity.toString(); 
27372
27373             if(isNaN(price) === true) {
27374                $price.val(0);
27375                price = 0;
27376                $t.closest('li').find('.prod-option-price').attr('data-option-price', price);
27377            }
27378
27379            $t.closest('li').find('.prod-option-title').text($title.val());
27380            $t.closest('li').find('.prod-option-desc').text($desc.val());
27381            $t.closest('li').find('.prod-option-price').text(addCommas(str_price));
27382            $t.closest('li').find('.prod-option-quantity').text(addCommas(str_quantity));
27383            $t.closest('li').find('.prod-option-status').text($status.text());
27384
27385            if(price < 0) {
27386                $t.closest('li').find('.prod-option-price').addClass('minus');
27387            } else {
27388                $t.closest('li').find('.prod-option-price').removeClass('minus');
27389            }
27390            // if($text_require.find('input').is(':checked') == true) {
27391            //     var checkbox = "\
27392            //     <span>필수</span>\
27393            //     <svg class='active' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16'>\
27394            //     <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'/>\
27395            //     </svg>";
27396            //     $t.parents('li').find('.prod-option-require').html(checkbox);
27397            // } else {
27398            //     var checkbox = "\
27399            //     <span>필수</span>\
27400            //     <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16'>\
27401            //     <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'/>\
27402            //     </svg>";
27403            //     $t.parents('li').find('.prod-option-require').html(checkbox);
27404            // }
27405            var option_type = $t.closest('.prod-option').attr('data-option_mode');
27406
27407            if(product_options.advanced == 'false') {
27408                if($title.val() === undefined || $title.val().trim().length == 0 || (option_type == 'text' && $title.val().trim().length > 20)) {
27409                    $t.closest('li').addClass('err');
27410                    if($title.val().trim().length > 20) {
27411                        alert('옵션명은 20자까지 입력이 가능합니다.');
27412                    }
27413                    ret = false;
27414                    return false;
27415                }
27416            }
27417            if($quantity.val() == '') $t.closest('li').find('.prod-option-quantity').text('0');
27418            if($('.switch-quantity').is(':checked') == true && $t.closest('li').find('.prod-option-quantity').text() == '0') {
27419                $t.closest('li').find('.option-price-status-str').attr('data-val','O').text('품절');
27420                $t.closest('li').find('.prod-option-status').attr('data-val','O').text('품절');
27421            }
27422
27423            $t.closest('.prod-option-edit').addClass('hide');
27424            $t.closest('li').find('.prod-option-item').removeClass('hide');
27425            $t.closest('li').removeClass('err');
27426
27427            ret = true;
27428        });
27429        
27430        return ret;
27431    }
27432}
27433
27434var checkDuplicateOptionName = function(el) {
27435    var titles = $('.prod-option-title').map(function(idx, v) { 
27436            var str = $(v).text().trim();
27437            if(str.length > 0) return str;                        
27438        }).get();
27439    var input = el.val().trim();
27440    var cnt = titles.filter(function(el){
27441                return el == input;
27442            }).length;
27443    var flag = false;
27444
27445    if(input.length > 0 && cnt > 1) {
27446        el.parents('li').find('.prod-option-title').text('');
27447        el.val('');
27448        el.focus();
27449        flag = true;
27450        alert('옵션명 중복 오류입니다.'); 
27451    } else {
27452        el.parents('li').find('.prod-option-title').removeClass('now-input');
27453    }
27454
27455    return flag;
27456}
27457
27458var siteConfigOthersCheckModal = function(sid,check_id,check_uadmin,success_callback,cancel_callback) {
27459
27460    var config_url = (check_uadmin) ? '/_config' : '/config',
27461        check_data = {
27462            'id': check_id,
27463            'edit': check_uadmin,
27464            'step': 'check'
27465        };
27466
27467    $.post('/umember/login/others', {
27468        'sid': sid,
27469        'data': JSON.stringify(check_data)
27470    }, function(data) {
27471
27472        if(typeof data.error != 'undefined' && data.error) {
27473            $(this).showModalFlat('ERROR', data.error, true, false, '', 'close');
27474            return false;
27475        }
27476
27477        if(typeof success_callback == 'undefined' || !success_callback) {
27478            success_callback = function() { 
27479                setSiteLogs('config','enter','','dashboard');
27480                location.href = config_url;
27481            };
27482        }
27483
27484        if(!data.result) {
27485            success_callback();
27486        } else {
27487            var o_id = data.others_id,
27488                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'],
27489                checkOtherLoginModal = $(this).showModalFlat($.lang[LANG]['config.information'], str, true, true, function() {
27490                    $.processON('Other Login Disconnecting...');
27491
27492                    var set_data = check_data;
27493                    set_data['step'] = 'set';
27494
27495                    $.ajax({
27496                        type: 'POST',
27497                        url: '/umember/login/others',
27498                        data: { sid: SID, data: JSON.stringify(set_data) },
27499                        dataType: 'json',
27500                        async: true,
27501                        success: function(data) {
27502                            setTimeout(function() {
27503                                $.processOFF();
27504                                success_callback();
27505                            }, 400);
27506                        }
27507                    });
27508                    
27509                }, 'cancel', 'ok', 'cl-p70 cl-cmmodal cl-s-btn w560 cl-p0 login-modal', '', '', '', cancel_callback);
27510        }
27511
27512    }, 'json');
27513}
27514
27515var changeBrokenImages = function(el) {
27516    if($(el).length == 0) return;
27517    // if($(el).find('.hideBlockWrap').length > 0) return;
27518    var broken_icon = '//storage.googleapis.com/i.addblock.net/icon_broken_img.png',
27519        broken_image = '//storage.googleapis.com/i.addblock.net/img_broken.png',
27520        broken_popup = '//storage.googleapis.com/i.addblock.net/img_broken_fill_500.png';
27521
27522    var checkBlockConfig = $(el).is('#el-blockConfig'),
27523        checkSiteConfig = $(el).is('#el-siteConfig'),
27524        checkElement = $(el).is('.element'),
27525        checkMenu = $(el).is('header'),
27526        // broken_img =  (checkBlockConfig || checkMenu) ? '//storage.googleapis.com/i.addblock.net/icon_broken_img.png' : '//storage.googleapis.com/i.addblock.net/img_broken.png',
27527        broken_img =  (checkBlockConfig) ? broken_icon : broken_image,
27528        broken_bg = (checkBlockConfig) ? 'none' : 'url(' + broken_img + ')';
27529
27530    if(checkElement || checkMenu) {
27531        var el_bg = $(el).css('background-image').replace(/^url\(['"]?([^'"]+)['"]?\)/, '$1');
27532        
27533        el_bg = el_bg.replace(/^(http)?(s)?(:)?\/\/i\.addblock\.net\//g,'//storage.googleapis.com/i.addblock.net/');
27534        if(el_bg.match(/(http)?(s)?(\:)?\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/) != null) {
27535            $('<img>', { src : el_bg }).on('error', function(e) {
27536                console.log('block bg img error: '+el_bg);
27537
27538                $(el).css('background-image',broken_bg);
27539                e.target.remove();
27540            }.bind(this));
27541        }
27542    }
27543
27544    $(el).find('[data-attach="true"]:not(img), #preview-image').each(function() {
27545        var this_attach = $(this),
27546            attch_bg = this_attach.css('background-image').replace(/^url\(['"]?([^'"]+)['"]?\)/, '$1'),
27547            this_el = this_attach.closest('.element').attr('data-el');
27548
27549        attch_bg = attch_bg.replace(/^(http)?(s)?(:)?\/\/i\.addblock\.net\//g,'//storage.googleapis.com/i.addblock.net/');
27550        if(attch_bg.match(/(http)?(s)?(\:)?\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/) != null) {
27551            $('<img>', { src : attch_bg }).on('error', function(e) {
27552                console.log('attach bg img error: '+attch_bg);
27553
27554                if(this_attach.is('[data-target]')) {
27555                    // img_broken background-image inline css reset
27556                    var attach_html = this_attach.outerHTML();
27557                    this_attach.replaceWith(attach_html.replace(/style\=\"(.+)?background\-image\:([^\;]+)\;\"(\=\"\")?/gi,''));
27558
27559                    var this_selector = '.' + $('.'+this_el).attr('data-name') + ' ' + this_attach.attr('data-target'),
27560                        this_css = $('#'+this_el+'css').html();
27561                    $('#'+this_el+'css').html( this_css + this_selector + ' { background-image: ' + broken_bg + '; }');
27562                } else {
27563                    this_attach.css('background-image',broken_bg);
27564                }
27565                e.target.remove();
27566            }.bind(this));
27567        }
27568    });
27569
27570    $(el).find('img').each(function() {
27571        var el_img = $(this);
27572        var this_img = el_img.attr('src');
27573        if(typeof this_img == 'undefined' || this_img == '') return;
27574
27575        if(this_img.match(/^\/\/i\.addblock\.net\//gi) !== null) {
27576            this_img = this_img.replace(/^\/\/i\.addblock\.net\//gi,'//storage.googleapis.com/i.addblock.net/');
27577            $(this).attr('src',this_img);
27578        }
27579
27580        $(this).error(function() {
27581            // console.log('img error: '+this_img);
27582            $(this).attr('data-orgimg',this_img);
27583
27584            if(checkSiteConfig) {
27585                if($(this).closest('.sc-banner-img-thumb').length > 0) {
27586                    var e_b_type = $(this).closest('.tab-panel').attr('data-type'),
27587                        e_b_id = $(this).closest('.panel-banner-item').attr('data-id'),
27588                        e_b_device = $(this).closest('.sc-banner-img').attr('data-device');
27589
27590                    $(this).unbind('error').attr('src', broken_icon);
27591                    if(e_b_device == 'p') $(this).closest('.panel-banner-item').find('.pt-thumb img').unbind('error').attr('src', broken_icon);
27592                    if(e_b_type == 'band') {
27593                        var e_b_root = (e_b_device == 'p') ? '--scbandBanner-img-pc' : '--scbandBanner-img-mobile';
27594                        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);
27595                    }
27596                }
27597            } else {
27598                $(this).unbind('error').attr('src', broken_img)
27599                    .removeAttr('data-storage')
27600                    .removeAttr('data-photo-id')
27601                    .removeAttr('data-img-val')
27602                    .removeAttr('data-width');
27603                if(checkBlockConfig) {
27604                    if($(this).closest('.attach-thumb').length > 0) $(this).closest('.attach-thumb').eq(0).css('background-image', broken_bg);
27605                } else {
27606                    if($(this).closest('.img-wrapper').find('.g-img').length > 0) $(this).closest('.img-wrapper').find('.g-img').css('background-image', broken_bg);
27607                }
27608            }
27609        });
27610
27611        if(checkBlockConfig) {
27612            this_img = replaceBrokenImages(this_img, 'icon');
27613            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);
27614        }
27615
27616        el_img.attr('src', this_img);
27617    });
27618
27619    if($(el).attr('data-type') == 'video' && $(el).attr('data-mode') == 'zoom') {
27620        $(el).find('.video-gallery-url').each(function(idx, v) {
27621            if($(v).attr('href').indexOf('youtu') > -1) {
27622                let poster = $(v).attr('data-poster');
27623                const testImg = new Image();
27624                testImg.onload = function () {
27625                    if (this.width <= 120 && this.height <= 90) {
27626                        const thumb = poster.replace('maxresdefault', '0');
27627                        $(v).attr('data-poster', thumb);
27628                        $(v).find('.ly-img').css('background-image', 'url(' + thumb + ')');
27629                    }
27630                };
27631                testImg.src = poster;
27632            }
27633        });
27634    }
27635}
27636
27637var replaceBrokenImages = function(path,return_type) {
27638    var check_broken_icon = /^(http)?(s)?(:)?\/\/storage\.googleapis\.com\/i\.addblock\.net\/icon_broken_img\.png/gi,
27639        check_broken_img = /^(http)?(s)?(:)?\/\/storage\.googleapis\.com\/i\.addblock\.net\/img_broken\.png/gi,
27640        v = path;
27641
27642    if(return_type == 'img') return v.replace(check_broken_icon, '//storage.googleapis.com/i.addblock.net/img_broken.png');
27643    else return v.replace(check_broken_img, '//storage.googleapis.com/i.addblock.net/icon_broken_img.png');
27644}
27645
27646var getServeImage = function(f,w,path) {
27647    if(f == undefined) return;
27648    var r = '';
27649    if(typeof w === 'number') w = String(w);
27650    if(f.indexOf('googleusercontent') > -1) {
27651        var magic_type = (typeof SETTINGS != 'undefined') ? SETTINGS.magic_type : property.SETTINGS.magic_type,
27652            check_magic_type = (typeof magic_type != 'undefined' && magic_type == 'webp') ? true : false;
27653            t =  (check_magic_type) ? '-rw' : '';
27654
27655        var n = f.indexOf('=');
27656        f = f.substring(0, n != -1 ? n : f.length);
27657        switch(w) {
27658            case "0"      : r = f + '=s0'+t;            break;
27659            case "30"     : r = f + '=w30'+t;           break;
27660            case "60"     : r = f + '=w60-h60-n'+t;     break;
27661            case "250"    : r = f + '=w250-h250-n'+t;   break;
27662            case "300"    : r = f + '=w300-h300-n'+t;   break;
27663            case "500"    : r = f + '=w500-h700-n'+t;   break; //5:7
27664            case "600"    : r = f + '=w600-h600-n'+t;   break; //1:1
27665            case "650"    : r = f + '=w650-h366-n'+t;   break; //16:9
27666            case "670"    : r = f + '=w670-h1005-n'+t;  break; //6:9
27667            case "700"    : r = f + '=w700-h500-n'+t;   break; //7:5
27668            case "800"    : r = f + '=w800'+t;          break;
27669
27670            case "540"    : r = f + '=w600-h480-n'+t;   break; //5:4
27671            case "430"    : r = f + '=w600-h450-n'+t;   break; //4:3
27672            case "320"    : r = f + '=w600-h400-n'+t;   break; //3:2
27673            case "169"    : r = f + '=w650-h366-n'+t;   break; //16:9
27674            case "450"    : r = f + '=w480-h600-n'+t;   break; //4:5
27675            case "340"    : r = f + '=w450-h600-n'+t;   break; //3:4
27676            case "230"    : r = f + '=w400-h600-n'+t;   break; //2:3
27677            case "916"    : r = f + '=w450-h800-n'+t;   break; //9:16
27678
27679            case "1920"   :
27680                $.ajax({
27681                    type: 'POST',
27682                    url: '/template/image',
27683                    data: { url : f, width : w },
27684                    dataType: 'json',                    
27685                    async: false,
27686                    success: function(data) {
27687                        if(typeof data.s800 != 'undefined') {
27688                            if(w == "800")
27689                                r = (Number(data.s800) > 2560) ? f + '=s0' : f + '=w800-h' + data.s800 + '-n';
27690                            if(w == "1920")
27691                                r = (Number(data.s1920) > 2560) ? f + '=s0' : f + '=w1920-h' + data.s1920 + '-n';
27692                            r+=t;
27693                        } else {
27694                            r = (check_magic_type) ? f+'=-rw' : f;
27695                        }
27696                    }
27697                });
27698                break;                           
27699            case "map-info"    : r = f + '=w640-h550-n'+t;   break;
27700            default       : r = (check_magic_type) ? f+'=-rw' : f;  break;
27701        }
27702    } else {
27703        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) {
27704            r = f;
27705        } else {
27706            path = (path.slice(-1) == '/') ? path : path + '/';
27707            // r = (f.indexOf('http:') > -1) ? f : (w == "0" || w == "") ? path + f : path + w + '/' + f;
27708            if(f.indexOf('//') > -1) {
27709                if(w == "0" || w == "") {
27710                    file_name = f.split('/').pop();
27711                    r = path + file_name;
27712                }
27713            } else {
27714                r = (w == "0" || w == "") ? path + f : path + w + '/' + f;
27715            }
27716            // r = (f.indexOf('//') > -1) ? f : (w == "0" || w == "") ? path + f : path + w + '/' + f;
27717        }
27718    }
27719    return r;
27720}
27721
27722Date.prototype.format = function (f) {
27723    if (!this.valueOf()) return " ";
27724
27725    var weekName = ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"];
27726    var d = this;
27727    
27728    return f.replace(/(yyyy|yy|MM|dd|E|hh|mm|ss|a\/p)/gi, function(da) {
27729        switch (da) {
27730            case "yyyy": return d.getFullYear();
27731            case "yy": return (d.getFullYear() % 1000).zf(2);
27732            case "MM": return (d.getMonth() + 1).zf(2);
27733            case "dd": return d.getDate().zf(2);
27734            case "E": return weekName[d.getDay()];
27735            case "HH": return d.getHours().zf(2);
27736            case "hh": return ((h = d.getHours() % 12) ? h : 12).zf(2);
27737            case "mm": return d.getMinutes().zf(2);
27738            case "ss": return d.getSeconds().zf(2);
27739            case "a/p": return d.getHours() < 12 ? "오전" : "오후";
27740            default: return da;
27741        }
27742    });
27743};
27744
27745String.prototype.string = function(len){var s = '', i = 0; while (i++ < len) { s += this; } return s;};
27746String.prototype.zf = function(len){return "0".string(len - this.length) + this;};
27747Number.prototype.zf = function(len){return this.toString().zf(len);};
27748
27749var galleryDeleteItem = function(seq,callback) {
27750    if(CANCEL) return true;
27751    var item_page = $('.gallery-items div[data-seq="' + seq + '"]').attr('data-page');
27752    $.ajax({
27753        url: '/template/element/type/get-projectPage-bookmarkBlock/seq/' + seq,
27754        data: {sid: SID, page: item_page},
27755        dataType: 'json',
27756        type: 'POST',
27757        async: true,
27758        cache: false,
27759        success: function (data) {
27760            checkError(data);
27761            if(typeof callback == 'function') {
27762                callback(data);
27763            }
27764        }
27765    }, 'json');                
27766}
27767
27768var glItemDelete = function(ids, page) {
27769    $.post('/template/gallery/delete', { sid: SID, s: ids, page: page }, function(data) {
27770        checkError(data);
27771    }, 'json');
27772}
27773function removeOptionModal(optionList, optionMode) {
27774    // console.log(optionList);
27775    var sid = (typeof SID == 'undefined') ? property.SID : SID;
27776    if(optionList.length > 0) {
27777        var modal = $(this).showModalFlat($.lang[LANG]['config.information'], '선택한 옵션을 삭제하시겠습니까?', true, true, function() {
27778            optionList.each(function(){
27779                var seq = $(this).find('.prod-option-title').attr('data-seq');
27780                
27781                if(typeof seq != "undefined" || seq) {
27782                    $.post('/template/products', { seq : seq, sid : sid, type : 'delete', mode: 'option' }, function(data) {
27783                        if(typeof data.error != "undefined" || data.error) {
27784                            alert(data.error);
27785                            return false;
27786                        }
27787
27788                        var liTotal = 0;
27789                        $('.prod-option-list > li').each(function () { liTotal++; });
27790                        if (liTotal < 2) $('.prod-option .plus-price').addClass('hide');
27791                    }, 'json');
27792                } else {
27793                    var liTotal = 0;
27794                    $('.prod-option-list > li').each(function () { liTotal++; });
27795                    if (liTotal < 2) $('.prod-str-price').text('');
27796                }
27797            });
27798
27799            optionList.remove();
27800            $('.prod-option[data-option_mode="'+optionMode+'"]').addClass('hide');
27801
27802            var cnt = $('.prod-option[data-option_mode="normal"] .prod-option-list > li').length;
27803            if (cnt <= 1) {
27804                var html = '<div class="download-contents">\
27805                                <span class="cl_icon_upload02" data-cnt="0">업로드</span>\
27806                                <div id="none-option-file"></div>\
27807                            </div>';
27808                fileUpdateCnt++;
27809
27810                $('#add-upload-check').prepend(html);
27811                if ($('#none-option-file').length > 0) {
27812                    $('.switch-product[value="off"]').prop('checked', true);
27813                    $('#status-append').fadeOut(0);
27814                    $('#sale-calendar').hide();
27815                }
27816            }
27817
27818            modal.modal('hide');
27819        }, 'cancel', 'ok', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0', false, function(){
27820            $('#'+optionMode+'-option').prop('checked', true);
27821        }, '', function(){
27822            if(optionMode == 'normal') {
27823                if($('.prod-option[data-option_mode="normal"] .prod-option-list > li').length > 1) {
27824                    $('#'+optionMode+'-option').prop('checked', true);
27825                } 
27826            } else {
27827                if($('.prod-option[data-option_mode="'+optionMode+'"] .prod-option-list > li').length > 0) {
27828                    $('#'+optionMode+'-option').prop('checked', true);
27829                }
27830            }
27831        });
27832    } else {
27833        $('.prod-option[data-option_mode="'+optionMode+'"]').addClass('hide');
27834    }
27835}
27836
27837$(function () {
27838    $(document).on('change', '.review-checkbox-check', function () {
27839        if ($(this).is(':checked') === true) {
27840            $(this).closest('.form-wrap').removeClass('disabled');
27841            $('.photo-review-tab').removeClass('hide'); 
27842        } else {
27843            $(this).closest('.form-wrap').addClass('disabled');
27844            $('.photo-review-tab').addClass('hide');
27845            $('.photo-review-top-view').addClass('hide');
27846            $('.photo-review-tab #use-review-img-upload').prop('checked',false);
27847            $('.photo-review-tab #photo-review').prop('checked',false);
27848        }
27849    });
27850
27851    $(document).on('change', '#use-review-img-upload', function () {
27852        if ($(this).is(':checked') === true) {
27853            $('.photo-review-top-view').removeClass('hide');
27854        } else {
27855            $('.photo-review-top-view').addClass('hide');
27856            $('.photo-review-tab #photo-review').prop('checked',false);
27857        }
27858    });
27859
27860    $(document).on('change', '.qna-checkbox-check', function () {
27861        if ($(this).is(':checked') === true) {
27862            $(this).closest('.form-wrap').removeClass('disabled');
27863        } else {
27864            $(this).closest('.form-wrap').addClass('disabled');
27865        }
27866    });
27867
27868    $(document).on('change', '.option-state-box .status-checkbox', function (e) {
27869        if($(this).attr('id') == 'normal-option') {
27870            var li = $('.prod-option[data-option_mode="normal"] .prod-option-list > li').slice(1);
27871            if(product_options.advanced == 'true' && li.length == 0) {
27872                $(this).prop('checked',false);
27873                // alert('고급 설정이 적용되어 있어 입력형 옵션과 추가 옵션은 고급 설정창에서 설정이 가능합니다');
27874                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() {
27875                    $(document).on('keydown', function(e) {
27876                        if(e.keyCode == 27) modal.modal('hide');
27877                    });
27878                });
27879                return false;
27880            }
27881            if ($(this).is(':checked') === true) {
27882                if(li.length == 0) {
27883                    var r = addProductOption('normal');
27884                    if(r == false) {
27885                        $('#normal-option').prop('checked', false);
27886                        return false;
27887                    }
27888                }
27889                $('.prod-option-tab').removeClass('hide');
27890                $('.prod-option[data-option_mode="normal"]').removeClass('hide');
27891                $('.prod-option[data-option_mode="normal"] .plus-price').removeClass('hide');
27892                $('.prod-option[data-option_mode="normal"] .plus-status').removeClass('hide');
27893                switchDownload('on'); //다운로드 파일        
27894            } else {         
27895                switchDownload('off'); //다운로드 파일
27896                // removeOptionModal(li, 'normal');
27897                if(li.length == 1 && li.find('.prod-option-item .prod-option-title').text() == '') {
27898                    li.remove();
27899                }
27900                $('.prod-option[data-option_mode="normal"]').addClass('hide');
27901            }
27902        } else if($(this).attr('id') == 'text-option') {
27903            if($('#download-product').is(':checked') === true) { //다운로드 상품
27904                alert('다운로드 상품은 입력옵션을 지원하지 않습니다.');
27905                $(this).prop('checked', false);
27906                return false;
27907            }
27908            var li = $('.prod-option[data-option_mode="text"] .prod-option-list > li');
27909            if(product_options.advanced == 'true' && li.length == 0) {
27910                $(this).prop('checked',false);
27911                // alert('고급 설정이 적용되어 있어 입력형 옵션과 추가 옵션은 고급 설정창에서 설정이 가능합니다');
27912                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() {
27913                    $(document).on('keydown', function(e) {
27914                        if(e.keyCode == 27) modal.modal('hide');
27915                    });
27916                });
27917                return false;
27918            }
27919            if ($(this).is(':checked') === true) {   
27920                $('.prod-option-tab').removeClass('hide');
27921                $('.prod-option[data-option_mode="text"]').removeClass('hide');
27922
27923                if(li.length == 0) addProductOption('text');
27924                if(li.length >= 7) {
27925                    $('.prod-option[data-option_mode="text"] > .prod-option-add').addClass('disabled');
27926                } else {
27927                    $('.prod-option[data-option_mode="text"] > .prod-option-add').removeClass('disabled');
27928                }
27929            } else {
27930                // removeOptionModal(li, 'text');
27931                if(li.length == 1 && li.find('.prod-option-item .prod-option-title').text() == '') {
27932                    li.remove();
27933                }
27934                $('.prod-option[data-option_mode="text"]').addClass('hide');
27935            }
27936        } else if($(this).attr('id') == 'additional-option') {
27937            if($('#download-product').is(':checked') === true) { //다운로드 상품
27938                alert('다운로드 상품은 추가옵션을 지원하지 않습니다.');
27939                $(this).prop('checked', false);
27940                return false;
27941            }
27942            var li = $('.prod-option[data-option_mode="additional"] .prod-option-list > li');
27943            if(product_options.advanced == 'true' && li.length == 0) {
27944                $(this).prop('checked',false);
27945                // alert('고급 설정이 적용되어 있어 입력형 옵션과 추가 옵션은 고급 설정창에서 설정이 가능합니다.');
27946                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() {
27947                    $(document).on('keydown', function(e) {
27948                        if(e.keyCode == 27) modal.modal('hide');
27949                    });
27950                });
27951                return false;
27952            }
27953
27954            if ($(this).is(':checked') === true) {
27955                $('.prod-option-tab').removeClass('hide');
27956                $('.prod-option[data-option_mode="additional"]').removeClass('hide');
27957                $('.prod-option[data-option_mode="additional"] .plus-price').removeClass('hide');
27958                $('.prod-option[data-option_mode="additional"] .plus-status').removeClass('hide');
27959
27960                if(li.length == 0) addProductOption('additional');
27961            } else {
27962                // removeOptionModal(li, 'additional');
27963                if(li.length == 1 && li.find('.prod-option-item .prod-option-title').text() == '') {
27964                    li.remove();
27965                }
27966
27967                $('.prod-option[data-option_mode="additional"]').addClass('hide');
27968            }
27969        }
27970
27971        if($('.switch-quantity').is(":checked") == true) {
27972            if($('#normal-option').is(':checked') === true) {
27973                // $('#prod-quantity').attr('readonly','true').removeClass('hide').attr('placeholder','옵션에서 재고 관리');
27974                $('.quantity-label').addClass('on');
27975                $('.plus-quantity').removeClass('hide');
27976            } else if($('#normal-option').is(':checked') === false && $('#additional-option').is(':checked') === true) {
27977                $('.quantity-label').removeClass('on');
27978                $('#prod-quantity').removeAttr('readonly').removeClass('hide');
27979                $('.plus-quantity').removeClass('hide');
27980            } else {
27981                $('.quantity-label').removeClass('on');
27982                $('#prod-quantity').removeAttr('readonly').removeClass('hide');
27983                $('.plus-quantity').addClass('hide');
27984            }
27985
27986        //     $parent.find('.prod-option-quantity, .edit-option-quantity').show();
27987        //     $parent.find('.plus-quantity').removeClass('hide');
27988        } else {
27989            $('.quantity-label').removeClass('on');
27990            $('#prod-quantity').addClass('hide');
27991            $('.prod-option-quantity, .prod-plus-quantity, .edit-option-quantity').hide();
27992            $('.plus-quantity').addClass('hide');
27993        }
27994
27995        if($('.prod-option-tab .prod-option.hide').length == 3) { //탭 모두 비활성화일때
27996            $('.prod-option-tab').addClass('hide');
27997            if(product_options.advanced == 'true')
27998                $('.reset-wrap').addClass('hide');
27999            if($('.switch-quantity').is(":checked") == true) {
28000                $('.quantity-label').removeClass('on');
28001            }
28002        } else {
28003            if(product_options.advanced == 'true')
28004                $('.reset-wrap').removeClass('hide');
28005        }
28006    });
28007
28008    $(document).on('click','.btn-fblogin.btn-warning', function(e) {
28009        var facebook_disabled_str = '\
28010        <div class="text-left" style="padding: 20px 15px;"><br>\
28011        ' + $.lang[LANG]['config.modal.fblogin.error.1'] + '\
28012            <ol style="padding-inline-start: 15px; margin-top: 10px; line-height: 2;">\
28013            ' + $.lang[LANG]['config.modal.fblogin.error.2'] + '\
28014            </ol>\
28015        ' + $.lang[LANG]['config.modal.fblogin.error.3'] + '\
28016        </div>';
28017
28018        $(this).showModalFlat('INFORMATION',facebook_disabled_str,true,false,'','ok','','w555');
28019    });
28020
28021    //$(document).off('click', '#etc-start-date.etc_date');
28022    // $(document).on('click', '#etc-start-date-txt', function (e) {
28023    //     $('.cl_etc_date_time').each(function () {
28024    //         $(this).removeClass('active');
28025    //     });
28026
28027    //     if($('#etc-start-date-picker').css('display') == 'block') {
28028    //         $(this).removeClass('active');
28029    //         $('#etc-start-date-picker').hide();
28030    //     } else {
28031    //         $('.etc-date').removeClass('active');
28032    //         $(this).addClass('active');
28033    //         $('#etc-start-date-picker').show();
28034    //     }
28035    //     $('#etc-end-date-picker').hide();
28036    //     $('#etc-except-date-picker').hide();
28037            
28038    //     $('#select-calendar').val('etc-start-date');
28039    //     startPicker.generateDates();
28040    //     var i = 0;
28041    //     var width = 0;
28042    //     $('#etc-end-date-picker .Datepickk .d-table input + label').each(function () {
28043    //         if (i == 0) width = $(this).width();
28044    //         $(this).css('height', width+'px');
28045    //         i++;
28046    //     });
28047    //     var i = 0;
28048    //     var width = 0;
28049    //     $('#etc-start-date-picker .Datepickk .d-table input + label').each(function () {
28050    //         if (i == 0) width = $(this).width();
28051    //         $(this).css('height', width+'px');
28052    //         i++;
28053    //     });
28054    // });
28055
28056    // $(document).on('click', '#etc-end-date-txt', function () {
28057    //     $('.cl_etc_date_time').each(function () {
28058    //         $(this).removeClass('active');
28059    //     });
28060
28061    //     if($('#etc-end-date-picker').css('display') == 'block') {
28062    //         $(this).removeClass('active');
28063    //         $('#etc-end-date-picker').hide();
28064    //     } else {
28065    //         $('.etc-date').removeClass('active');
28066    //         $(this).addClass('active');
28067    //         $('#etc-end-date-picker').show();
28068    //     }
28069
28070    //     $('#etc-start-date-picker').hide();
28071    //     $('#etc-except-date-picker').hide();
28072
28073    //     $('#select-calendar').val('etc-end-date');
28074    //     endPicker.generateDates();
28075    //     var i = 0;
28076    //     var width = 0;
28077    //     $('#etc-end-date-picker .Datepickk .d-table input + label').each(function () {
28078    //         if (i == 0) width = $(this).width();
28079    //         $(this).css('height', width+'px');
28080    //         i++;
28081    //     });
28082    //     var i = 0;
28083    //     var width = 0;
28084    //     $('#etc-start-date-picker .Datepickk .d-table input + label').each(function () {
28085    //         if (i == 0) width = $(this).width();
28086    //         $(this).css('height', width+'px');
28087    //         i++;
28088    //     });
28089    // });
28090
28091    // $(document).on('click', '#etc-except-date', function () {
28092    //     $('.unselect-all').remove();
28093        
28094    //     if($('#etc-except-date-picker').css('display') == 'block') {
28095    //         $(this).removeClass('active');
28096    //         $('#etc-except-date-picker').hide();
28097    //     } else {
28098    //         $('.etc-date').removeClass('active');
28099    //         $(this).addClass('active');
28100    //         $('#etc-except-date-picker').show();
28101    //         $('#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>');
28102    //         displaySelectedDates();
28103    //     }
28104
28105    //     $('#etc-start-date-picker').hide();
28106    //     $('#etc-end-date-picker').hide();
28107
28108    //     setExceptPicker();
28109    //     // exceptPicker.generateDates(true);
28110    //     var i = 0;
28111    //     var width = 0;
28112    //     $('#etc-except-date-picker .Datepickk .d-table input + label').each(function () {
28113    //         if (i == 0) width = $(this).width();
28114    //         $(this).css('height', width+'px');
28115    //         i++;
28116    //     });
28117
28118
28119    // });
28120
28121    // $(document).on('click', '#etc-except-date-picker .unselect-all', function (e) {
28122    //     e.preventDefault();
28123    //     exceptPicker.unselectExceptAll();
28124    //     //exceptPicker.generateDates(true);
28125    //     setExceptPicker();
28126    //     $('#etc-except-date').val('-');
28127    //     $('.etc-except-date-status').text('');
28128    //     $(this).addClass('disabled');
28129    // });
28130
28131    
28132
28133    $(document).on('click', '.email-add-box:not(.disabled)', function(e){
28134
28135        if (!$(e.target).is('.email-box')) {
28136            $('#email-add-input').focus();
28137        }
28138    });
28139
28140    $(document).on('keydown', '.email-add-box:not(.disabled) #email-add-input', function (e) {
28141        var keyCode = e.keyCode || e.which;
28142        if (keyCode == 9 || keyCode == 13) {
28143            e.preventDefault();
28144            enterEmailBox($(this), 'add');
28145        }
28146    });
28147
28148    $(document).on('click', function(e) {
28149        if($('#email-add-input').length > 0 && !$(e.target).is('#email-add-input')) {
28150            e.stopPropagation();
28151            enterEmailBox($('#email-add-input'), 'add');
28152        }
28153    });
28154
28155    $(document).on('click', '.email-add-box:not(.disabled) .email-box-delt', function (e) {
28156        e.stopPropagation();
28157        enterEmailBox($(this), 'delete');
28158    });
28159
28160    $(document).on('click', '.email-add-box:not(.disabled) .email-box', function (e) {
28161
28162        e.stopPropagation();
28163
28164        var textWidth = $(this).find('.email-text').width();
28165        var emailTextInput = $(this).find('.email-text-input');
28166        var otherBox = $('.email-box').not(this); //선택한 박스 외 다른 박스
28167        var emailBox = enterEmailBox(otherBox.find('.email-text-input.active input'), 'modify');
28168        if (emailBox) {
28169            otherBox.find('.email-text').removeClass('hidden');
28170            otherBox.find('.email-text-input').addClass('hidden');
28171            otherBox.find('.email-text-input').removeClass('active');
28172        }
28173        if(emailTextInput.hasClass('hidden')) {
28174            $(this).find('.email-text').addClass('hidden');
28175            emailTextInput.removeClass('hidden');
28176            emailTextInput.addClass('active');
28177            emailTextInput.find('input').css('width', textWidth+'px');
28178            emailTextInput.find('input').focus();
28179        }
28180    });
28181
28182    $(document).on('keydown', '.email-box', function (e) {
28183        var keyCode = e.keyCode || e.which;
28184        if (keyCode == 9 || keyCode == 13) {
28185            var emailBox = enterEmailBox($('.email-text-input').not('.hidden').find('input'), 'modify');
28186
28187            if (emailBox) {
28188                $(this).find('.email-text').removeClass('hidden');
28189                $(this).find('.email-text-input').addClass('hidden');
28190            }
28191        }
28192    });
28193
28194    $(document).on('click', function (e) {
28195        if (!$(e.target).is('.email-box')) {
28196            e.stopPropagation();
28197            var emailBox = enterEmailBox($('.email-text-input.active input'), 'modify');
28198
28199            if (emailBox) {
28200                $(this).find('.email-text').removeClass('hidden');
28201                $(this).find('.email-text-input').addClass('hidden');
28202                $(this).find('.email-text-input').removeClass('active');
28203            }
28204        }
28205    });
28206    // if ($('#email-line-box').length > 0) {
28207    //     var name = $('#email-line-box').attr('name');
28208    //     var className = $('#email-line-box').attr('class');
28209    //     var value = $('#email-line-box').val();
28210
28211    //     var emailList = value.split(',');
28212
28213    //     var html = '\
28214    //         <input type="hidden" id="email-line-box" name="'+name+'" class="'+className+'" value="'+value+'">\
28215    //         <div class="email-add-box">\
28216    //             <input type="text" id="email-add-input">\
28217    //         </div>\
28218    //     ';
28219    //     $('#email-line-box').before(html);
28220
28221    //     var html = '';
28222    //     if (emailList.length >= 1) {
28223    //         if (emailList[0] != '') {
28224    //             for (var i=0;i<emailList.length;i++) {
28225    //                 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>'
28226    //             }
28227
28228    //             $('#email-add-input').before(html);
28229    //             var boxWidth = 0;
28230    //             $('.email-add-box .email-box').each(function () {
28231    //                 boxWidth += $(this).innerWidth() + 10;
28232    //             });
28233    //             var textWidth = $('#email-add-input').parent().innerWidth() - 20,
28234    //                 uni = 'px';
28235
28236    //             var totalWidth = textWidth - boxWidth;
28237
28238    //             if (totalWidth <= 40) {
28239    //                 totalWidth = 100;
28240    //                 uni = '%'
28241    //             }
28242
28243    //             $('#email-add-input').css('width', totalWidth+uni);
28244    //         }
28245    //     }
28246    //     $('#email-line-box').remove();
28247    // } L.20211008.
28248
28249    $(document).on('click', '.fitem-category', function (e) {
28250        if(typeof handleIconStorageCategoryClick == 'function') {
28251            handleIconStorageCategoryClick($(this));
28252            return;
28253        }
28254
28255        var quick_category = $(this).attr('data-category');
28256        $(this).addClass('active').siblings('.fitem-category').removeClass('active');
28257        getIconImage(quick_category);
28258    });
28259});
28260
28261function enterEmailBox (el, mode) {
28262    var regExp = /^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,3}$/i;
28263    if(mode == 'add' || mode == 'modify') {
28264        var val = (typeof el.val() !== 'undefined')? el.val().trim() : '';
28265        if (val == '') return true;
28266        if(!regExp.test(val)) {
28267            // alert('이메일 형식이 올바르지 않습니다.');
28268            var modal = $(this).showModalFlat('','이메일 형식이 올바르지 않습니다.',true,false,function() {
28269                    modal.modal('hide');
28270                },'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
28271                $(document).on('keydown', function(e) {
28272                    if(e.keyCode == 27) modal.modal('hide');
28273                });
28274            });
28275            el.val('');
28276            el.focus();
28277            return false;
28278        }
28279        var flag = true;
28280        $('.email-text').not('.hidden').each(function(idx, v) {
28281            if($(v).text() == val) {
28282                // alert('이미 등록된 이메일입니다.');
28283                var modal = $(this).showModalFlat('','이미 등록된 이메일입니다.',true,false,function() {
28284                    modal.modal('hide');
28285                },'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
28286                    $(document).on('keydown', function(e) {
28287                        if(e.keyCode == 27) modal.modal('hide');
28288                    });
28289                });
28290                el.val('');
28291                el.focus();
28292                flag = false;
28293                return false;
28294            }
28295        });
28296
28297        if(flag === false) {
28298            return false;
28299        }
28300    }
28301
28302    if(mode == 'add') {
28303        var html = '<div class="email-box">\
28304        <div class="email-text">'+val+'</div>\
28305        <div class="email-text-input hidden"><input type="text" value="'+val+'"></div>\
28306        <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>\
28307        </div>';
28308               
28309        if($('.email-box').length < 5) { //이메일 최대 5개까지
28310            el.before(html);
28311        }
28312        el.val('');
28313    } else if (mode == 'delete') {
28314        if($('.email-box').length <= 1) {
28315            alert('관리자 수신메일은 최소 1개 이상 등록되어 있어야 합니다.');
28316            return false;
28317        }
28318        el.parent().remove();
28319    } else if (mode == 'modify') {
28320        var emailBox = el.closest('.email-box').find('.email-text');
28321        emailBox.text(val);
28322    } else {
28323        return false;
28324    }
28325    
28326    var emailArr = new Array();
28327    $('.email-add-box .email-box .email-text').each(function () {
28328        emailArr.push($(this).text());
28329    });
28330    console.log(emailArr);
28331    $('#email-line-box').val(emailArr.join(','))
28332
28333    if($('.email-box').length >= 5) {
28334        $('#email-add-input').remove();
28335    } else {
28336        if($('#email-add-input').length == 0) {
28337            $('.email-add-box').append('<input type="text" id="email-add-input">');
28338        }
28339        if (mode != 'modify') {
28340            $('#email-add-input').focus();
28341        }
28342    }
28343
28344    return true;
28345}
28346
28347function enterGeneralBox (el, mode){
28348    var regExp = /^[0-9+]+$/;    
28349    if(mode == 'add' || mode == 'modify') {
28350
28351        var val = (typeof el.val() !== 'undefined')? el.val().trim() : '';//value 체크        
28352        val = val.replace(/ /g,""); 
28353        if (val == '') return true; //입력내용 비어있으면 종료
28354
28355    // console.log(val.replace('+',''));
28356    // console.log(val.replace('+','').length);
28357        if ( val.replace('+','').length < 10 || val.replace('+','').length > 15) {           
28358
28359                    siteNotice('kakao_number_length');
28360                    el.val('');
28361                    el.focus();
28362                    return false;            
28363        }
28364        if(!regExp.test(val)) {
28365                siteNotice('kakao_onlynumber');
28366                el.val('');
28367                el.focus();
28368                return false;
28369        }
28370        var flag = true;
28371        
28372        $('.generalnum-text').not('.hidden').each(function(idx, v) {
28373            
28374            if($(v).text().replace('+','') == val.replace('+','')) {
28375                // alert('이미 등록 된 이메일입니다.');
28376                siteNotice('kakao_dupnumber');
28377                el.val('');
28378                el.focus();
28379                flag = false;
28380                return false;
28381            }
28382        });
28383
28384        if(flag === false) {
28385            return false;
28386        }
28387    }
28388    if(mode == 'add') {
28389
28390        //0206 18:00 working..
28391        if(val.substring(0, 1) == '0'){
28392            var firststring_delete = val.substring(1);
28393            var sliceValue ='';        
28394            var text_array = new Array();
28395                firststring_delete = '+82'+firststring_delete;
28396                
28397                $('.generalnum-text').each(function(idx, v) {           
28398                    sliceValue = text_array.push($(v).text());
28399                });
28400        } else if(val.slice(0,2) =='82' || val.slice(0,3) =='+82'){
28401            if(val.slice(0,1) == '+') val = val.substring(1);
28402
28403            var firststring_delete = val.substring(2);
28404            var sliceValue =''; 
28405                firststring_delete = '0'+firststring_delete;
28406                   
28407            var text_array = new Array();
28408                $('.generalnum-text').each(function(idx, v) {           
28409                    sliceValue = text_array.push($(v).text());
28410                });            
28411        } else {
28412            var firststring_delete = val;
28413            var text_array = new Array();
28414
28415        } 
28416            if(text_array.includes(firststring_delete)){
28417                var modal = $(this).showModalFlat('',$.lang[LANG]['shopping.dashboard.kakaoNotice.dupnumber'],true,false,function() {
28418                    modal.modal('hide');
28419                },'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
28420                    $(document).on('keydown', function(e) {
28421                        if(e.keyCode == 27) modal.modal('hide');
28422                    });
28423                });                
28424                el.val('');
28425                el.focus();                
28426                return false ;
28427            }
28428       
28429        //0206 18:00 working..
28430
28431        
28432        let val_chk = val.substring(0, 1);
28433        if(val_chk !== '0' && val_chk !=='+'){
28434            val = '+'+val;
28435        }           
28436        var html = '<div class="generalnum-box">\
28437        <div class="generalnum-text">'+val+'</div>\
28438        <div class="generalnum-text-input hidden"><input type="text" value="'+val+'"></div>\
28439        <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>\
28440        </div>';
28441               
28442        
28443       el.before(html);
28444           
28445        el.val('');
28446    } else if (mode == 'delete') {
28447
28448        // if($('.generalnum-box').length <= 1) {
28449        //   $(this).siblings(input);
28450        // }         
28451        el.parent().remove();
28452    } 
28453    else if (mode == 'modify') {
28454        // if(val.substring(0, 1) == '0'){
28455        //     var firststring_delete = val.substring(1);
28456        //     var sliceValue ='';        
28457        //     var text_array = new Array();
28458        //         firststring_delete = '+82'+firststring_delete;
28459        //         $('.generalnum-text').each(function(idx, v) {           
28460        //             sliceValue = text_array.push($(v).text());
28461        //         });
28462        // }
28463
28464        if(val.substring(0, 1) == '0'){
28465            var firststring_delete = val.substring(1);
28466            var sliceValue ='';        
28467            var text_array = new Array();
28468                firststring_delete = '+82'+firststring_delete;
28469                
28470                $('.generalnum-text').each(function(idx, v) {           
28471                    sliceValue = text_array.push($(v).text());
28472                });
28473        } else if(val.slice(0,2) =='82' || val.slice(0,3) =='+82'){     
28474          if(val.slice(0,1) == '+') val = val.substring(1);       
28475            var firststring_delete = val.substring(2);
28476            var sliceValue =''; 
28477                firststring_delete = '0'+firststring_delete;
28478                   
28479            var text_array = new Array();
28480                $('.generalnum-text').each(function(idx, v) {           
28481                    sliceValue = text_array.push($(v).text());
28482                });            
28483        } else {
28484            var firststring_delete = val;
28485            var text_array = new Array();
28486
28487        }         
28488            if(text_array.includes(firststring_delete)){
28489                var modal = $(this).showModalFlat('',$.lang[LANG]['shopping.dashboard.kakaoNotice.dupnumber'],true,false,function() {
28490                    modal.modal('hide');
28491                },'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
28492                    $(document).on('keydown', function(e) {
28493                        if(e.keyCode == 27) modal.modal('hide');
28494                    });
28495                });                
28496                el.val('');
28497                el.focus();                
28498                return false ;
28499            }
28500       
28501
28502        
28503        let val_chk = val.substring(0, 1);
28504        if(val_chk !== '0' && val_chk !=='+'){
28505            val = '+'+val;
28506        }      
28507        var emailBox = el.closest('.generalnum-box').find('.generalnum-text');
28508        emailBox.text(val);
28509       
28510    } else {
28511        return false;
28512    }
28513
28514
28515 var emailArr = new Array();
28516    $('.generalnum-add-box .generalnum-box .generalnum-text').each(function () {
28517        emailArr.push($(this).text());
28518    });
28519    
28520    $('#generalnum-line-box').val(emailArr.join(','))
28521    $('#generalnum-add-input').remove();
28522
28523    (LANG =='ko') ? LangPlaceholderNumber = '번호를 입력해주세요.' : LangPlaceholderNumber = 'Please enter the Number.';
28524   
28525        if($('#generalnum-add-input').length == 0) {
28526            $('.generalnum-add-box').append('<input type="text" id="generalnum-add-input">');
28527            if ($('.generalnum-box').length == 0) {
28528                $('#generalnum-add-input').attr('placeholder',LangPlaceholderNumber)
28529            }
28530        }
28531        if (mode != 'modify') {
28532            $('#generalnum-add-input').focus();
28533        }
28534    
28535
28536    return true;    
28537}
28538
28539    $(document).on('click', function(e) {
28540        if($('#generalnum-add-input').length > 0 && !$(e.target).is('#generalnum-add-input')) {
28541            e.stopPropagation();
28542            enterGeneralBox($('#generalnum-add-input'), 'add');
28543           
28544        }
28545    });
28546
28547    $(document).on('keydown', '#generalnum-add-input', function (e) {
28548        var keyCode = e.keyCode || e.which;
28549        if (keyCode == 9 || keyCode == 13) {
28550            e.preventDefault();
28551            enterGeneralBox($(this), 'add');
28552        }
28553    });
28554
28555    $(document).on('click', '.generalnum-box', function (e) {
28556        e.stopPropagation();
28557        var textWidth = $(this).find('.generalnum-text').width();
28558        var emailTextInput = $(this).find('.generalnum-text-input');
28559        var otherBox = $('.generalnum-box').not(this); //선택한 박스 외 다른 박스
28560        var emailBox = enterGeneralBox(otherBox.find('.generalnum-text-input.active input'), 'modify');
28561        if (emailBox) {
28562            otherBox.find('.generalnum-text').removeClass('hidden');
28563            otherBox.find('.generalnum-text-input').addClass('hidden');
28564            otherBox.find('.generalnum-text-input').removeClass('active');
28565        }
28566        if(emailTextInput.hasClass('hidden')) {
28567            $(this).find('.generalnum-text').addClass('hidden');
28568            emailTextInput.removeClass('hidden');
28569            emailTextInput.addClass('active');
28570            emailTextInput.find('input').css('width', textWidth+'px');
28571            emailTextInput.find('input').focus();
28572        }
28573    });
28574
28575    $(document).on('click', '.generalnum-add-box', function(e){
28576        if (!$(e.target).is('.generalnum-box')) {
28577
28578            $('#generalnum-add-input').focus();
28579        }
28580    });
28581
28582   $(document).on('keydown', '.generalnum-box', function (e) {
28583        var keyCode = e.keyCode || e.which;
28584        if (keyCode == 9 || keyCode == 13) {
28585            $(this).find('.generalnum-text-input').removeClass('active');
28586            var emailBox = enterGeneralBox($('.generalnum-text-input').not('.hidden').find('input').not(this), 'modify');
28587
28588            if (emailBox) {
28589                $(this).find('.generalnum-text-input').addClass('hidden');
28590                $(this).find('.generalnum-text').removeClass('hidden');
28591
28592            }
28593        }
28594    });
28595
28596    $(document).on('click', function (e) {
28597        if (!$(e.target).is('.generalnum-box')) {
28598            e.stopPropagation();
28599            var emailBox = enterGeneralBox($('.generalnum-text-input.active input'), 'modify');
28600
28601
28602            if (emailBox) {
28603                $(this).find('.generalnum-text').removeClass('hidden');
28604                $(this).find('.generalnum-text-input').addClass('hidden');
28605                $(this).find('.generalnum-text-input').removeClass('active');
28606            }
28607        }
28608    });    
28609
28610    $(document).on('click', '.generalnum-box-delt', function (e) {
28611        e.stopPropagation();
28612        enterGeneralBox($(this), 'delete');
28613    });
28614
28615
28616function emailLineFunc () {
28617    var emailBox = enterEmailBox($('#email-add-input'), 'add');
28618    
28619    if ($('.email-box.none').length > 0) {
28620        alert('옳바르지 않은 이메일 주소가 포함되어있습니다.');
28621        return false;
28622    }
28623    
28624    if (emailBox === false) {
28625        $('#email-add-input').focus();
28626        return false;
28627    }
28628
28629    return true;
28630}
28631
28632function division (option, n) {
28633    var arr = option;
28634    var len = arr.length;
28635    var cnt = Math.floor(len / n) + (Math.floor(len % n) > 0 ? 1 : 0);
28636    var tmp = [];
28637
28638    for (var i=0;i<cnt;i++) {
28639        tmp.push(arr.splice(0, n));
28640    }
28641
28642    return tmp;
28643}
28644
28645function truncateReviewTitle (reviewArr) { //상품후기 제목 자르기
28646    $('.s-table-review .review-content>div').each(function(idx, item){
28647        var reviewContent = reviewArr[idx];
28648        
28649        if(reviewContent !== undefined) {
28650            $(this).html(reviewContent);
28651
28652            for(var i = reviewContent.length; i > 0; i--){
28653                if($(this).height() > 60) {
28654                    $(this).html(reviewContent.substr(0, i));
28655                    $(this).append('...');
28656                }
28657                else {
28658                    break;
28659                }
28660            }
28661        }
28662    });
28663}
28664
28665function nl2br (str, is_xhtml) {
28666    if (typeof str === 'undefined' || str === null) {
28667        return '';
28668    }
28669    var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';
28670    return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
28671}
28672
28673function extra_charge_info($obj, status, free_flag, change_flag) {
28674    $(".order-cancel-content.extra-info").remove();
28675    var s = '\
28676    <div class="order-cancel-content extra-info">\
28677        <div class="cancel-info-box">\
28678            <p class="error">\
28679            ' + (free_flag ? '- 결제 당시 무료배송 조건을 충족하지 못해 배송료가 발생 할 수 있습니다.<br>' : '' ) + '\
28680            ' + (change_flag ? '- 주문 상품 ' + (status == 'C' ? '취소' : '반품') + ' 시 배송비 조건에 따라 배송비가 달라질 수 있습니다.<br>' : '') + '\
28681            - 자세한 사항은 판매자의 안내를 따라주세요.\
28682            </p>\
28683        </div>\
28684    </div>\
28685    ';
28686    if(free_flag || change_flag) {
28687        if($obj.find(".modal-comment.point-used-desc").length) {
28688            $obj.find(".modal-comment.point-used-desc").before(s);
28689        } else {
28690            $obj.append(s);
28691        }
28692    }
28693}
28694
28695function setCLEscrowFooter(sid,plantype,obj) {
28696    if(typeof sid == 'undefined') return false;
28697
28698    if( typeof plantype == 'undefined' || plantype != 'SM' || 
28699        typeof obj == 'undefined' || 
28700        typeof obj.onoff == 'undefined' || !obj.onoff || obj.onoff === false ||
28701        typeof obj.key == 'undefined' || !obj.key || obj.key == ''
28702    ) {
28703        $('.el-footer').find('.escrow-image-wrap-box').remove();
28704        return false;
28705    }
28706
28707    var escrow_img = (typeof obj.type != 'undefined' && obj.type) ? obj.type : 1,
28708        escrow_key = obj.key,
28709        checkCLEscrowFooter = ($('.el-footer').find('.escrow-image-wrap-box').length > 0) ? true : false,
28710        checkCLFooter = ($('.el-footer').find('.cl-footer-site-element').length > 0) ? true : false;
28711    
28712    var escrow_link = '';
28713    if(obj.pg_company == 'KCP') {
28714        escrow_img = '<img src="//storage.googleapis.com/i.addblock.net/shopping_mall/escrow_site/escrow_site0' + escrow_img + '.png" />';
28715        escrow_link = '//admin.kcp.co.kr/Modules/escrow/kcp_pop.jsp?site_cd=' + escrow_key;
28716    } else if(obj.pg_company == 'NICEPAY') {
28717        escrow_img = '<img src="//storage.googleapis.com/i.addblock.net/shopping_mall/escrow_setting/nicepay_escrow_setting0' + escrow_img + '.png" />';
28718        escrow_link = 'https://npg.nicepay.co.kr/issue/issueEscrow.do?Mid=' + escrow_key + '&CoNo=' + obj.b_number.replace(/-/g,'');
28719    }
28720        
28721    var clef_str = '\
28722            <div class="escrow-image-wrap">\
28723                <a href="' + escrow_link + '" target="_blank">\
28724                    ' + escrow_img + '\
28725                </a>\
28726            </div>\
28727    ';
28728
28729    if(checkCLEscrowFooter) {
28730        $('.el-footer').find('.escrow-image-wrap-box').html('<br>'+clef_str);
28731    } else if(checkCLFooter) {
28732        $('.el-footer').find('.escrow-image-wrap').remove();
28733        $('.el-footer').find('.cl-footer-site-element').last().append('<br><div class="escrow-image-wrap-box">'+clef_str+'</div>');
28734    } else {
28735        $('.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>');
28736    }
28737}
28738
28739
28740function setConfigLogs(action,v,obj,page) {
28741    $.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) {
28742        if(typeof data.error != 'undefined' && data.error) {
28743            console.log(data.error);
28744            return false;
28745        }
28746    },'json');
28747}
28748
28749function setSiteLogs(action,v,obj,page,ref) {
28750    $.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) {
28751        if(typeof data.error != 'undefined' && data.error) {
28752            console.log(data.error);
28753            return false;
28754        }
28755    },'json');
28756}
28757
28758function getProductInfoList() {
28759    var input_empty = false,
28760        cate_null = false,
28761        idx = 0,
28762        prod_info_cate = $('.prod-select-title').text().trim(),
28763        $prod_info_lists = $('.prod-lists > div'),
28764        prod_info = {
28765            'title' : prod_info_cate,
28766            'content' : []
28767        };
28768        prod_null = new Array();
28769
28770    if(prod_info_cate=='선택하세요') {
28771        cate_null = true;
28772    }
28773
28774    $.each($prod_info_lists, function(i,v) {
28775        if($(this).hasClass('prod-info-list-save')) return true;
28776
28777        var info_list_title = $(this).find('label').text(),
28778            info_list_content = ($(this).find('.prod-input-value').length > 0) ? $(this).find('.prod-input-value').html().trim() : '';
28779        if(info_list_content.length > 0) info_list_content = info_list_content.replace(/&nbsp;/gi, '');
28780
28781        if(info_list_content.length==0) { 
28782            idx = i;
28783            input_empty = true;
28784            prod_null.push(idx);
28785        }
28786        var s = { 
28787            'title' : info_list_title,
28788            'content' : info_list_content
28789        }
28790        prod_info.content.push(s);
28791    });
28792    prod_info.input_empty = input_empty;
28793    prod_info.input_idx = idx;
28794    prod_info.cate_null = cate_null;
28795    return prod_info;
28796}
28797
28798function setOptionlist($data, func) {
28799    var check_quantity = $('.prod-detail-wrap .switch-quantity').prop('checked'),
28800        normal_options_count = 0;
28801
28802    $.each($data, function(idx,o) { //상품옵션 로드
28803        switch(o.option_status) {
28804            case "S" : str = '판매'; break;
28805            case "O" : str = '품절'; break;
28806            case "H" : str = '숨김'; break;
28807            default : str = '판매'; o.option_status = 'S'; break;
28808        }
28809
28810        if(typeof o.option_quantity == 'undefined' || o.option_quantity == null) o.option_quantity = 0;
28811        if(typeof o.option_price == 'undefined' || o.option_price == null) o.option_price = 0;
28812
28813        var s = "";
28814        if(typeof o.option_type !='undefined' && o.option_type.indexOf('T') > -1) {
28815            s = '\
28816            <li>\
28817                <div class="prod-option-item">\
28818                    <span class="prod-option-title" data-seq="' + o.seq + '">' + o.option_name + '</span>\
28819                    <span class="prod-option-require" data-val="' + o.option_type + '">';
28820                s += '</span>\
28821                </div>\
28822                <div class="prod-option-edit hide">\
28823                    <div class="form-wrap">\
28824                        <div class="form-group edit-option-title">\
28825                            <input type="text" maxlength="20" placeholder="안내문구 입력 (예:두께를 mm단위로 입력해주세요.)"/>\
28826                        </div>\
28827                        <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>\
28828                    </div>\
28829                </div>';
28830        } else {
28831            var option_price = Number(o.option_price),
28832                only_price = Math.abs(option_price),
28833                str_price = only_price.toString(),
28834                str_quantity = (o.option_quantity).toString(),
28835                minus = (option_price < 0)? 'minus':'',
28836                option_name = o.option_name;
28837
28838                if(o.option_mix3) {
28839                    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>';
28840                } else {
28841                    if(o.option_mix2) {
28842                        option_name = '<label class="owidth ow1">' + o.option_mix2 + '</label><label class="owidth ow2">' + option_name + '</label>';
28843                    } else if(o.option_group) {
28844                        option_name = '<label class="owidth ow1">' + o.option_group + '</label><label class="owidth ow2">' + option_name + '</label>';
28845                    }
28846                }
28847            s = '\
28848            <li>\
28849                <div class="prod-option-item">\
28850                    <span class="prod-option-move cl-sort-handle">' + clSVG('move_handle', 20, 20) + '</span>\
28851                    <span class="prod-option-title" data-seq="' + o.seq + '">' + option_name + '</span>\
28852                    <span class="prod-option-price '+minus+'" data-option-price="'+o.option_price+'">' + addCommas(str_price) + '</span>\
28853                    <span class="prod-option-quantity" ' + ((check_quantity) ? '' : 'style="display:none"') + '>' + addCommas(str_quantity) + '</span>\
28854                    <span class="prod-option-status" data-val="' + o.option_status + '">' + str + '</span>\
28855                    <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>\
28856                </div>\
28857                <div class="prod-option-edit hide">\
28858                    <div class="form-wrap">\
28859                        <span class="prod-option-move cl-sort-handle">' + clSVG('move_handle', 20, 20) + '</span>\
28860                        <div class="form-group edit-option-title">\
28861                            <input type="text" maxlength="60" placeholder="옵션값"/>\
28862                        </div>\
28863                        <div class="form-group edit-option-price">\
28864                            <input type="text" class="option-price-number sign" placeholder="0" numberOnly/>\
28865                        </div>\
28866                        <div class="form-group edit-option-quantity" ' + ((check_quantity) ? '' : 'style="display:none"') + '>\
28867                            <input type="text" class="option-price-quantity" maxlength="5" placeholder="0" numberonly/>\
28868                        </div>\
28869                        <div class="form-group edit-option-select">\
28870                            <div class="option-price-status-str hand" data-val="' + o.option_status + '">' + str + '</div>\
28871                            <ul class="option-price-status-select">\
28872                                <li data-val="S">판매</li>\
28873                                <li data-val="O">품절</li>\
28874                                <li data-val="H">숨김</li>\
28875                            </ul>\
28876                        </div>\
28877                        <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>\
28878                    </div>\
28879                </div>';
28880                // console.log('option_type:'+o.option_type);
28881            if (o.product_state && o.option_type!='A' && o.option_type!='T') {
28882                var p_s_data = JSON.parse(o.product_state);
28883
28884                if (p_s_data.file_name) {
28885                    if (fileUpdateCnt == 0) fileUpdateCnt++;
28886                    if (loadFile == 0) loadFile++;
28887                    s += '<div class="form-group product-status">\
28888                            <div class="product-state-box">\
28889                                <div class="product-upload">\
28890                                    <div class="title">파일 업로드</div>\
28891                                    <div class="download-contents">\
28892                                        <span class="cl_icon_upload02" data-cnt="'+fileUpdateCnt+'">업로드</span>\
28893                                        <div class="file-box-list" id="file-box-'+fileUpdateCnt+'">';
28894
28895                                            var serverName = p_s_data.file_url.split('/');
28896                                            s += '<div class="file-name file-name-'+loadFile+'">\
28897                                                    <span class="real-file-name">'+p_s_data.file_name+'</span>\
28898                                                    <span class="file-name-detail" title="'+p_s_data.file_name+'">'+p_s_data.file_str_name+'</span>\
28899                                                    <span class="file-size">'+p_s_data.file_size+'</span>\
28900                                                    <span class="cl-icon cl_icon_close" data-cnt="'+loadFile+'" data-pn="'+o.product_number+'" data-file="'+serverName[8]+'" data-seq="'+o.seq+'"></span>\
28901                                                    <span class="file-url">'+p_s_data.file_url+'</span>\
28902                                                </div>';
28903                                            loadFile++;
28904
28905                    s += '              </div>\
28906                                    </div>\
28907                                </div>\
28908                            </div>\
28909                        </div>';
28910                }
28911            }
28912            fileUpdateCnt++;
28913        }
28914        s += "</li>";
28915
28916        optionLength = Object.keys($data).length;
28917        if($data.length == 1 && o.option_name=='noneOption') {
28918            $('.prod-option[data-option_mode="normal"] .prod-option-list').append(s);
28919        } else {      
28920            if(o.option_type !== undefined && o.option_type.indexOf('T') > -1) {
28921                if($data.length > 0) {
28922                    $('.prod-option[data-option_mode="text"] .prod-option-list').append(s);
28923                    $('.option-state-box .newcheckbox').eq(1).find('#text-option').prop('checked',true);
28924                    $('.prod-option-tab').removeClass('hide');
28925                    $('.prod-option[data-option_mode="text"]').removeClass('hide');
28926                }
28927            } else if(o.option_type == 'A') {
28928                if($data.length > 0) {
28929                    $('.prod-option[data-option_mode="additional"] .prod-option-list').append(s);
28930                    $('.option-state-box .newcheckbox').eq(2).find('#additional-option').prop('checked',true);
28931                    $('.prod-option-tab').removeClass('hide');
28932                    $('.prod-option[data-option_mode="additional"]').removeClass('hide');
28933                    $('.prod-option[data-option_mode="additional"] .plus-price').removeClass('hide');
28934                    $('.prod-option[data-option_mode="additional"] .plus-status').removeClass('hide');
28935
28936                }
28937            } else {
28938                $('.prod-option[data-option_mode="normal"] .prod-option-list').append(s);
28939                normal_options_count++;
28940                if(normal_options_count > 1) {
28941                    $('.option-state-box .newcheckbox').eq(0).find('#normal-option').prop('checked',true);
28942                    $('.prod-option-tab').removeClass('hide');
28943                    $('.prod-option[data-option_mode="normal"]').removeClass('hide');
28944                    $('.prod-option[data-option_mode="normal"] .plus-price').removeClass('hide');
28945                    $('.prod-option[data-option_mode="normal"] .plus-status').removeClass('hide');
28946                }
28947            }
28948        }
28949
28950        if($('.prod-option[data-option_mode="normal"] .prod-option-list > li').length == 1) {
28951            $('.prod-option[data-option_mode="normal"]').addClass('hide');
28952            $('.option-state-box .newcheckbox').eq(0).find('#normal-option').prop('checked',fal
28952se);
28953        }
28954        if($('.prod-option[data-option_mode="text"] .prod-option-list > li').length == 0) {
28955            $('.prod-option[data-option_mode="text"]').addClass('hide');
28956            $('.option-state-box .newcheckbox').eq(1).find('#text-option').prop('checked',false);
28957        }
28958        if($('.prod-option[data-option_mode="additional"] .prod-option-list > li').length == 0) {
28959            $('.prod-option[data-option_mode="additional"]').addClass('hide');
28960            $('.option-state-box .newcheckbox').eq(2).find('#additional-option').prop('checked',false);
28961        }
28962        
28963        $('#product-state').find('input[type="file"]').attr('data-cnt', loadFile).click();
28964    }); 
28965    
28966    if(typeof func == 'function') {
28967        func();
28968    }
28969}
28970
28971var setAdvancedMode = function(r) {
28972    if(r == "true") { // 고급모드
28973        $('.option-type-title.tp2, .option-type-title.tp3').removeClass('hide');
28974        $('.option-type-title3.tp2, .option-type-title3.tp3').removeClass('hide');
28975        $('.options-config').addClass('active');
28976        $('.prod-option-list').sortable('disable');
28977        $('.edit-option-title input').prop('disabled', true);
28978        $('.prod-option-move').addClass('invisible');
28979        $('.edit-option-delete').addClass('invisible');
28980        $('.prod-option-add').addClass('hide');
28981        $('.reset-wrap').removeClass('hide');
28982        $('.option-type-title.tp1').removeClass('editable');
28983        $('.prod-option[data-option_mode="text"] > .text-option-info').removeClass('editable');
28984        $('.prod-option[data-option_mode="text"] > .option-head').removeClass('editable');
28985        $('.option-type-title3.tp1').removeClass('editable');
28986    } else {
28987        $('.option-type-title.tp2, .option-type-title.tp3').addClass('hide');
28988        $('.option-type-title3.tp2, .option-type-title3.tp3').addClass('hide');
28989        $('.options-config').removeClass('active');
28990        $('.prod-option-list').sortable('enable');
28991        $('.edit-option-title input').prop('disabled', false);
28992        $('.prod-option-move').removeClass('invisible');
28993        $('.edit-option-delete').removeClass('invisible');
28994        $('.prod-option-add').removeClass('hide');
28995        $('.reset-wrap').addClass('hide');
28996        $('.option-type-title.tp1').addClass('editable');
28997        $('.prod-option[data-option_mode="text"] > .text-option-info').addClass('editable');
28998        $('.prod-option[data-option_mode="text"] > .option-head').addClass('editable');
28999        $('.option-type-title3.tp1').addClass('editable');
29000    }
29001    if($('.prod-option-tab .prod-option.hide').length == 3) { //탭 모두 비활성화일때
29002        $('.reset-wrap').addClass('hide');
29003    }
29004
29005    switch(product_options.type) {
29006        case "1": 
29007            $('.option-head-str').text('단일형');
29008            $('.option-type-title.tp1').text('옵션명');
29009            $('.option-type-title.tp2').text('옵션값');
29010            $('.option-type-title.tp3').text('');
29011            break;
29012        case "2": 
29013            $('.option-head-str').text('2개 조합형');
29014            if(product_options['config1'][0] !== undefined)
29015                $('.option-type-title.tp1').text(product_options['config1'][0]['title']).removeClass('editable');
29016            if(product_options['config1'][0] !== undefined)
29017                $('.option-type-title.tp2').text(product_options['config1'][0]['value']);
29018            $('.option-type-title.tp3').text('');
29019            break;
29020        case "3": 
29021            $('.option-head-str').text('3개 조합형');
29022            if(product_options['config1'][0] !== undefined)
29023                $('.option-type-title.tp1').text(product_options['config1'][0]['title']).removeClass('editable');
29024            if(product_options['config1'][0] !== undefined)
29025                $('.option-type-title.tp2').text(product_options['config1'][0]['value']);
29026            if(product_options['config1'][0] !== undefined)
29027                $('.option-type-title.tp3').text(product_options['config1'][0]['value2']);
29028            break;
29029        default:
29030            $('.option-head-str').text('기본형');
29031            $('.option-type-title.tp1').text('옵션명');
29032            $('.option-type-title.tp2').text('옵션값');
29033            $('.option-type-title.tp3').text('');
29034            break;            
29035    }
29036}
29037var switchQuantity = function() {
29038    if($('.switch-quantity').is(':checked')) {
29039        $('.switch-quantity').parents('.form-wrap').removeClass('disabled');
29040        $('.prod-option-quantity, .prod-plus-quantity, .edit-option-quantity').show();
29041
29042        if($('#normal-option').is(':checked') === true) {
29043            // $('#prod-quantity').attr('readonly','true').removeClass('hide').attr('placeholder','옵션에서 재고 관리');
29044            $('.quantity-label').addClass('on');
29045            $('.plus-quantity').removeClass('hide');
29046        } else if($('#normal-option').is(':checked') === false && $('#additional-option').is(':checked') === true) {
29047            $('.quantity-label').removeClass('on');
29048            $('#prod-quantity').removeAttr('readonly').removeClass('hide');
29049            $('.plus-quantity').removeClass('hide');
29050        } else {
29051            $('.quantity-label').removeClass('on');
29052            $('#prod-quantity').removeAttr('readonly').removeClass('hide');
29053            $('.plus-quantity').addClass('hide');
29054        }
29055    } else {
29056        $('.quantity-label').removeClass('on');
29057        $('.switch-quantity').parents('.form-wrap').addClass('disabled');
29058        $('#prod-quantity').addClass('hide');
29059        $('.prod-option-quantity, .prod-plus-quantity, .edit-option-quantity').hide();
29060        $('.plus-quantity').addClass('hide');
29061    }
29062}        
29063
29064function getMapURL(map_url, return_type) {
29065    /*
29066        https://www.google.co.kr/maps/@37.4817147,127.0069527,14z
29067        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
29068        <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>
29069    
29070
29071        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
29072        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
29073    */
29074    
29075
29076    var checkGoogle = (map_url.match(/^(https|http)\:\/\/www\.google(\.co\.kr|\.com)\/maps\//g) !== null) ? true : false;
29077    if(checkGoogle) {
29078        var checkEmbed = (map_url.match(/^(https|http)\:\/\/www\.google(\.co\.kr|\.com)\/maps\/embed\?/g) !== null) ? true : false,
29079            checkPlace = (map_url.match(/^(https|http)\:\/\/www\.google(\.co\.kr|\.com)\/maps\/(place|search)/g) !== null) ? true : false;
29080        if(checkEmbed) {
29081            var map_src = map_url;
29082        } else {
29083            var map_arr = map_url.replace(/^(https|http)\:\/\/www\.google(\.co\.kr|\.com)\/maps\//g,'').split('/'),
29084                map_tmp = (checkPlace) ? map_arr[2].split(',') : map_arr[0].split(','),
29085                map_unit = (typeof map_tmp[2] != 'undefined' && map_tmp[2]) ? map_tmp[2].replace(/[0-9.]/g,'') : '',
29086                map_place = (checkPlace) ? map_arr[1] : '',
29087                map_xy = map_tmp[0].replace(/^@/,'') + ' ' + map_tmp[1],
29088                map_zoom = (map_unit == 'z') ? parseInt(map_tmp[2].replace('z','')) : 17,
29089                // 위성지도 map_miter = (map_unit == 'm') ? map_tmp[2].replace('m','') : '',
29090                map_query = (checkPlace) ? map_place : map_xy;
29091
29092
29093            if(map_unit == 'z') map_query += '&z='+map_zoom;
29094            // 위성지도  if(map_unit == 'm') map_query += '&t=k';
29095
29096            // 언어
29097            var check_lang = map_arr[map_arr.length-1];
29098            if(typeof check_lang != 'undefined' && check_lang) {
29099                var lang_arr = check_lang.split('?'),
29100                    lang_str = '';
29101                $.each(lang_arr, function(i,tmp) {
29102                    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) {
29103                        map_query += '&hl=' + tmp.replace(/^hl=/g,'');
29104                    }
29105                });
29106            }
29107            
29108            var map_src = '//www.google.com/maps?q=' + map_query + '&ll=' + map_xy.replace(/ /,',') + '&output=embed';
29109        }
29110
29111        var map_iframe = '\
29112            <iframe class="google-map" src="' + map_src + '" data-map="true" data-url="' + map_url + '" allowfullscreen="" loading="lazy"></iframe>\
29113        ';
29114        if(return_type == 'html') return map_iframe;
29115        else if(return_type == 'src') return map_src;
29116        // else if(return_type == 'obj') {
29117        //     return {
29118        //         'url' : map_url,
29119        //         'src' : map_src,
29120        //         'html' : map_iframe.trim(),
29121        //         'place' : (checkPlace) ? map_place : '',
29122        //         'xy' : (checkPlace) ? map_xy : '',
29123        //         'unit' : (checkPlace) ? map_unit : '',
29124        //         'zoom' : (checkPlace) ? map_zoom : '',
29125        //     };
29126        // }
29127    } else {
29128        var map_src = '//www.google.com/maps?q=서울특별시&z=10&output=embed',
29129            map_iframe = '\
29130            <iframe class="google-map disabled" src="' + map_src + '" data-map="true" data-url="' + map_src + '" allowfullscreen="" loading="lazy"></iframe>\
29131            <div class="map-undefined"><span>지도 URL을 다시 설정해주세요</span></div>\
29132        ';
29133
29134        if(return_type == 'html') return map_iframe;
29135        else if(return_type == 'src') return map_src;
29136    }
29137}
29138
29139var deliveryTemplateListModal = function(shopping_url, close_func) {
29140$.processON();
29141    var html = '';
29142
29143    html += '\
29144        <div class="setting-sub-content setting-delivery-template">\
29145            <div class="setting-sub-content-desc">여러 유형의 배송 조건을 설정하고, 상품 등록 시 미리 설정해둔 배송 조건을<br>간편하게 적용할 수 있습니다.</div>\
29146            <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>\
29147            <div class="delivery-template-area"></div>\
29148        </div>\
29149    '
29150
29151    var modal = $(this).showModalFlat($.lang[LANG]['shopping.delivery.template.title'],html,true,false, function() {
29152        modal.modal('hide');
29153    }, 'close','','cl-cmmodal cl-s-btn w680 cl-p70 cover delivery-template-modal', true, function() {
29154        if(typeof close_func == 'function') {
29155            close_func();
29156        }
29157    }, function() {
29158        
29159        var getDeliveryTemplateList = function() {
29160            $.ajax({
29161                url: shopping_url + '/getDeliveryTemplateList',
29162                type: 'post',
29163                dataType: 'json',
29164                data:{'sid' : SID},
29165                async: false,
29166                success:function(data) {
29167                    console.log(data);
29168                    var html = '';
29169                    if(data.length) {
29170                        $(data).each(function(idx) {
29171                            var row = this;
29172
29173                            html += '<div class="template-row-box" data-seq="' + row.seq + '">';
29174                            html += '<div class="template-row-title-box">';
29175                            html += '<div class="template-row-title">' + row.name + '</div>';
29176
29177                            if(LUX) {
29178                                if(idx > 0) {
29179                                    html += '<div class="template-row-buttons">\
29180                                                <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>\
29181                                                <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>\
29182                                    ';
29183                                    if(idx > 1) {
29184                                        html += '\
29185                                                    <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>\
29186                                        ';
29187                                    }
29188                                    html += '\
29189                                            </div>';
29190                                }
29191                            } else {
29192                                html += '<div class="template-row-buttons">\
29193                                            <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>\
29194                                            <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>\
29195                                ';
29196                                if(idx > 0) {
29197                                    html += '\
29198                                                <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>\
29199                                    ';
29200                                }
29201                                html += '\
29202                                        </div>';
29203                            }
29204                            html += '</div>';
29205
29206                            html += '<div class="template-row-content">';
29207                            html += (row.mix_yn == 'Y' ? '묶음배송' : '개별배송') + ' / ';
29208
29209                            var delivery_type_arr = row.delivery_type.split(',');
29210                            var delivery_type_str = '';
29211                            $(delivery_type_arr).each(function(k,v) {
29212                                if(delivery_type_str) delivery_type_str += ', ';
29213                                delivery_type_str += $.lang[LANG]['shopping.delivery.template.delivery_type.' + v.toLowerCase()];
29214                            });
29215
29216
29217                            if(delivery_type_str) html += delivery_type_str + ' / ';
29218                            if(delivery_type_arr.indexOf('DELIVERY') > -1) 
29219                                html += $.lang[LANG]['shopping.delivery.' + row.delivery_company.toLowerCase()] + ' / ';
29220                            html += $.lang[LANG]['shopping.delivery.template.price_type.' + row.price_type.toLowerCase()]; 
29221
29222                            if(row.price_type == 'FIX') {
29223                                html += '(' + number_format(row.delivery_fee) + '원)';
29224                            } else if(row.price_type == 'QUANTITY' || row.price_type == 'WEIGHT') {
29225                                var price_type_detail = row.price_type_detail ? JSON.parse(row.price_type_detail) : {};
29226                                
29227                                if(price_type_detail.method == 'DIFFERENTIAL') {
29228                                    var detail = '';
29229                                    var popup_content = '';
29230                                    if(price_type_detail.detail) {
29231                                        $.each(price_type_detail.detail, function(k, v) {
29232                                            var value = Object.keys(v);
29233                                            var price = Object.values(v);
29234
29235                                            if(row.price_type == 'QUANTITY') {
29236                                                if(k < 2) {
29237                                                    if(detail) detail += ', ';
29238                                                    detail += value + '개 이상(' + number_format(price) + '원)';
29239                                                }
29240                                                popup_content += value + '개 이상 ' + number_format(price) + '원' + '<br>';
29241                                            } else if(row.price_type == 'WEIGHT') {
29242                                                if(k < 2) {
29243                                                    if(detail) detail += ', ';
29244                                                    detail += value + 'Kg 이상(' + number_format(price) + '원)';
29245                                                }
29246                                                popup_content += value + 'Kg 이상 ' + number_format(price) + '원' + '<br>';
29247                                            }
29248                                        });
29249
29250                                        if(price_type_detail.detail.length > 2) {
29251                                            popup_content = $.lang[LANG]['shopping.delivery.template.price_type.' + row.price_type.toLowerCase()] + '<br>' + popup_content;
29252                                            if(!LUX) popup_content += '<br>※ 추가 상품은 배송비 조건에 반영되지 않습니다.';
29253                                            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>';
29254                                        }
29255                                    }
29256                                    if(detail) {
29257                                        detail = '(차등 / ' + detail + ')';
29258                                        html += detail;
29259                                    }
29260                                } else if(price_type_detail.method == 'REPEAT') {
29261                                    var detail = '';
29262                                    var value = Object.keys(price_type_detail.detail);
29263                                    var price = Object.values(price_type_detail.detail);
29264
29265                                    if(row.price_type == 'QUANTITY') {
29266                                        detail += value + '개 구매시마다 ' + number_format(price) + '원 반복 부과';
29267                                    } else if(row.price_type == 'WEIGHT') {
29268                                        detail += value + 'Kg마다 ' + number_format(price) + '원 반복 부과';
29269                                    }
29270
29271                                    if(detail) {
29272                                        detail = '(반복 / ' + detail + ')';
29273                                        html += detail;
29274                                    }
29275                                }
29276                            }
29277
29278                            if(row.additional_yn == 'Y') {
29279                                html += ' / 도서산간 지역 추가 배송비 (제주 ' + number_format(row.additional_jeju_price) + '원, 제주 외 도서산간 ' + number_format(row.additional_land_price) + '원';
29280                            }
29281
29282                            html += ' / ' + $.lang[LANG]['shopping.delivery.template.pay_type.' + row.pay_type.toLowerCase()];
29283
29284                            if(row.free_condition_yn == 'Y') {
29285                                html += ' / ' + number_format(row.free_condition) + '원 이상 무료 배송';
29286                            }
29287
29288                            if(row.make_to_order_yn == 'Y') {
29289                                html += ' / 주문 확인 후 ' + row.due_date + '일 후 배송 예정';
29290                            }
29291
29292                            if(row.install_fee_yn == 'Y') {
29293                                html += ' / 별도 설치비 있음';
29294                            }
29295
29296                            html += '</div>';
29297                            html += '</div>';
29298                        });
29299                    } else {
29300                        html += '<div>배송 템플릿이 없습니다.</div>';
29301                    }
29302                    html += '</div>';
29303                    $('.delivery-template-area').html(html);
29304                    $('.delivery-template-area').find('[data-toggle="popover"]').popover();
29305                }, complete: function() {
29306                    $.processOFF();
29307                }
29308            });
29309        }
29310
29311        getDeliveryTemplateList();
29312
29313        $('.btn-add-template').on('click', function() {
29314            deliveryTemplateEditModal(shopping_url, '', getDeliveryTemplateList);
29315        });
29316
29317        modal.on('click', '.btn-edit-template', function() {
29318            var seq = $(this).closest('.template-row-box').data('seq');
29319            deliveryTemplateEditModal(shopping_url, seq, getDeliveryTemplateList);
29320        });
29321
29322        modal.on('click', '.btn-copy-template', function() {
29323            var seq = $(this).closest('.template-row-box').data('seq');
29324            var copy_modal = $(this).showModalFlat('배송설정 복제', '선택한 배송설정을 복제하시겠습니까?', true, true, function() {
29325                    $.processON();
29326                    setTimeout(function() {
29327                        $.ajax({
29328                            url: shopping_url + '/copyDeliveryTemplate',
29329                            type:'post',
29330                            dataType:'json',
29331                            async: false,
29332                            data:{'sid' : SID, 'seq' : seq},
29333                            success:function(data) {
29334                                getDeliveryTemplateList();
29335                            }, complete: function() {
29336                                $.processOFF();
29337                            }
29338                        });
29339                    });
29340                    
29341                copy_modal.modal('hide');
29342            }, 'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p130');
29343            var backdrop_z_index = Number(copy_modal.css('zIndex'));
29344            backdrop_z_index+=2;
29345            copy_modal.css('zIndex', backdrop_z_index + 1);
29346            copy_modal.parent().next('.modal-backdrop').css('zIndex', backdrop_z_index);
29347        });
29348
29349        modal.on('click', '.btn-delete-template', function() {
29350            var seq = $(this).closest('.template-row-box').data('seq');
29351            var delete_modal = $(this).showModalFlat('배송설정 삭제', '선택한 배송설정이 적용되었던 상품들은 기본 배송설정으로 변경됩니다.<br><br>선택한 배송설정을 삭제하시겠습니까?', true, true, function() {
29352                    $.processON();
29353                    setTimeout(function() {
29354                        $.ajax({
29355                            url: shopping_url + '/deleteDeliveryTemplate',
29356                            type:'post',
29357                            dataType:'json',
29358                            async: false,
29359                            data: {
29360                                'sid' : SID,
29361                                'seq' : seq
29362                            },
29363                            success:function(data) {
29364                                getDeliveryTemplateList();
29365                            },
29366                            complete: function() {
29367                                $.processOFF();
29368                            }
29369                        });
29370                    });
29371                delete_modal.modal('hide');
29372            }, 'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p130',true);
29373                
29374            var backdrop_z_index = Number(delete_modal.css('zIndex'));
29375            backdrop_z_index+=2;
29376            delete_modal.css('zIndex', backdrop_z_index + 1);
29377            delete_modal.parent().next('.modal-backdrop').css('zIndex', backdrop_z_index);
29378        }); 
29379    }, function() {
29380        // if(typeof close_func == 'function') {
29381        //     close_func();
29382        // }
29383    });
29384}
29385
29386var deliveryTemplateEditModal = function(shopping_url, template_seq, callback_func) {
29387
29388    var seq = template_seq ? template_seq : '';
29389
29390    var opts = {
29391        'seq' : '',
29392        'name':'',
29393        'mix_yn' : 'Y',
29394        'delivery_type' : 'DELIVERY',
29395        'price_type' : 'FIX',
29396        'delivery_fee' : 2500,
29397        'additional_yn' : 'N',
29398        'pay_type' : 'PREPAY',
29399        'free_condition_yn' : 'N',
29400        'make_to_order_yn' : 'N',
29401        'install_fee_yn' : 'N',
29402        'additional_jeju_price' : 0,
29403        'additional_land_price' : 0,
29404        'due_date' : '',
29405        'free_condition' : 0,
29406        'delivery_company' : 'pt',
29407        'price_type_detail' : {}
29408    };
29409
29410    if(seq) {
29411        $.ajax({
29412            url:shopping_url + '/getDeliveryTemplate',
29413            type:'post',
29414            dataType:'json',
29415            async: false,
29416            data:{
29417                'seq' : seq,
29418                'sid' : SID,
29419            },
29420            success:function(data) {
29421                $.extend(opts, data);
29422            }
29423        });
29424    }
29425
29426    opts.delivery_type = opts.delivery_type.split(',');
29427    if(opts.price_type == 'QUANTITY' || opts.price_type == 'WEIGHT') {
29428        opts.price_type_detail = opts.price_type_detail ? JSON.parse(opts.price_type_detail) : {};
29429        
29430        if(!opts.price_type_detail.detail) {
29431            opts.price_type_detail.detail = {};
29432        }
29433
29434        if(opts.price_type_detail.method && opts.price_type_detail.method == 'REPEAT') {
29435            if(opts.price_type == 'QUANTITY') {
29436                opts.quantity_repeat_value = Object.keys(opts.price_type_detail.detail)[0];
29437                opts.quantity_repeat_price = Object.values(opts.price_type_detail.detail)[0];
29438            } else if(opts.price_type == 'WEIGHT') {
29439                opts.weight_repeat_value = Object.keys(opts.price_type_detail.detail)[0];
29440                opts.weight_repeat_price = Object.values(opts.price_type_detail.detail)[0];
29441            }
29442        } else {
29443            opts.price_type_detail.method = 'DIFFERENTIAL';
29444        }
29445    }
29446
29447    if(opts.delivery_company == '') opts.delivery_company = 'pt';
29448
29449    var tracking_delivery_company_arr = ['cj','pt','hj','lg','lt','post'];
29450
29451    var delivery_company_arr = [
29452        'etc',
29453        'cj',
29454        'pt',
29455        'hj',
29456        'lg',
29457        'lt',
29458        'post',
29459        'koryo',
29460        'wevill',
29461        'daesin',
29462        'ilyang',
29463        'kdexp',
29464        'chunil',
29465        'cv',
29466        'cu',
29467        'hdexp',
29468        'dhl',
29469        'dhlglobalmail',
29470        'dhlde',
29471        'fedex',
29472        'gsmnton',
29473        'warpex',
29474        'ems',
29475        'ace',
29476        'qxpress',
29477        'aciexpress',
29478        'lineexp',
29479        'pantos',
29480        'smartlogis',
29481        'hlcglobal',
29482        'ups',
29483        'korexg',
29484        'tnt',
29485        'swgexp',
29486        'daewoon',
29487        'usps',
29488        'iparcel',
29489        'kunyoung',
29490        'hpl',
29491        'gnetwork',
29492        'slx',
29493        'daelim',
29494        'honam',
29495        'gsiexpress',
29496        'eunha',
29497        'homeinno',
29498        'hybrid',
29499        'airway',
29500        'woorihb',
29501        'yjsworld',
29502        'yjs',
29503        'crlx',
29504        'homepick',
29505        'cwayexpress',
29506        'anytrack',
29507        'bridge',
29508        'gpslogix',
29509        'esther',
29510        'lotos',
29511        'ufreight',
29512        'ik',
29513        'lslogis',
29514        'sebang',
29515        'nonghyup',
29516        'yongma',
29517        'europarcel',
29518        'kgsl',
29519        'sunghun',
29520        'forever',
29521        'airboy',
29522        'ecmsexpress',
29523        'efs',
29524        'handex',
29525        'kglnet',
29526        'twofastexpress',
29527        'gos',
29528        'gspostbox',
29529        'adcair',
29530        'donggang',
29531        'kin',
29532        'hanwoori',
29533        'lglogistics',
29534        'generalpost',
29535        'ezusa',
29536        'handalum',
29537        'howser',
29538        'dpd',
29539        'gop',
29540        'wizwa',
29541        'selc',
29542        'sfex',
29543        'wihtyou',
29544        'roadsunexpress',
29545        'dongjin',
29546        'ilshin',
29547        'ky',
29548        'tpmlogis',
29549        'zeniel',
29550        'fresh',
29551        'jlogist',
29552        'chainlogis',
29553        'hivecity',
29554        'hanssem',
29555        'todaypickup',
29556        'qrun',
29557        'nogok',
29558        'spasys1',
29559        'freshmates',
29560        'etomars',
29561        'shipnergy',
29562        'geniego',
29563        'dodoflex',
29564        'ltl',
29565        'vendorpia',
29566        'coship',
29567        'gdakorea',
29568        'lge',
29569        'teamfresh',
29570        'yunda',
29571        'alltakorea',
29572        'lottechilsung',
29573        'valex',
29574        'bababa',
29575        'ch1',
29576        'apex',
29577        'homeplus',
29578        'gsfresh',
29579        'hanaromart',
29580        'choroc',
29581        'vroong',
29582        'dcommerce',
29583        'aboutpet',
29584        '1004home',
29585        'gtslogis',
29586        'sbgls',
29587        'ssg',
29588        'kokusai',
29589        'goodtoluck',
29590        'ekdp',
29591        'woongji',
29592        'xinpatek',
29593        'herewego',
29594        'panasia',
29595        'pingpong',
29596        'cargoplease',
29597		'kjt', // 케이제이티
29598		'rush', // 오늘회러쉬
29599		'ntlps', // 엔티엘피스
29600		'actcore', // 에이씨티앤코아
29601		'logisvalley', // 로지스밸리
29602		'drabbit', // 딜리래빗
29603		'naeun', // 나은물류
29604		'logispartner', // UFO 로지스
29605		'ndexkorea', // NDEX KOREA
29606    ];
29607
29608        // console.log(new_delivery_company_arr)
29609    var tmp_delivery_company_arr = {}, new_delivery_company_arr = {};
29610    var delivery_company_options = '';
29611    $(delivery_company_arr).each(function(k, v) {
29612        tmp_delivery_company_arr[$.lang[LANG]['shopping.delivery.' + v]] = v;
29613    });
29614
29615    $(Object.keys(tmp_delivery_company_arr).sort()).each(function(k, v) {
29616        new_delivery_company_arr[v] = tmp_delivery_company_arr[v];
29617    });
29618
29619    delivery_company_options = '';
29620    $.each(new_delivery_company_arr, function(k, v) {
29621        var data_content = '';
29622        if(tracking_delivery_company_arr.indexOf(v) > -1) {
29623            data_content = '<span class="tracking-delivery-icon"></span>';
29624        }
29625        delivery_company_options += '<option value="' + v + '" ' + (opts.delivery_company == v ? ' selected ' : '') + (data_content ? ' data-content=\'' + k + data_content + '\'' : '') + '>' + k + '</option>';
29626    });
29627
29628    var html = '\
29629        <div class="delivery-template-layer">\
29630            <form id="deliveryTemplateForm">\
29631                <div class="item-row">\
29632                    <div class="">' + $.lang[LANG]['shopping.delivery.template.name'] + '</div>\
29633                    <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>\
29634                </div>\
29635                <div class="item-row">\
29636                    <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>\
29637                    <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>
29637' + $.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>\
29638                </div>\
29639                <div class="item-row">\
29640                    <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>\
29641                    <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>
29641' + $.lang[LANG]['shopping.delivery.template.delivery_type.visit'] + '</label>\
29642                        <div class="delivery-company-row" style="' + (opts.delivery_type.indexOf('DELIVERY') > -1 ? '' : ' display: none; ') + '">\
29643                            <div class="row-sub-title">' + $.lang[LANG]['shopping.delivery.template.delivery_company'] + '</div>\
29644                            <select name="delivery_company" class="form-control">\
29645                                ' + delivery_company_options + '\
29646                            </select>\
29647                        </div>\
29648                    </div>\
29649                </div>\
29650                <div class="item-row">\
29651                    <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>\
29652                    <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>\
29653                        <div class="fix-row free-condition-row m15t" style="' + (opts.price_type == 'FIX' || opts.price_type == 'FREE_CONDITION' ? '' : ' display: none; ') + '">\
29654                            <div class="row-sub-title">기본 배송비</div>\
29655                            <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>\
29656                        </div>\
29657                        <div class="free-condition-row m15t" style="' + (opts.price_type == 'FREE_CONDITION' ? '' : ' display: none; ') + '">\
29658                            <div class="row-sub-title">무료 배송 조건</div>\
29659                            <div class="m5t">\
29660                                <input type="text" name="free_condition" class="form-control" value="' + (number_format(opts.free_condition)) + '" numberonly maxlength="13" />원 이상 구매 시 무료 배송\
29661                            </div>\
29662                            <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>\
29663                        </div>\
29664                        <div class="price-type-detail-method-row quantity-row weight-row" style="' + (opts.price_type == 'QUANTITY' || opts.price_type == 'WEIGHT' ? '' : ' display: none;') + '">\
29665                            <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>\
29666                            <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>\
29667                        </div>\
29668                        <div class="quantity-row" style="' + (opts.price_type == 'QUANTITY' ? '' : ' display: none; ') + '">\
29669                        <div class="quantity-differential" style="' + (opts.price_type_detail.method == 'DIFFERENTIAL' ? '' : ' display: none;') + '">\
29670                            <table>\
29671                                <colgroup><col width="45%" /><col width="40%" /><col width="20%" /></colgroup>\
29672                        ';
29673
29674                        if(opts.price_type == 'QUANTITY' && opts.price_type_detail.method == 'DIFFERENTIAL' && opts.price_type_detail.detail.length) {
29675                            $.each(opts.price_type_detail.detail, function(k, v) {
29676                                var value = Object.keys(v);
29677                                var price = Object.values(v);
29678                                if(k == 0) value = 1;
29679                                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>';
29680                            });
29681                        } else {
29682                            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>';
29683                        }
29684
29685                        html += '\
29686                                </table>\
29687                                <div><button type="button" class="btn btn-quantity-diff">+ 조건 추가</button></div>\
29688                            </div>\
29689                            <div class="quantity-repeat" style="' + (opts.price_type_detail.method == 'REPEAT' ? '' : ' display: none;') + '">\
29690                                <div class="row-sub-title">기본 배송비</div>\
29691                                <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>\
29692                                <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>\
29693                            </div>\
29694                        </div>\
29695                        <div class="weight-row" style="' + (opts.price_type == 'WEIGHT' ? '' : ' display: none;') + '">\
29696                        <div class="weight-differential" style="' + (opts.price_type_detail.method == 'DIFFERENTIAL' ? '' : ' display: none;') + '">\
29697                            <table>\
29698                                <colgroup><col width="45%" /><col width="40%" /><col width="20%" /></colgroup>\
29699                        ';
29700
29701                        if(opts.price_type == 'WEIGHT' && opts.price_type_detail.method == 'DIFFERENTIAL' && opts.price_type_detail.detail.length) {
29702                            $(opts.price_type_detail.detail).each(function(k, v) {
29703                                var value = Object.keys(v);
29704                                var price = Object.values(v);
29705                                if(k == 0) value = 0;
29706                                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">
29706<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>';
29707                            });
29708                        } else {
29709                            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>';
29710                        }
29711                        html += '\
29712                                </table>\
29713                                <div><button type="button" class="btn btn-weight-diff">+ 조건 추가</button></div>\
29714                            </div>\
29715                            <div class="weight-repeat" style="' + (opts.price_type_detail.method == 'REPEAT' ? '' : ' display: none; ') + '">\
29716                                <div>기본 배송비</div>\
29717                                <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>\
29718                                <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>\
29719                            </div>\
29720                        </div>\
29721                        ';
29722                        if(!LUX) {
29723                            html += '\
29724                        <div class="quantity-row weight-row" style="' + (opts.price_type == 'QUANTITY' || opts.price_type == 'WEIGHT' ? '' : ' display: none;') + '">\
29725                            <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>\
29726                        </div>\
29727                            ';
29728                        }
29729                        html += '\
29730                    </div>\
29731                </div>\
29732                <div class="item-row">\
29733                    <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>\
29734                    <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>
29734' + $.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>\
29735                        <div class="additional-row m15t" style="' + (opts.additional_yn == 'Y' ? '' : ' display: none; ') + '">\
29736                            <div class="row-sub-title">제주</div>\
29737                            <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>\
29738                            <div class="row-sub-title m15t">제주 외 도서산간</div>\
29739                            <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>\
29740                        </div>\
29741                    </div>\
29742                </div>\
29743                <div class="item-row">\
29744                    <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>\
29745                    <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>
29745' + $.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>\
29746                </div>\
29747                <div class="item-row">\
29748                    <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>\
29749                    <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>\
29750                        <div class="make-to-order-row" style="' + (opts.make_to_order_yn == 'Y' ? '' : ' display : none; ') + '">\
29751                            <div class="row-sub-title m15t">발송 예정일</div>\
29752                            <div class="m5t">\
29753                                <select name="due_date" class="form-control">\
29754                                    <option value="">선택</option>\
29755                    ';
29756
29757                    for(var i=2; i<=14; i++) {
29758                        html += '<option value="' + i + '" ' + (opts.due_date == i ? ' selected ' : '') + '>' + i + '</option>';
29759                    }
29760
29761                    html += '   </select> 일 이내 발송 예정\
29762                            </div>\
29763                            <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
297636 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>\
29764                        </div>\
29765                    </div>\
29766                </div>\
29767                <div class="item-row">\
29768                    <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>\
29769                    <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>\
29770                </div>\
29771            </form>\
29772        </div>\
29773    ';
29774
29775    var modal = $(this).showModalFlat($.lang[LANG]['shopping.delivery.template.title.' + (seq != '' ? 'm' : 'n')],html,true,true, function() {
29776        modal.find('.error').remove();
29777        modal.find('.error-box').removeClass('error-box');
29778
29779        var result = true;
29780
29781        if($.trim(modal.find('input[name="name"]').val()) == '') {
29782            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>');
29783            modal.find('input[name="name"]').addClass('error-box').focus();
29784            result = false;
29785        } 
29786
29787        if(checkEmojis(modal.find('input[name="name"]').val())) {
29788            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>');
29789            modal.find('input[name="name"]').addClass('error-box').focus();
29790            result = false;
29791        }
29792
29793        $.ajax({
29794            url: shopping_url + '/deliveryTemplateNameCheck',
29795            type: 'post',
29796            dataType: 'json',
29797            async: false,
29798            data: {
29799                'sid' : SID,
29800                'seq' : modal.find('input[name="seq"]').val(),
29801                'name' : $.trim(modal.find('input[name="name"]').val())
29802            },
29803            success:function(data) {
29804                if(data.result != 'N') {
29805                    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>');
29806                    modal.find('input[name="name"]').focus();
29807                    result = false;
29808                }
29809            }
29810        });
29811
29812        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)) {
29813            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>');
29814            modal.find('input[name="delivery_fee"]').addClass('error-box').focus();
29815            result = false;
29816        } 
29817
29818        if(modal.find('select[name="price_type"]').val() == 'FREE_CONDITION') {
29819            if(!modal.find('input[name="free_condition"]').val() || modal.find('input[name="free_condition"]').val() < 10) {
29820                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>');
29821                modal.find('input[name="free_condition"]').addClass('error-box').focus();;
29822                result = false;
29823            }
29824        } else if(modal.find('select[name="price_type"] option:selected').val() == 'QUANTITY') { // 수량별
29825            if(modal.find('input[name="price_type_detail_method"]:checked').val() == 'DIFFERENTIAL') { // 차등 부과
29826                modal.find('input[name="quantity_differential_value[]"]:not([readonly]), input[name="quantity_differential_price[]"]').each(function() {
29827                    if($(this).attr('name') == 'quantity_differential_value[]') {   
29828                        if($.trim($(this).val()) == '' || $(this).val() == 0) {
29829                            $(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>');
29830                            result = false;
29831                            $(this).addClass('error-box');
29832                        } else {
29833                            var val = $(this).val();
29834                            var cur_elem = this;
29835                            var dup_elem = modal.find('input[name="quantity_differential_value[]"]').filter(function() { return cur_elem != this && $(this).val() == val;});
29836                            if(dup_elem.length) {
29837                                dup_elem.addClass('error-box');
29838                                result = false;
29839                                $(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>');
29840                            }
29841                        }
29842                    } 
29843
29844                    if($(this).attr('name') == 'quantity_differential_price[]') {
29845                        if($.trim($(this).val()) == '' || $.trim($(this).val()) < 10) {
29846                            if(!$(this).closest('tr').next('tr.error').length)
29847                                $(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>')
29848                            $(this).addClass('error-box');
29849                            result = false;
29850                        }
29851                    }
29852                });
29853            } else if(modal.find('input[name="price_type_detail_method"]:checked').val() == 'REPEAT') {
29854                if(modal.find('input[name="quantity_repeat_value"]').val() == 0 || modal.find('input[name="quantity_repeat_value"]').val() == '') { // 반복 부과
29855                    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>');
29856                    modal.find('input[name="quantity_repeat_value"]').addClass('error-box');
29857                    modal.find('input[name="quantity_repeat_value"]').focus();
29858                    result = false;
29859                } 
29860
29861                if(!modal.find('input[name="quantity_repeat_price"]').val() || modal.find('input[name="quantity_repeat_price"]').val() < 10) {
29862                    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>');
29863                    modal.find('input[name="quantity_repeat_price"]').addClass('error-box');
29864                    modal.find('input[name="quantity_repeat_price"]').focus();
29865                    result = false;
29866                }
29867            }
29868        } else if(modal.find('select[name="price_type"] option:selected').val() == 'WEIGHT') { // 무게별
29869            if(modal.find('input[name="price_type_detail_method"]:checked').val() == 'DIFFERENTIAL') { // 차등 부과
29870                
29871                modal.find('input[name="weight_differential_value[]"], input[name="weight_differential_price[]"]').not('[readonly]').each(function() {
29872                    if($(this).attr('name') == 'weight_differential_value[]') {
29873                        if($.trim($(this).val()) == '' || $.trim($(this).val()) == 0) {
29874                            result = false;
29875                            $(this).addClass('error-box');
29876                            $(this).focus();
29877                            $(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>');
29878                            
29879                        } else {
29880                            var val = $(this).val();
29881                            var cur_elem = this;
29882                            var dup_elem = modal.find('input[name="weight_differential_value[]"]').filter(function() { return cur_elem != this && $(this).val() == val;});
29883                            if(dup_elem.length) {
29884                                dup_elem.addClass('error-box');
29885                                dup_elem.eq(0).focus();
29886                                result = false;
29887                                $(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>');
29888                                
29889                            }
29890                        }
29891                    }
29892                    
29893                    if($(this).attr('name') == 'weight_differential_price[]') {
29894                        if(!$(this).val() || $(this).val() < 10) {
29895                            if(!$(this).closest('tr').next('tr.error').length)
29896                                $(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>')
29897                            $(this).addClass('error-box');
29898                            $(this).focus();
29899                            result = false;
29900                        }
29901                    }
29902                });
29903            } else if(modal.find('input[name="price_type_detail_method"]:checked').val() == 'REPEAT') { // 반복 부과
29904                if(modal.find('input[name="weight_repeat_value"]').val() == 0 || modal.find('input[name="weight_repeat_value"]').val() == '') {
29905                    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>');
29906                    modal.find('input[name="weight_repeat_value"]').addClass('error-box');
29907                    modal.find('input[name="weight_repeat_value"]').focus();
29908                    result = false;
29909                }
29910
29911                if(!modal.find('input[name="weight_repeat_price"]').val() || modal.find('input[name="weight_repeat_price"]').val() < 10) {
29912                    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>');
29913                    modal.find('input[name="weight_repeat_price"]').addClass('error-box');
29914                    modal.find('input[name="weight_repeat_price"]').focus();
29915                    result = false;
29916                }
29917            }
29918        }
29919
29920        if(modal.find('input[name="additional_yn"]:checked').val() == 'Y') {
29921            modal.find('input[name="additional_jeju_price"]').parent().next('.error').remove();
29922            if($.trim(modal.find('input[name="additional_jeju_price"]').val()) == '' || $.trim(modal.find('input[name="additional_jeju_price"]').val()) < 10) {
29923                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>');
29924                modal.find('input[name="additional_jeju_price"]').addClass('error-box');
29925                result = false;
29926            }
29927
29928            modal.find('input[name="additional_land_price"]').parent().next('.error').remove();
29929            if($.trim(modal.find('input[name="additional_land_price"]').val()) == '' || $.trim(modal.find('input[name="additional_jeju_price"]').val()) < 10) {
29930                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>');
29931                modal.find('input[name="additional_land_price"]').addClass('error-box');
29932                result = false;
29933            }
29934        }
29935
29936        if(modal.find('input[name="make_to_order_yn"]:checked').val() == 'Y' && modal.find('select[name="due_date"]').val() == '') {
29937            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>');
29938            modal.find('.make-to-order-row button').addClass('error-box');
29939            result = false;
29940        }
29941
29942        if(!result) return false;
29943
29944        $.processON();
29945        setTimeout(function() {
29946            $.ajax({
29947                url: shopping_url + '/insertDeliveryTemplate',
29948                type:'post',
29949                dataType:'json',
29950                async:false,
29951                data: $('#deliveryTemplateForm').serialize(),
29952                success:function(data) {
29953
29954                },
29955                complete: function() {
29956                    $.processOFF();
29957                    if(typeof callback_func == 'function') callback_func();
29958                }
29959            });
29960        });
29961        
29962        modal.modal('hide');
29963    }, 'cancel','save','cl-cmmodal cover delivery-template-modal cl-s-btn w620 cl-p80', true, '', function() {
29964        modal.find('#deliveryTemplateForm input[name="name"]').on('blur', function() {
29965            modal.find('.name-error').remove();
29966            $(this).removeClass('error-box');
29967
29968            if($.trim($(this).val()) == '') {
29969                $(this).addClass('error-box');
29970                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>');
29971                return;  
29972            } 
29973
29974            if(checkEmojis($(this).val())) {
29975                $(this).addClass('error-box');
29976                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>');
29977                return false;
29978            }
29979
29980            $.ajax({
29981                url: shopping_url + '/deliveryTemplateNameCheck',
29982                type: 'post',
29983                dataType: 'json',
29984                data: {
29985                    'sid' : SID,
29986                    'seq' : modal.find('input[name="seq"]').val(),
29987                    'name' : $.trim($(this).val())
29988                },
29989                success:function(data) {
29990                    if(data.result != 'N') {
29991                        $(this).addClass('error-box');
29992                        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>');
29993                    } else {
29994                        modal.find('.name-error').remove();
29995                        modal.find('#deliveryTemplateForm input[name="name"]').removeClass('error-box');
29996                    }
29997                }
29998            });
29999        }).on('input', function() {
30000            var regexp = /^[ㄱ-ㅎㅏ-ㅣ가-힣a-zA-Z0-9\(\)\[\]\_\- ]+$/;
30001            if(!regexp.test($.trim($(this).val()))) {
30002                $(this).val($.trim($(this).val()).replace(/[^ㄱ-ㅎㅏ-ㅣ가-힣a-zA-Z0-9\(\)\[\]\_\- ]/gi, ''));
30003            }
30004        });
30005
30006        modal.find('input[name="mix_yn"]').on('change', function() {
30007            if($('input[name="mix_yn"]:checked').val() == 'Y') {
30008                modal.find('.mix-price-type-row').show();
30009            } else {
30010                modal.find('.mix-price-type-row').hide();
30011            }
30012        });
30013
30014        modal.find('select[name="price_type"]').on('change', function() {
30015            if($(this).find('option:selected').val() == 'QUANTITY') {
30016                modal.find('input[name="price_type_detail_method"]:first').prop('checked', true).change();
30017                modal.find('.weight-row').hide();
30018                modal.find('.fix-row').hide();
30019                modal.find('.free-condition-row').hide();
30020                modal.find('.quantity-row').show();
30021            } else if($(this).find('option:selected').val() == 'WEIGHT') {
30022                modal.find('input[name="price_type_detail_method"]:first').prop('checked', true).change();
30023                modal.find('.quantity-row').hide();
30024                modal.find('.fix-row').hide();
30025                modal.find('.free-condition-row').hide();
30026                modal.find('.weight-row').show();
30027            } else if($(this).find('option:selected').val() == 'FIX') {
30028                modal.find('.quantity-row').hide();
30029                modal.find('.weight-row').hide();
30030                modal.find('.free-condition-row').hide();
30031                modal.find('.fix-row').show();
30032            } else if($(this).find('option:selected').val() == 'FREE_CONDITION') {
30033                modal.find('.quantity-row').hide();
30034                modal.find('.weight-row').hide();
30035                modal.find('.fix-row').hide();
30036                modal.find('.free-condition-row').show();
30037            } else {
30038                modal.find('.fix-row').hide();
30039                modal.find('.quantity-row').hide();
30040                modal.find('.weight-row').hide();
30041                modal.find('.free-condition-row').hide();
30042            }
30043        });
30044
30045        modal.find('.btn-quantity-diff').on('click', function() {
30046            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>
30046<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>';
30047            modal.find('.quantity-differential table').append(html);
30048        });
30049
30050        modal.find('.btn-weight-diff').on('click', function() {
30051            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>';
30052            modal.find('.weight-differential table').append(html);
30053        });
30054
30055        modal.find('input[name="delivery_type[]"]').on('change', function() {
30056            if(modal.find('input[name="delivery_type[]"][value="DELIVERY"]:checked').length) {
30057                modal.find('.delivery-company-row').show();
30058            } else {
30059                modal.find('.delivery-company-row').hide();
30060            }
30061
30062            modal.find('select[name="price_type"]').prop('disabled', false);
30063
30064            // modal.find('input[name="additional_yn"]').prop('disabled', false);
30065            modal.find('.additional-yn-row').removeClass('disabled-area');
30066            
30067            // modal.find('input[name="pay_type"]').prop('disabled', false);
30068            modal.find('.pay-type-row').removeClass('disabled-area');
30069
30070            if(modal.find('input[name="delivery_type[]"]:checked').length == 1 && modal.find('input[name="delivery_type[]"]:checked').val() == 'VISIT') {
30071                modal.find('select[name="price_type"]').val('FREE').change().prop('disabled', true);
30072                modal.find('input[name="delivery_fee"]').val(0);
30073                modal.find('input[name="additional_yn"][value="N"]').prop('checked', true).change();
30074                // modal.find('input[name="additional_yn"]').prop('disabled', true);
30075                modal.find('.additional-yn-row').addClass('disabled-area');
30076                modal.find('input[name="pay_type"][value="PREPAY"]').prop('checked', true).change();
30077                // modal.find('input[name="pay_type"]').prop('disabled', true);
30078                modal.find('.pay-type-row').addClass('disabled-area');
30079            } else if(modal.find('input[name="delivery_type[]"]:checked').length == 1 && modal.find('input[name="delivery_type[]"]:checked').val() == 'QUICK') {
30080                modal.find('select[name="price_type"]').val('ETC').change().prop('disabled', true);
30081                modal.find('input[name="additional_yn"][value="N"]').prop('checked', true).change();
30082                // modal.find('input[name="additional_yn"]').prop('disabled', true);
30083                modal.find('.additional-yn-row').addClass('disabled-area');
30084                modal.find('input[name="pay_type"][value="DELIVERED"]').prop('checked', true).change();
30085                modal.find('input[name="pay_type"]').prop('disabled', true);
30086                modal.find('.pay-type-row').addClass('disabled-area');
30087            } else if(modal.find('input[name="delivery_type[]"][value="DELIVERY"]:checked').length == 0 && modal.find('input[name="delivery_type[]"][value="DIRECT"]:checked').length == 0) {
30088                modal.find('select[name="price_type"]').val('ETC').prop('disabled', true).change();
30089                modal.find('input[name="additional_yn"][value="N"]').prop('checked', true).change()
30090                // modal.find('input[name="additional_yn"]').prop('disabled', true);
30091                modal.find('.additional-yn-row').removeClass('disabled-area');
30092                modal.find('input[name="pay_type"][value="DELIVERED"]').prop('checked', true).change();
30093                // modal.find('input[name="pay_type"]').prop('disabled', true);
30094                modal.find('.pay-type-row').addClass('disabled-area');
30095            }
30096            modal.find('select[name="price_type"]').selectpicker('refresh');
30097        });
30098
30099        modal.on('input', 'input[numberonly]', function(){
30100            var max_num = 1000000000; //10억
30101            if(Number($(this).val().replace(/,/g, '')) > max_num) {
30102                $(this).val(number_format(max_num));
30103            }
30104        });
30105
30106        modal.on('input', 'input[name="weight_repeat_value"], input[name="weight_differential_value[]"]', function(){
30107            var max_num = 100;
30108
30109            var val = $(this).val().replace(/,/g, '');
30110            if(val.indexOf('.') > -1 && val.indexOf('.') < val.length-4) {
30111                val = Number((Math.floor(Number(val) * 1000) / 1000).toFixed(3));
30112            }
30113
30114            if(Number(val) > max_num) {
30115                val = max_num;
30116            }
30117            $(this).val(number_format(val));
30118        });
30119
30120        modal.find('input[name="price_type_detail_method"]').on('change', function() {
30121            if(modal.find('select[name="price_type"] option:selected').val() == 'QUANTITY') {
30122                if(modal.find('input[name="price_type_detail_method"]:checked').val() == 'DIFFERENTIAL') {
30123                    $('.quantity-differential').show();
30124                    $('.quantity-repeat').hide();
30125                } else if(modal.find('input[name="price_type_detail_method"]:checked').val() == 'REPEAT') {
30126                    $('.quantity-repeat').show();
30127                    $('.quantity-differential').hide();
30128                }
30129            } else if(modal.find('select[name="price_type"] option:selected').val() == 'WEIGHT') {
30130                if(modal.find('input[name="price_type_detail_method"]:checked').val() == 'DIFFERENTIAL') {
30131                    $('.weight-differential').show();
30132                    $('.weight-repeat').hide();
30133                } else if(modal.find('input[name="price_type_detail_method"]:checked').val() == 'REPEAT') {
30134                    $('.weight-repeat').show();
30135                    $('.weight-differential').hide();
30136                }
30137            }
30138        });
30139
30140        modal.find('input[name="delivery_fee"]').on('blur', function() {
30141            $(this).removeClass('error-box');
30142            $(this).parent().next('.error').remove();            
30143            if($.trim($(this).val()) == '' || $(this).val() < 10) {
30144                $(this).addClass('error-box');
30145                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">
30145<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>');
30146            }
30147        });
30148
30149        modal.find('input[name="additional_yn"]').on('change', function() {
30150            if(modal.find('input[name="additional_yn"]:checked').val() == 'Y') {
30151                modal.find('.additional-row').show();
30152            } else {
30153                modal.find('.additional-row').hide();
30154            }
30155        });
30156
30157        modal.find('input[name="free_condition_yn"]').on('change', function() {
30158            if(modal.find('input[name="free_condition_yn"]:checked').val() == 'Y') {
30159                modal.find('.free-condition-row').show();
30160            } else {
30161                modal.find('.free-condition-row').hide();
30162            }
30163        });
30164
30165        modal.find('input[name="free_condition"]').on('blur', function() {
30166            $(this).removeClass('error-box');
30167            $(this).parent().next('.error').remove();
30168            if($.trim($(this).val()) == '' || $(this).val() < 10) {
30169                $(this).addClass('error-box');
30170                $(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>');
30171            }
30172        });
30173
30174        modal.find('input[name="make_to_order_yn"]').on('change', function() {
30175            if(modal.find('input[name="make_to_order_yn"]:checked').val() == 'Y') {
30176                modal.find('.make-to-order-row').show();
30177            } else {
30178                modal.find('.make-to-order-row').hide();
30179            }
30180        });
30181
30182        modal.on('blur', 'input[name="quantity_repeat_price"], input[name="weight_repeat_price"], input[name="additional_jeju_price"], input[name="additional_land_price"]', function() {
30183            $(this).removeClass('error-box');
30184            $(this).parent().next('.error').remove();
30185            if($.trim($(this).val()) == '' || $.trim($(this).val()) < 10) {
30186                $(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>');
30187                $(this).addClass('error-box');
30188            }
30189        })
30190
30191        modal.on('blur', 'input[name="quantity_repeat_value"]', function() {
30192            $(this).removeClass('error-box');
30193            $(this).parent().next('.error').remove();
30194            if($.trim($(this).val()) == '' || $.trim($(this).val()) == 0) {
30195                $(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>');
30196                $(this).addClass('error-box');
30197            }
30198        });
30199
30200        modal.on('blur', 'input[name="weight_repeat_value"]', function() {
30201            $(this).removeClass('error-box');
30202            $(this).parent().next('.error').remove();
30203            if($.trim($(this).val()) == '' || $.trim($(this).val()) == 0) {
30204                $(this).parent().after('<div class="error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13">
30204<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>');
30205                $(this).addClass('error-box');
30206            }
30207        });
30208
30209        modal.on('blur', 'input[name="quantity_differential_value[]"]', function() {
30210            $(this).removeClass('error-box');
30211            $(this).closest('tr').next('tr.error').remove();
30212            if($.trim($(this).val()) == '' || $(this).val() == 0) {
30213                $(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>')
30214                $(this).addClass('error-box');
30215                return false;
30216            }
30217            modal.find('input[name="quantity_differential_value[]"]').removeClass('error-box');
30218            modal.find('.error.dup-value').remove();
30219            modal.find('input[name="quantity_differential_value[]"]').each(function() {
30220                var val = $(this).val();
30221                var cur_elem = this;
30222                var dup_elem = modal.find('input[name="quantity_differential_value[]"]').filter(function() { return cur_elem != this && $(this).val() == val;});
30223                if(dup_elem.length) {
30224                    dup_elem.addClass('error-box');
30225                    $(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>');
30226                    return false;
30227                }
30228            });
30229        });
30230
30231        modal.on('blur', 'input[name="weight_differential_value[]"]', function() {
30232            $(this).removeClass('error-box');
30233            $(this).closest('tr').next('tr.error').remove();
30234            if(!$('input[name="weight_differential_value[]"]').is('[readonly]') && ($.trim($(this).val()) == '' || $(this).val() == 0)) {
30235                $(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>')
30236                $(this).addClass('error-box');
30237                return false;
30238            }
30239            modal.find('input[name="weight_differential_value[]"]').removeClass('error-box');
30240            modal.find('.error.dup-value').remove();
30241            modal.find('input[name="weight_differential_value[]"]').each(function() {
30242                var val = $(this).val();
30243                var cur_elem = this;
30244                var dup_elem = modal.find('input[name="weight_differential_value[]"]').filter(function() { return cur_elem != this && $(this).val() == val;});
30245                if(dup_elem.length) {
30246                    dup_elem.addClass('error-box');
30247                    $(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>');
30248                    return false;
30249                }
30250            });
30251        });
30252
30253        modal.on('blur', 'input[name="quantity_differential_price[]"], input[name="weight_differential_price[]"]', function() {
30254            $(this).removeClass('error-box');
30255            $(this).closest('tr').next('tr.error').remove();
30256            if($.trim($(this).val()) == '' || $(this).val() < 10) {
30257                $(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>')
30258                $(this).addClass('error-box');
30259            }
30260        });
30261
30262        modal.on('change', 'select[name="due_date"]', function() {
30263            modal.find('select[name="due_date"]').parent().parent().find('.due-date-error').remove();
30264            modal.find('.make-to-order-row button').removeClass('error-box');
30265            if($(this).val() == '') {
30266                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>
30266발송 예정일을 선택해 주세요.</div>');
30267                modal.find('.make-to-order-row button').addClass('error-box');
30268            }
30269        });
30270
30271        modal.on('click', '.btn-delete-condition-row', function() {
30272            var btn = this;
30273            var modal = $(this).showModalFlat('배송비 조건 구간 삭제', '선택한 배송비 조건 구간을 삭제하시겠습니까?', true, true, function() {
30274                $(btn).closest('tr').remove();
30275                modal.modal('hide');
30276            }, 'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p130');
30277            var backdrop_z_index = Number(modal.css('zIndex'));
30278            modal.css('zIndex', backdrop_z_index + 1);
30279            modal.parent().next('.modal-backdrop').css('zIndex', backdrop_z_index);
30280        }); 
30281
30282        modal.find('[data-toggle="popover"]').popover();
30283
30284        modal.find('select').selectpicker();
30285
30286        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>');
30287        modal.find('.delivery-company-row').find('[data-toggle="popover"]').popover();
30288        modal.find('select[name="delivery_company"]').on('shown.bs.select changed.bs.select', function(select_event, dropdown_event) {
30289            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>');
30290            modal.find('.delivery-company-row').find('[data-toggle="popover"]').popover();
30291            // if(select_event.type == 'shown') {
30292            //     var select = select_event.target;
30293            //     var dropdown = dropdown_event.target;
30294            //     var selected_text = $(select).find('option:selected').text();
30295            //     // console.log(dropdown);
30296            //     var target = $(dropdown).find('li').filter(function() { return $(this).find('span.text').text() == selected_text});
30297            //     var pos = $(target).offset().top;
30298            //     $(dropdown).find('.inner').scrollTop($(dropdown).find('.inner').scrollTop() + pos);
30299            // }
30300        });
30301
30302    });
30303}
30304
30305function convertDateString(input) {
30306    const regex = /(\d{4})년 (\d{2})월 (\d{2})일 (오전|오후) (\d{2}):(\d{2})/;
30307    const match = input.match(regex);
30308    if (!match) return "";
30309
30310    let [_, year, month, day, period, hour, minute] = match;
30311    return `${year}-${month}-${day} ${hour}:${minute}`;
30312}
30313
30314// var calendarDateTimePicker = function(id, type, se, fulltime) {
30315//     console.log('id: ' + id +', type: ' + type + ', se: ' + se + ', fulltime: ' + fulltime);
30316//     // if(typeof id === undefined || !id) {
30317//     //     return false;
30318//     // }
30319//     var sid = (typeof property != 'undefined') ? property.SID : SID;
30320//     var blocklang = LANG;
30321//     var field_setting = {};
30322//     var etcDateState = 'N';
30323
30324//     //기본값
30325//     $default_term = {
30326//         'select_terms' : 'N',
30327//         'start_date' : '',
30328//         'end_date' : '',
30329//         'date_week' : 'A',
30330//         'days' : 'sun|mon|tue|wed|thu|fri|sat',
30331//     };
30332//     $default_excludeDate = {'date' : ''};
30333//     $default_time = {
30334//         'interval' : '30',
30335//         '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',
30336//         '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'
30337//     };
30338//     $default_color = {'highlight' : '4789e7'};
30339
30340//     field_setting = {
30341//         'term' : $default_term,
30342//         'excludeDate' : $default_excludeDate,
30343//         'time' : $default_time,
30344//         'color' : $default_color,
30345//     };
30346
30347//     var term = (field_setting.term)? field_setting.term:{};
30348//     var excludeDate = (field_setting.excludeDate)? field_setting.excludeDate:{};
30349//     var time = (type != 'date' && field_setting.time)? field_setting.time:{};
30350//     var color = (field_setting.color)? field_setting.color:{};
30351
30352//     var startDate = (term.start_date !== undefined)? term.start_date:'';
30353//     var endDate = (term.end_date !== undefined)? term.end_date:'';
30354//     var dateWeek = (term.date_week !== undefined)? term.date_week:'';
30355//     var days = (term.days !== undefined)? term.days.split('|'):[];
30356//     var daysObj = {
30357//         'sun': 0,
30358//         'mon': 1,
30359//         'tue': 2,
30360//         'wed': 3,
30361//         'thu': 4,
30362//         'fri': 5,
30363//         'sat': 6,
30364//     }
30365
30366//     //excludeDate
30367//     var exceptDate = (excludeDate.date !== undefined)? excludeDate.date.split(','):[];
30368
30369//     //time
30370//     var interval = (time.interval!==undefined)? time.interval:'30';
30371//     var am = (time.am!==undefined && time.am)? time.am.split('|'):[];
30372//     var pm = (time.pm!==undefined && time.pm)? time.pm.split('|'):[];
30373    
30374//     var disabled = null;
30375//     if(term.select_terms == 'Y') {
30376//         if(dateWeek == 'W') {
30377//             disabled = [0, 6];
30378//         } else if(dateWeek == 'K') {
30379//             disabled = [1, 2, 3, 4, 5];
30380//         }
30381//         if(days.length > 0) {
30382//             disabled = [0, 1, 2, 3, 4, 5, 6];
30383//             $.each(days, function(i, v){
30384//                 enableIdx = disabled.indexOf(daysObj[v]);
30385//                 if(enableIdx > -1) {
30386//                     disabled.splice(enableIdx, 1);
30387//                 }
30388//             });
30389//         }
30390//     }
30391//     var modal_title = (!fulltime) ? $.lang[blocklang]['config.form.date2.select'] : $.lang[blocklang]['config.form.date.select'];
30392//     var modal_str = '\
30393//         <div class="term-calendar-box form-calendar-box" data-type="'+type+'">\
30394//             <input type="hidden" id="select-calendar" value="term-datepicker">\
30395//             <input type="hidden" id="etc-start-date-txt" value="'+startDate+'">\
30396//             <input type="hidden" id="etc-end-date-txt" value="'+endDate+'">\
30397//             <input type="hidden" id="etc-date-week" value="'+dateWeek+'">\
30398//             <input type="hidden" id="etc-except-date" value="'+exceptDate+'">\
30399//             <input type="hidden" id="select-date-ymd">\
30400//             <div id="form-date2-datepicker-'+id+'"></div>\
30401//         </div>';
30402//     if(!fulltime) {
30403//         modal_str+='\
30404//             <div class="setting-row">\
30405//                 <div class="setting-label am">'+$.lang[blocklang]['config.form.date2.time.am']+'</div>\
30406//                 <div class="display-flex time-interval" data-time="am"></div>\
30407//             </div>\
30408//             <div class="setting-row">\
30409//                 <div class="setting-label pm">'+$.lang[blocklang]['config.form.date2.time.pm']+'</div>\
30410//                 <div class="display-flex time-interval" data-time="pm"></div>\
30411//             </div>';
30412//     }
30413    
30414//     if($('#etc-status').val() == 'P') {
30415//         modal_str+='\
30416//         <div class="term-setting hide" data-blocklang="'+blocklang+'">\
30417//             <span class="start-date"></span> ~ <span class="end-date"></span><span class="time"></span>\
30418//         </div>';
30419//     } else {
30420//         modal_str+='\
30421//         <div class="term-setting hide" data-blocklang="'+blocklang+'"></div>';
30422//     }
30423    
30424
30425//     var modal_class = 'modal-dialog cl-cmmodal cl-s-btn form-date2 cl-close-btn cover';
30426//     var etcText = '';
30427//     var dateTimeModal = $(this).showModalFlat(modal_title, modal_str, true, true, function () { //confirm
30428//         var datePick = $('.term-setting').text();
30429//         if(!fulltime) {
30430//             if(datePick == '') {
30431//                 alert('날짜와 시간을 선택해 주세요');
30432//                 return false;
30433//             } else {
30434//                 $('.userEL'+id).find('.calendar-modal-body .modal-field.'+se+' input').val(convertDateString(datePick));
30435//             }
30436//         } else {
30437//             var d = $('#select-date-ymd').val();
30438//             if(d == '') {
30439//                 alert('날짜를 선택해 주세요');
30440//                 return false;
30441//             }
30442//             var dp = d.replaceAll('.', '-');
30443//             $('.userEL'+id).find('.calendar-modal-body .modal-field.'+se+' input').val(dp);
30444//         }
30445
30446//         var $body = $('.userEL'+id).find('.calendar-modal-body');
30447//         var sVal = $body.find('.modal-field.sdate input').val() || '';
30448//         var eVal = $body.find('.modal-field.edate input').val() || '';
30449//         var pass = 'N';
30450
30451//         var rx = /^\d{4}-\d{2}-\d{2}( \d{2}:\d{2})?$/;
30452
30453//         var sOk = rx.test(sVal), eOk = rx.test(eVal);
30454//         if (sOk && eOk) {
30455//             var sStr = (sVal.length === 10) ? (sVal + ' 00:00') : sVal;
30456//             var eStr = (eVal.length === 10) ? (eVal + ' 00:00') : eVal;
30457//             var sDate = new Date(sStr.replace(' ', 'T'));
30458//             var eDate = new Date(eStr.replace(' ', 'T'));
30459
30460//             if (isFinite(sDate) && isFinite(eDate) && sDate <= eDate) {
30461//                 pass = 'Y';
30462//         }
30463//         }
30464
30465//         $body.find('.pass').val(pass).trigger('change');
30466
30467//         dateTimeModal.modal('hide');
30468//     },$.lang[blocklang]['config.cancel'],$.lang[blocklang]['config.ok'], modal_class, true, '', function() { //show
30469//         var currentYear = new Date().getFullYear();
30470//         var termPicker = new Datepickk({
30471//             container: document.querySelector('#form-date2-datepicker-'+id),
30472//             inline:true,
30473//             today:true,
30474//             range: ((type == 'etc-product-date' || type == 'etc-product-datetime') && $('#etc-status').val() == 'P')? true : false,
30475//             disabledDays: disabled,
30476//             lang: blocklang,
30477//             minDate: new Date(1900, 0, 1),
30478//             maxDate: new Date(currentYear + 15, 11, 31),
30479//         });
30480
30481//         if(type.indexOf('etc-product-date') > -1) {
30482//             startDate = $('#etc-min-date').val();
30483//             endDate = $('#etc-max-date').val();
30484//         }
30485
30486//         if(exceptDate) {
30487//             var disabledDateArr = new Array();
30488//             $.each(exceptDate, function(idx, item){
30489//                 item = item.replace(/\./g,'/'); //date for firefox
30490//                 disabledDateArr.push(new Date(item));
30491//             });
30492//             termPicker.disabledDates = disabledDateArr;
30493//         }
30494        
30495//         if(startDate && endDate) {
30496//             var checkStartDate = startDate.split('.');
30497//             var checkEndDate = endDate.split('.');
30498//             termPicker.minDate = new Date(checkStartDate[0], (checkStartDate[1] * 1) - 1, checkStartDate[2]);
30499//             termPicker.maxDate = new Date(checkEndDate[0], (checkEndDate[1] * 1) - 1, checkEndDate[2]);
30500//         }
30501
30502//         $(document).off('click', '.d-year, .d-month');
30503//         $(document).on('click', '.d-year, .d-month', function(){
30504//             $('.d-month-year-picker').toggleClass('d-show');
30505//             scrollToCurrentYearMonth();
30506//         });
30507
30508//         $('#datetime-style-'+id).remove();
30509//         var highlight = '#'+color.highlight;
30510//         var h_rgba = hexToRgba(highlight);
30511//         var rgba_str = h_rgba.r+','+h_rgba.g+','+h_rgba.b;
30512//         var style = '\
30513//             <style id="datetime-style-'+id+'">\
30514//                 .form-date2 .Datepickk .d-table input:not(:disabled):not(:checked) + label:hover:before{border: 1px solid '+highlight+'; background-color: transparent;}\
30515//                 .form-date2 .Datepickk .d-table input:not(:disabled) + label:hover:before{border: 1px solid '+highlight+'; background-color: transparent;}\
30516//                 .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+';}\
30517//                 .form-date2 .time-interval input:checked + label {color: '+highlight+'; border: 1px solid '+highlight+';}\
30518//                 .form-date2 .time-interval label{background-color: rgba('+rgba_str+', 0.05); border: 1px solid rgba('+rgba_str+', 0.1);}\
30519//                 .form-date2 .term-setting{background-color: rgba('+rgba_str+', 0.05);}\
30520//             </style>\
30521//             ';
30522//         $('.cl-cmmodal.form-date2').append(style);
30523        
30524//         dateTimeModal.find('.time-interval').each(function(i, v){
30525//             var mna = $(v).data('time');
30526//             var times = '';
30527
30528//             if(mna === 'am') {
30529//                 for(let t = 0; t <= 11; t++) {
30530//                     let hstr = t.toString().padStart(2, '0');
30531//                     times += '\
30532//                         <input type="checkbox" id="'+mna+'-'+t+'-00" class="o-time hide" name="'+mna+'" value="'+mna+' '+hstr+':00" data-setting_time="'+hstr+'00">\
30533//                         <label for="'+mna+'-'+t+'-00" class="o-time">'+hstr+':00</label>\
30534//                         <input type="checkbox" id="'+mna+'-'+t+'-30" class="ten-time half-time hide" name="'+mna+'" value="'+mna+' '+hstr+':30" data-setting_time="'+hstr+'30">\
30535//                         <label for="'+mna+'-'+t+'-30" class="ten-time half-time">'+hstr+':30</label>\
30536//                     ';
30537//                 }
30538//             }
30539
30540//             if(mna === 'pm') {
30541//                 for(let t = 12; t <= 23; t++) {
30542//                     let hstr = t.toString();
30543//                     times += '\
30544//                         <input type="checkbox" id="'+mna+'-'+t+'-00" class="o-time hide" name="'+mna+'" value="'+mna+' '+hstr+':00" data-setting_time="'+hstr+'00">\
30545//                         <label for="'+mna+'-'+t+'-00" class="o-time">'+hstr+':00</label>\
30546//                         <input type="checkbox" id="'+mna+'-'+t+'-30" class="ten-time half-time hide" name="'+mna+'" value="'+mna+' '+hstr+':30" data-setting_time="'+hstr+'30">\
30547//                         <label for="'+mna+'-'+t+'-30" class="ten-time half-time">'+hstr+':30</label>\
30548//                     ';
30549//                 }
30550//             }
30551
30552//             $(v).html(times);
30553//         });
30554        
30555//         dateTimeModal.find('.time-interval input').prop('disabled', true);
30556        
30557//         if(am.length > 0) {
30558//             $.each(am, function(i, v){
30559//                 dateTimeModal.find('.time-interval[data-time="am"] input[data-setting_time="'+v+'"]').prop('disabled', false);
30560//             });
30561//         }
30562
30563//         if(pm.length > 0) {
30564//             $.each(pm, function(i, v){
30565//                 dateTimeModal.find('.time-interval[data-time="pm"] input[data-setting_time="'+v+'"]').prop('disabled', false);
30566//             });
30567//         }
30568        
30569//         dateTimeModal.find('.time-interval label:not(.o-time)').addClass('hide');
30570        
30571//         switch (interval) {
30572//             case '10':
30573//                 dateTimeModal.find('.time-interval label').removeClass('hide');
30574//                 break;
30575//             case '20':
30576//                 dateTimeModal.find('.time-interval label.twt-time').removeClass('hide');
30577//                 break;
30578//             case '30':
30579//                 dateTimeModal.find('.time-interval label.half-time').removeClass('hide');
30580//                 break;
30581//         }
30582
30583//         let $enableTimes = dateTimeModal.find('.time-interval[data-time] input:not(:disabled) + label').not('.hide');
30584//         let $enableTimesAM = dateTimeModal.find('.time-interval[data-time="am"] input:not(:disabled) + label').not('.hide');
30585//         let $enableTimesPM = dateTimeModal.find('.time-interval[data-time="pm"] input:not(:disabled) + label').not('.hide');
30586
30587//         $enableTimes.first().prevAll('label').addClass('hide');
30588//         $enableTimes.last().nextAll('label').addClass('hide');
30589
30590//         if($enableTimesAM.length == 0) {
30591//             $('.setting-label.am').addClass('hide');
30592//             $('.time-interval[data-time="am"]').addClass('hide');
30593//         }
30594//         if($enableTimesPM.length == 0) {
30595//             $('.setting-label.pm').addClass('hide');
30596//             $('.time-interval[data-time="pm"]').addClass('hide');
30597//         }
30598
30599//         dateTimeModal.find('.time-interval input').on('change', function(){
30600//             $('.time-interval input').prop('checked', false);
30601//             $(this).prop('checked', true);
30602            
30603//             if(type == 'etc-product-datetime') {
30604//                 if($('#etc-status').val() == 'P') {
30605//                     if(!$('#etc-start-date-txt').val() || !$('#etc-end-date-txt').val()) return false;
30606//                 } else {
30607//                     if(!$('#etc-start-date-txt').val()) return false;
30608//                 }
30609//             }
30610
30611//             getDateTimeStr(blocklang);
30612//         });
30613
30614//         if(type.indexOf('etc-product-date') > -1 && $('#etc-start-date-option').val()) { //etc product
30615//             if($('#etc-status').val() == 'P') { //기간
30616//                 document.querySelector('#etc-start-date-txt').value = document.querySelector('#etc-start-date-option').value;
30617//                 document.querySelector('#etc-end-date-txt').value = document.querySelector('#etc-end-date').value;
30618//                 document.querySelector('#select-date-ymd').value = document.querySelector('#etc-start-date-option').value + '|' + document.querySelector('#etc-end-date').value
30619//                 termPicker.startDate = $('#etc-start-date-option').val();
30620//                 termPicker.endDate = $('#etc-end-date').val();
30621//             } else {
30622//                 document.querySelector('#etc-start-date-txt').value = document.querySelector('#etc-start-date-option').value;
30623//                 document.querySelector('#select-date-ymd').value = document.querySelector('#etc-start-date-option').value;
30624//                 var sDate = $('#etc-start-date-option').val();
30625//                 var sDateObj = new Date(sDate);
30626//                 termPicker.selectDate(sDateObj);
30627//             }
30628
30629//             if($('#etc-time').val()) {
30630//                 var sTime = $('#etc-time').val();
30631//                 $('.time-interval input[value="'+sTime+'"]').prop('checked', true);
30632//             }
30633            
30634//             setTimeout(function(){
30635//                 getDateTimeStr('ko')
30636//             }, 500);
30637//         }
30638//     });
30639// }
30640
30641var formDateTimePicker = function(id, type) {
30642    if(typeof id === undefined || !id) {
30643        return false;
30644    }
30645    var sid = (typeof property != 'undefined') ? property.SID : SID;
30646    var blocklang = ($('[form-seq="'+id+'"]').closest('.element').attr('data-blocklang'))? $('[form-seq="'+id+'"]').closest('.element').attr('data-blocklang'):LANG;
30647    var field_setting = {};
30648    var etcDateState = 'N';
30649
30650    if(type == 'etc-product-date' || type == 'etc-product-datetime') {
30651        blocklang = LANG;
30652        etcDateState = $('#etc-state').val();
30653        field_setting.term = JSON.parse($('#etc-term-setting').val());
30654        field_setting.excludeDate = {'date': $('#etc-exclude-date').val()};
30655        if(type == 'etc-product-datetime') field_setting.time = JSON.parse($('#etc-time-setting').val());
30656    } else {
30657        $.ajax({
30658            url: '/template/forms/field_config',
30659            dataType: 'json',
30660            type: 'POST',
30661            data:  { sid: sid, id : id },
30662            async: false,
30663            cache: false,
30664            success: function(data) {
30665                checkError(data);
30666                field_setting = data;
30667            }
30668        });
30669    }
30670
30671    var term = (field_setting.term)? field_setting.term:{};
30672    var excludeDate = (field_setting.excludeDate)? field_setting.excludeDate:{};
30673    var time = (type != 'date' && field_setting.time)? field_setting.time:{};
30674    var color = (field_setting.color)? field_setting.color:{};
30675
30676    var startDate = (term.start_date !== undefined)? term.start_date:'';
30677    var endDate = (term.end_date !== undefined)? term.end_date:'';
30678    var dateWeek = (term.date_week !== undefined)? term.date_week:'';
30679    var days = (term.days !== undefined)? term.days.split('|'):[];
30680    var daysObj = {
30681        'sun': 0,
30682        'mon': 1,
30683        'tue': 2,
30684        'wed': 3,
30685        'thu': 4,
30686        'fri': 5,
30687        'sat': 6,
30688    }
30689
30690    //excludeDate
30691    var exceptDate = (excludeDate.date !== undefined)? excludeDate.date.split(','):[];
30692
30693    //time
30694    if(type == 'date2' || type == 'etc-product-datetime') {
30695        var interval = (time.interval!==undefined)? time.interval:'30';
30696        var am = (time.am!==undefined && time.am)? time.am.split('|'):[];
30697        var pm = (time.pm!==undefined && time.pm)? time.pm.split('|'):[];
30698    }
30699    
30700    var disabled = null;
30701    if(term.select_terms == 'Y') {
30702        if(dateWeek == 'W') {
30703            disabled = [0, 6];
30704        } else if(dateWeek == 'K') {
30705            disabled = [1, 2, 3, 4, 5];
30706        }
30707        if(days.length > 0) {
30708            disabled = [0, 1, 2, 3, 4, 5, 6];
30709            $.each(days, function(i, v){
30710                enableIdx = disabled.indexOf(daysObj[v]);
30711                if(enableIdx > -1) {
30712                    disabled.splice(enableIdx, 1);
30713                }
30714            });
30715        }
30716    }
30717    var modal_title = (type == 'date2' || type == 'etc-product-datetime')? $.lang[blocklang]['config.form.date2.select'] : $.lang[blocklang]['config.form.date.select'];
30718    var modal_str = '\
30719        <div class="term-calendar-box form-calendar-box" data-type="'+type+'">\
30720            <input type="hidden" id="select-calendar" value="term-datepicker">\
30721            <input type="hidden" id="etc-start-date-txt" value="'+startDate+'">\
30722            <input type="hidden" id="etc-end-date-txt" value="'+endDate+'">\
30723            <input type="hidden" id="etc-date-week" value="'+dateWeek+'">\
30724            <input type="hidden" id="etc-except-date" value="'+exceptDate+'">\
30725            <input type="hidden" id="select-date-ymd">\
30726            <div id="form-date2-datepicker-'+id+'"></div>\
30727        </div>';
30728    if(type == 'etc-product-date' || type == 'etc-product-datetime') {
30729        modal_str = '\
30730        <div class="term-calendar-box form-calendar-box" data-type="'+type+'">\
30731            <input type="hidden" id="select-calendar" value="term-datepicker">\
30732            <input type="hidden" id="etc-start-date-txt" value="">\
30733            <input type="hidden" id="etc-end-date-txt" value="">\
30734            <input type="hidden" id="etc-date-week" value="'+dateWeek+'">\
30735            <input type="hidden" id="etc-except-date" value="'+exceptDate+'">\
30736            <input type="hidden" id="select-date-ymd">\
30737            <div id="form-date2-datepicker-'+id+'"></div>\
30738        </div>';
30739    }
30740    if(type == 'date2' || type == 'etc-product-datetime') {
30741        modal_str+='\
30742        <div class="setting-row">\
30743            <div class="setting-label am">'+$.lang[blocklang]['config.form.date2.time.am']+'</div>\
30744            <div class="display-flex time-interval" data-time="am"></div>\
30745        </div>\
30746        <div class="setting-row">\
30747            <div class="setting-label pm">'+$.lang[blocklang]['config.form.date2.time.pm']+'</div>\
30748            <div class="display-flex time-interval" data-time="pm"></div>\
30749        </div>';
30750    
30751    }
30752    if($('#etc-status').val() == 'P') {
30753        modal_str+='\
30754        <div class="term-setting hide" data-blocklang="'+blocklang+'">\
30755            <span class="start-date"></span> ~ <span class="end-date"></span><span class="time"></span>\
30756        </div>';
30757    } else {
30758        modal_str+='\
30759        <div class="term-setting hide" data-blocklang="'+blocklang+'"></div>';
30760    }
30761    
30762
30763    var modal_class = 'modal-dialog cl-cmmodal cl-s-btn form-date2 
30763cl-close-btn cover';
30764    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';
30765    var etcText = '';
30766    var dateTimeModal = $(this).showModalFlat(modal_title, modal_str, true, true, function () { //confirm
30767        //input value
30768        var $formDateYmd = $('[form-seq="'+id+'"] .date-ymd');
30769        var isFranchiseBar = ($formDateYmd.closest('[data-type="contact"][data-type2="franchise bar"]').length > 0);
30770        $formDateYmd.attr('data-select_date', $('#select-date-ymd').val());
30771        var dateVal = ($('#select-date-ymd').val() && $('.term-setting').text())? true : false;
30772        switch(type) {
30773            case 'date2':
30774                if(dateVal) {
30775                    $formDateYmd.attr('data-select_time', $('.time-interval input:checked').attr('id'));
30776                    $formDateYmd.val($('.term-setting').text());
30777                    if(isFranchiseBar) {
30778                        $formDateYmd.removeAttr('style');
30779                    } else {
30780                        $formDateYmd.css('width', '240px');
30781                    }
30782                } else {
30783                    alert($.lang[blocklang]['config.form.date2.notSelected']);
30784                    return false;
30785                }
30786                break;
30787            case 'etc-product-date':
30788                if(dateVal) {
30789                    if($('#etc-status').val() == 'P') {
30790                        var selectedDate = $('#select-date-ymd').val().split('|');
30791
30792                        $('.option-body #etc-start-date-option').val(selectedDate[0]);
30793                        $('.modal-cart-option-change #etc-start-date-option').val(selectedDate[0]);
30794                        $('input[name="change_option_start_date"]').val(selectedDate[0]);
30795
30796                        $('.option-body #etc-end-date').val(selectedDate[1]);
30797                        $('.modal-cart-option-change #etc-end-date').val(selectedDate[1]);
30798                        $('input[name="change_option_end_date"]').val(selectedDate[1]);
30799
30800                        etcText = selectedDate[0] + ' - ' + selectedDate[1];
30801                    } else {
30802                        var selectedDate = $('#select-date-ymd').val();
30803                        $('.option-body #etc-start-date-option').val(selectedDate);
30804                        $('.modal-cart-option-change #etc-start-date-option').val(selectedDate);
30805                        $('input[name="change_option_start_date"]').val(selectedDate);
30806                        etcText = selectedDate;
30807                    }
30808
30809                    $('#etc-date-text').text(etcText);
30810                    console.log(etcText);
30811                } else {
30812                    alert('날짜를 선택해 주세요.');
30813                    return false;
30814                }
30815                break;
30816            case 'etc-product-datetime':
30817                if(!dateTimeModal.find('.time-interval input:checked').val() || !dateVal) {
30818                    alert('날짜와 시간을 선택해 주세요.');
30819                    return false;
30820                }
30821                if(dateVal) {
30822                    $('.option-body #etc-time').val($('.time-interval input:checked').val());
30823                    $('.modal-cart-option-change #etc-time').val($('.time-interval input:checked').val());
30824                    if($('#etc-status').val() == 'P') {
30825                        var selectedDate = $('#select-date-ymd').val().split('|');
30826
30827                        $('.option-body #etc-start-date-option').val(selectedDate[0]);
30828                        $('.modal-cart-option-change #etc-start-date-option').val(selectedDate[0]);
30829                        $('input[name="change_option_start_date"]').val(selectedDate[0]);
30830
30831                        $('.option-body #etc-end-date').val(selectedDate[1]);
30832                        $('.modal-cart-option-change #etc-end-date').val(selectedDate[1]);
30833                        $('input[name="change_option_end_date"]').val(selectedDate[1]);
30834
30835                        etcText = selectedDate[0] + ' - ' + selectedDate[1];
30836                    } else {
30837                        var selectedDate = $('#select-date-ymd').val();
30838                        $('.option-body #etc-start-date-option').val(selectedDate);
30839                        $('.modal-cart-option-change #etc-start-date-option').val(selectedDate);
30840                        $('input[name="change_option_start_date"]').val(selectedDate);
30841                        etcText = selectedDate;
30842                    }
30843
30844                    if($('#etc-time').val()) {
30845                        var etcTime = $('#etc-time').val().split(' ');
30846                        if(etcTime[0] == 'am') {
30847                            etcText += (' 오전 ' + etcTime[1]);
30848                        } else {
30849                            etcText += (' 오후 ' + etcTime[1]);
30850                        }
30851                    }
30852
30853                    $('#etc-date-text').text(etcText);
30854                }
30855                break;
30856            default:
30857                if(dateVal) {
30858                    $formDateYmd.val($('.term-setting').text());
30859                } else {
30860                    alert($.lang[blocklang]['config.form.date.notSelected']);
30861                    return false;
30862                }
30863                break;
30864        }
30865        
30866        if(type == 'etc-product-date' || type == 'etc-product-datetime') {
30867            if ($('.cl-s-normal-option-selector').length <= 0) {
30868                var quantity = $('#product-quantity').val();
30869                var price = $('#product_c_price').val();
30870                var option = document.createElement('div');
30871                console.log(etcText + '||0||' + quantity);
30872                $(option).attr('data-val', etcText + '||0||' + quantity);
30873                productOptionPick(option, price, 'etc_none_option');
30874            }
30875        }
30876        
30877        //old
30878        if($('[form-seq="'+id+'"] .date-yyyy').length > 0) {
30879            var selectedDate = $('#select-date-ymd').val();
30880            var dateArr = selectedDate.split('.');
30881            $('[form-seq="'+id+'"] .date-yyyy').val(dateArr[0]);
30882            $('[form-seq="'+id+'"] .date-mm').val(dateArr[1]);
30883            $('[form-seq="'+id+'"] .date-dd').val(dateArr[2]);
30884
30885            if($('[form-seq="'+id+'"] .date-hh').length > 0) {
30886                var checkedTime = $('.time-interval input:checked').val();
30887                var timeArr = checkedTime.replace(/am |pm /g, '').split(':');
30888                var hh = timeArr[0];
30889                var ii = timeArr[1];
30890
30891                if(checkedTime.indexOf('pm') > -1) {
30892                    hh = (timeArr[0] == '12')? timeArr[0] : Number(timeArr[0])+12;
30893                }
30894
30895                $('[form-seq="'+id+'"] .date-hh').val(hh);
30896                $('[form-seq="'+id+'"] .date-ii').val(ii);
30897            }
30898        } 
30899        dateTimeModal.modal('hide');
30900    },$.lang[blocklang]['config.cancel'],$.lang[blocklang]['config.ok'], modal_class, true, '', function() { //show
30901        var currentYear = new Date().getFullYear();
30902        var termPicker = new Datepickk({
30903            container: document.querySelector('#form-date2-datepicker-'+id),
30904            inline:true,
30905            today:true,
30906            range: ((type == 'etc-product-date' || type == 'etc-product-datetime') && $('#etc-status').val() == 'P')? true : false,
30907            disabledDays: disabled,
30908            lang: blocklang,
30909            minDate: new Date(1900, 0, 1),
30910            maxDate: new Date(currentYear + 15, 11, 31),
30911        });
30912
30913        if(type.indexOf('etc-product-date') > -1) {
30914            startDate = $('#etc-min-date').val();
30915            endDate = $('#etc-max-date').val();
30916        }
30917
30918        if(exceptDate) {
30919            var disabledDateArr = new Array();
30920            $.each(exceptDate, function(idx, item){
30921                item = item.replace(/\./g,'/'); //date for firefox
30922                disabledDateArr.push(new Date(item));
30923            });
30924            termPicker.disabledDates = disabledDateArr;
30925        }
30926        
30927        if(startDate && endDate) {
30928            var checkStartDate = startDate.split('.');
30929            var checkEndDate = endDate.split('.');
30930            termPicker.minDate = new Date(checkStartDate[0], (checkStartDate[1] * 1) - 1, checkStartDate[2]);
30931            termPicker.maxDate = new Date(checkEndDate[0], (checkEndDate[1] * 1) - 1, checkEndDate[2]);
30932        }
30933
30934        $(document).off('click', '.d-year, .d-month');
30935        $(document).on('click', '.d-year, .d-month', function(){
30936            $('.d-month-year-picker').toggleClass('d-show');
30937            scrollToCurrentYearMonth();
30938        });
30939
30940        if((type=='date'||type=='date2') && color) {
30941            $('#datetime-style-'+id).remove();
30942            var highlight = '#'+color.highlight;
30943            var h_rgba = hexToRgba(highlight);
30944            var rgba_str = h_rgba.r+','+h_rgba.g+','+h_rgba.b;
30945            var style = '\
30946                <style id="datetime-style-'+id+'">\
30947                    .form-date2 .Datepickk .d-table input:not(:disabled):not(:checked) + label:hover:before{border: 1px solid '+highlight+'; background-color: transparent;}\
30948                    .form-date2 .Datepickk .d-table input:not(:disabled) + label:hover:before{border: 1px solid '+highlight+'; background-color: transparent;}\
30949                    .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+';}\
30950                    .form-date2 .time-interval input:checked + label {color: '+highlight+'; border: 1px solid '+highlight+';}\
30951                    .form-date2 .time-interval label{background-color: rgba('+rgba_
30951str+', 0.05); border: 1px solid rgba('+rgba_str+', 0.1);}\
30952                    .form-date2 .term-setting{background-color: rgba('+rgba_str+', 0.05);}\
30953                </style>\
30954             ';
30955            $('.cl-cmmodal.form-date2').append(style);
30956        }
30957        if(type == 'date2' || type == 'etc-product-datetime') {
30958            dateTimeModal.find('.time-interval').each(function(i, v){
30959                var mna = $(v).data('time');
30960                var times = '\
30961                    <input type="checkbox" id="'+mna+'-12-00" class="o-time hide" name="'+mna+'" value="'+mna+' 12:00" data-setting_time="1200">\
30962                    <label for="'+mna+'-12-00" class="o-time">12:00</label>\
30963                    <input type="checkbox" id="'+mna+'-12-10" class="ten-time hide" name="'+mna+'" value="'+mna+' 12:10" data-setting_time="1210">\
30964                    <label for="'+mna+'-12-10" class="ten-time">12:10</label>\
30965                    <input type="checkbox" id="'+mna+'-12-20" class="ten-time twt-time hide" name="'+mna+'" value="'+mna+' 12:20" data-setting_time="1220">\
30966                    <label for="'+mna+'-12-20" class="ten-time twt-time">12:20</label>\
30967                    <input type="checkbox" id="'+mna+'-12-30" class="ten-time half-time hide" name="'+mna+'" value="'+mna+' 12:30" data-setting_time="1230">\
30968                    <label for="'+mna+'-12-30" class="ten-time half-time">12:30</label>\
30969                    <input type="checkbox" id="'+mna+'-12-40" class="ten-time twt-time hide" name="'+mna+'" value="'+mna+' 12:40" data-setting_time="1240">\
30970                    <label for="'+mna+'-12-40" class="ten-time twt-time">12:40</label>\
30971                    <input type="checkbox" id="'+mna+'-12-50" class="ten-time hide" name="'+mna+'" value="'+mna+' 12:50" data-setting_time="1250">\
30972                    <label for="'+mna+'-12-50" class="ten-time">12:50</label>\
30973                    \
30974                    ';
30975                    for(let t = 1; t <= 11; t++) {
30976                        let hstr = t.toString().padStart(2, '0');
30977                        times += '\
30978                            <input type="checkbox" id="'+mna+'-'+t+'-00" class="o-time hide" name="'+mna+'" value="'+mna+' '+hstr+':00" data-setting_time="'+hstr+'00">\
30979                            <label for="'+mna+'-'+t+'-00" class="o-time">'+t+':00</label>\
30980                            <input type="checkbox" id="'+mna+'-'+t+'-10" class="ten-time hide" name="'+mna+'" value="'+mna+' '+hstr+':10" data-setting_time="'+hstr+'10">\
30981                            <label for="'+mna+'-'+t+'-10" class="ten-time">'+t+':10</label>\
30982                            <input type="checkbox" id="'+mna+'-'+t+'-20" class="ten-time twt-time hide" name="'+mna+'" value="'+mna+' '+hstr+':20" data-setting_time="'+hstr+'20">\
30983                            <label for="'+mna+'-'+t+'-20" class="ten-time twt-time">'+t+':20</label>\
30984                            <input type="checkbox" id="'+mna+'-'+t+'-30" class="ten-time half-time hide" name="'+mna+'" value="'+mna+' '+hstr+':30" data-setting_time="'+hstr+'30">\
30985                            <label for="'+mna+'-'+t+'-30" class="ten-time half-time">'+t+':30</label>\
30986                            <input type="checkbox" id="'+mna+'-'+t+'-40" class="ten-time twt-time hide" name="'+mna+'" value="'+mna+' '+hstr+':40" data-setting_time="'+hstr+'40">\
30987                            <label for="'+mna+'-'+t+'-40" class="ten-time twt-time">'+t+':40</label>\
30988                            <input type="checkbox" id="'+mna+'-'+t+'-50" class="ten-time hide" name="'+mna+'" value="'+mna+' '+hstr+':50" data-setting_time="'+hstr+'50">\
30989                            <label for="'+mna+'-'+t+'-50" class="ten-time">'+t+':50</label>\
30990                        ';
30991                    }
30992                    // times += '\
30993                    // <input type="checkbox" id="'+mna+'-1-00" class="hide" name="'+mna+'" value="'+mna+' 01:00" data-setting_time="0100">\
30994                    // <label for="'+mna+'-1-00">1:00</label>\
30995                    // <input type="checkbox" id="'+mna+'-1-30" class="half-time hide" name="'+mna+'" value="'+mna+' 01:30" data-setting_time="0130">\
30996                    // <label for="'+mna+'-1-30" class="half-time">1:30</label>\
30997                    // \
30998                    // <input type="checkbox" id="'+mna+'-2-00" class="hide" name="'+mna+'" value="'+mna+' 02:00" data-setting_time="0200">\
30999                    // <label for="'+mna+'-2-00">2:00</label>\
31000                    // <input type="checkbox" id="'+mna+'-2-30" class="half-time hide" name="'+mna+'" value="'+mna+' 02:30" data-setting_time="0230">\
31001                    // <label for="'+mna+'-2-30" class="half-time">2:30</label>\
31002                    // \
31003                    // <input type="checkbox" id="'+mna+'-3-00" class="hide" name="'+mna+'" value="'+mna+' 03:00" data-setting_time="0300">\
31004                    // <label for="'+mna+'-3-00">3:00</label>\
31005                    // <input type="checkbox" id="'+mna+'-3-30" class="half-time hide" name="'+mna+'" value="'+mna+' 03:30" data-setting_time="0330">\
31006                    // <label for="'+mna+'-3-30" class="half-time">3:30</label>\
31007                    // \
31008                    // <input type="checkbox" id="'+mna+'-4-00" class="hide" name="'+mna+'" value="'+mna+' 04:00" data-setting_time="0400">\
31009                    // <label for="'+mna+'-4-00">4:00</label>\
31010                    // <input type="checkbox" id="'+mna+'-4-30" class="half-time hide" name="'+mna+'" value="'+mna+' 04:30" data-setting_time="0430">\
31011                    // <label for="'+mna+'-4-30" class="half-time">4:30</label>\
31012                    // \
31013                    // <input type="checkbox" id="'+mna+'-5-00" class="hide" name="'+mna+'" value="'+mna+' 05:00" data-setting_time="0500">\
31014                    // <label for="'+mna+'-5-00">5:00</label>\
31015                    // <input type="checkbox" id="'+mna+'-5-30" class="half-time hide" name="'+mna+'" value="'+mna+' 05:30" data-setting_time="0530">\
31016                    // <label for="'+mna+'-5-30" class="half-time">5:30</label>\
31017                    // \
31018                    // <input type="checkbox" id="'+mna+'-6-00" class="hide" name="'+mna+'" value="'+mna+' 06:00" data-setting_time="0600">\
31019                    // <label for="'+mna+'-6-00">6:00</label>\
31020                    // <input type="checkbox" id="'+mna+'-6-30" class="half-time hide" name="'+mna+'" value="'+mna+' 06:30" data-setting_time="0630">\
31021                    // <label for="'+mna+'-6-30" class="half-time">6:30</label>\
31022                    // \
31023                    // <input type="checkbox" id="'+mna+'-7-00" class="hide" name="'+mna+'" value="'+mna+' 07:00" data-setting_time="0700">\
31024                    // <label for="'+mna+'-7-00">7:00</label>\
31025                    // <input type="checkbox" id="'+mna+'-7-30" class="half-time hide" name="'+mna+'" value="'+mna+' 07:30" data-setting_time="0730">\
31026                    // <label for="'+mna+'-7-30" class="half-time">7:30</label>\
31027                    // \
31028                    // <input type="checkbox" id="'+mna+'-8-00" class="hide" name="'+mna+'" value="'+mna+' 08:00" data-setting_time="0800">\
31029                    // <label for="'+mna+'-8-00">8:00</label>\
31030                    // <input type="checkbox" id="'+mna+'-8-30" class="half-time hide" name="'+mna+'" value="'+mna+' 08:30" data-setting_time="0830">\
31031                    // <label for="'+mna+'-8-30" class="half-time">8:30</label>\
31032                    // \
31033                    // <input type="checkbox" id="'+mna+'-9-00" class="hide" name="'+mna+'" value="'+mna+' 09:00" data-setting_time="0900">\
31034                    // <label for="'+mna+'-9-00">9:00</label>\
31035                    // <input type="checkbox" id="'+mna+'-9-30" class="half-time hide" name="'+mna+'" value="'+mna+' 09:30" data-setting_time="0930">\
31036                    // <label for="'+mna+'-9-30" class="half-time">9:30</label>\
31037                    // \
31038                    // <input type="checkbox" id="'+mna+'-10-00" class="hide" name="'+mna+'" value="'+mna+' 10:00" data-setting_time="1000">\
31039                    // <label for="'+mna+'-10-00">10:00</label>\
31040                    // <input type="checkbox" id="'+mna+'-10-30" class="half-time hide" name="'+mna+'" value="'+mna+' 10:30" data-setting_time="1030">\
31041                    // <label for="'+mna+'-10-30" class="half-time">10:30</label>\
31042                    // \
31043                    // <input type="checkbox" id="'+mna+'-11-00" class="hide" name="'+mna+'" value="'+mna+' 11:00" data-setting_time="1100">\
31044                    // <label for="'+mna+'-11-00">11:00</label>\
31045                    // <input type="checkbox" id="'+mna+'-11-30" class="half-time hide" name="'+mna+'" value="'+mna+' 11:30" data-setting_time="1130">\
31046                    // <label for="'+mna+'-11-30" class="half-time">11:30</label>\
31047                    // ';
31048                $(v).html(times);
31049            }); //end each
31050            
31051            dateTimeModal.find('.time-interval input').prop('disabled', true);
31052            
31053            if(am.length > 0) {
31054                $.each(am, function(i, v){
31055                    dateTimeModal.find('.time-interval[data-time="am"] input[data-setting_time="'+v+'"]').prop('disabled', false);
31056                });
31057            }
31058
31059            if(pm.length > 0) {
31060                $.each(pm, function(i, v){
31061                    dateTimeModal.find('.time-interval[data-time="pm"] input[data-setting_time="'+v+'"]').prop('disabled', false);
31062                });
31063            }
31064            
31065            dateTimeModal.find('.time-interval label:not(.o-time)').addClass('hide');
31066            console.log('interval', interval);
31067            switch (interval) {
31068                case '10':
31069                    dateTimeModal.find('.time-interval label').removeClass('hide');
31070                    break;
31071                case '20':
31072                    dateTimeModal.find('.time-interval label.twt-time').removeClass('hide');
31073                    break;
31074                case '30':
31075                    dateTimeModal.find('.time-interval label.half-time').removeClass('hide');
31076                    break;
31077            }
31078
31079            let $enableTimes = dateTimeModal.find('.time-interval[data-time] input:not(:disabled) + label').not('.hide');
31080            let $enableTimesAM = dateTimeModal.find('.time-interval[data-time="am"] input:not(:disabled) + label').not('.hide');
31081            let $enableTimesPM = dateTimeModal.find('.time-interval[data-time="pm"] input:not(:disabled) + label').not('.hide');
31082
31083            $enableTimes.first().prevAll('label').addClass('hide');
31084            $enableTimes.last().nextAll('label').addClass('hide');
31085
31086            if($enableTimesAM.length == 0) {
31087                $('.setting-label.am').addClass('hide');
31088                $('.time-interval[data-time="am"]').addClass('hide');
31089            }
31090            if($enableTimesPM.length == 0) {
31091                $('.setting-label.pm').addClass('hide');
31092                $('.time-interval[data-time="pm"]').addClass('hide');
31093            }
31094
31095            // var num = 1;
31096            // var length = 0;
31097            // dateTimeModal.find('.time-interval label').not('.hide').each(function(i, v){
31098            //     $(v).prev('input').addClass('row-'+num);
31099            //     if($(v).prev('input').prop('disabled')) {
31100            //         length++;
31101            //     }
31102
31103            //     if((i+1)%4 == 0) {
31104            //         if(length == 4) $('input.row-'+num+' + label').addClass('hide');
31105            //         length = 0;
31106            //         num ++;
31107            //     }
31108            // });
31109
31110            dateTimeModal.find('.time-interval input').on('change', function(){
31111                $('.time-interval input').prop('checked', false);
31112                $(this).prop('checked', true);
31113                
31114                if(type == 'etc-product-datetime') {
31115                    if($('#etc-status').val() == 'P') {
31116                        if(!$('#etc-start-date-txt').val() || !$('#etc-end-date-txt').val()) return false;
31117                    } else {
31118                        if(!$('#etc-start-date-txt').val()) return false;
31119                    }
31120                }
31121
31122                getDateTimeStr(blocklang);
31123            });
31124        } //date2
31125
31126        if($('[form-seq="'+id+'"] .date-ymd').val()) { //form
31127            var sDate = $('[form-seq="'+id+'"] .date-ymd').attr('data-select_date');
31128            var sDateObj = new Date(sDate);
31129            termPicker.currentDate  = sDateObj;
31130            termPicker.selectDate(sDateObj);
31131            $('#select-date-ymd').val(sDate);
31132            
31133            if(type == 'date2') {
31134                var sTime = $('[form-seq="'+id+'"] .date-ymd').attr('data-select_time');
31135                $('#'+sTime).prop('checked', true);
31136            }
31137            getDateTimeStr(blocklang);
31138        }
31139
31140        if(type.indexOf('etc-product-date') > -1 && $('#etc-start-date-option').val()) { //etc product
31141            if($('#etc-status').val() == 'P') { //기간
31142                document.querySelector('#etc-start-date-txt').value = document.querySelector('#etc-start-date-option').value;
31143                document.querySelector('#etc-end-date-txt').value = document.querySelector('#etc-end-date').value;
31144                document.querySelector('#select-date-ymd').value = document.querySelector('#etc-start-date-option').value + '|' + document.querySelector('#etc-end-date').value
31145                termPicker.startDate = $('#etc-start-date-option').val();
31146                termPicker.endDate = $('#etc-end-date').val();
31147            } else {
31148                document.querySelector('#etc-start-date-txt').value = document.querySelector('#etc-start-date-option').value;
31149                document.querySelector('#select-date-ymd').value = document.querySelector('#etc-start-date-option').value;
31150                var sDate = $('#etc-start-date-option').val();
31151                var sDateObj = new Date(sDate);
31152                termPicker.selectDate(sDateObj);
31153            }
31154
31155            if($('#etc-time').val()) {
31156                var sTime = $('#etc-time').val();
31157                $('.time-interval input[value="'+sTime+'"]').prop('checked', true);
31158            }
31159            
31160            setTimeout(function(){
31161                getDateTimeStr('ko')
31162            }, 500);
31163        }
31164    });
31165}
31166
31167function getDateTimeStr(blocklang, w, c) {
31168    // console.log(c)
31169    if(typeof w == 'undefined') w = '';
31170    if(typeof c == 'undefined') c = '';
31171    var lang = (blocklang)? blocklang:LANG
31172    var selectedDate = $('#select-date-ymd').val();
31173    var checkSelectedDate = selectedDate.split('.');
31174    var inputType = ($('.setting-datetime-input').length > 0)? $('.setting-datetime-input').attr('data-type') : $('.form-calendar-box').attr('data-type');
31175    var selectedTime = $('.time-interval input:checked');
31176
31177    switch (inputType) {
31178        case 'date2':
31179            if(selectedDate && selectedTime.length > 0) {
31180                $('.term-setting').removeClass('hide');
31181                var selectedTimeTxt = ' '+$.lang[lang]['config.form.date2.time.'+selectedTime.attr('name')]+' '+selectedTime.next('label').text();            
31182                if(lang == 'ko') {
31183                    $('.term-setting').text(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일'+selectedTimeTxt);
31184                } else {
31185                    $('.term-setting').text(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]+selectedTimeTxt);
31186                }
31187            }
31188            break;
31189        case 'etc-product-date':
31190        case 'etc-product-datetime':
31191            lang = 'ko';
31192            blocklang = 'ko';
31193            
31194            var selectedTimeTxt = '';
31195            selectedDate = $('#etc-start-date-txt').val();
31196            checkSelectedDate = selectedDate.split('.');
31197
31198            var startDate = $('#etc-start-date-txt').val();
31199            var endDate = $('#etc-end-date-txt').val();
31200            if(selectedDate) {
31201                $('.term-setting').removeClass('hide');
31202                if($('#etc-status').val() == 'P') { //기간
31203                    var checkStartDate = startDate.split('.');
31204                    var checkEndDate = endDate.split('.');
31205                    if (selectedTime.length > 0) selectedTimeTxt = '<br>'+$.lang[lang]['config.form.date2.time.'+selectedTime.attr('name')]+' '+selectedTime.next('label').text();            
31206                    if(blocklang == 'ko') {
31207                        $('.term-setting .start-date').html(checkStartDate[0]+'년 '+checkStartDate[1]+'월 '+checkStartDate[2]+' 일');
31208                        $('.term-setting .end-date').html(checkEndDate[0]+'년 '+checkEndDate[1]+'월 '+checkEndDate[2]+' 일'+selectedTimeTxt);
31209                    } else {
31210                        $('.term-setting .start-date').html(checkStartDate[1]+'/'+checkStartDate[2]+'/'+checkStartDate[0]);
31211                        $('.term-setting .end-date').html(checkEndDate[1]+'/'+checkEndDate[2]+'/'+checkEndDate[0]+selectedTimeTxt);
31212                    }
31213                } else {
31214                    if (selectedTime.length > 0) selectedTimeTxt = ' '+$.lang[lang]['config.form.date2.time.'+selectedTime.attr('name')]+' '+selectedTime.next('label').text();            
31215                    if(lang == 'ko') {
31216                        $('.term-setting').html(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일'+selectedTimeTxt);
31217                    } else {
31218                        $('.term-setting').html(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]+selectedTimeTxt);
31219                    }
31220                }
31221            }
31222            break;
31223        case 'saleStartDateTime':
31224            if(c == '') {
31225                lang = 'ko';
31226                blocklang = 'ko';
31227            } else {
31228                lang = c;
31229                blocklang = c;
31230            }
31231            // console.log('w', w);
31232            var selectedTimeTxt = '';
31233            checkSelectedDate = selectedDate.split('.');
31234
31235            if(selectedDate) {
31236                if(lang == 'ko') {
31237                    $('.sale-calendar-box .start-date').html(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일');
31238                } else {
31239                    $('.sale-calendar-box .start-date').html(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]);
31240                }
31241                
31242                var saleStartDateTime = $('#sale-start-datetime').val();
31243                
31244                if (w == 'calendar') {
31245                    $('.setting-sale-date .setting-datetime-input').slideUp(400, function(){
31246                        $('.setting-sale-date').removeClass('open');
31247                    });
31248
31249                    $('.setting-sale-time .setting-datetime-input').slideDown(400, function(){
31250                        $('.setting-sale-time').addClass('open');
31251                    });
31252                } else {
31253                    if(!w && saleStartDateTime) {
31254                        $('.setting-sale-date').removeClass('open');
31255                        $('.setting-sale-date .setting-datetime-input').css('display', 'none');
31256                        
31257                        $('.setting-sale-time').removeClass('open');
31258                        $('.setting-sale-time .setting-datetime-input').css('display', 'none');
31259                    }
31260                }
31261            }
31262
31263            if (selectedTime.length > 0) {
31264                var timeArr = selectedTime.next('label').text().split(':');
31265                if(c == 'en') selectedTimeTxt = $.lang[c]['config.form.date2.time.'+selectedTime.closest('.time-interval').attr('data-time')]+' '+timeArr[0]+' : '+timeArr[1];
31266                else selectedTimeTxt = $.lang[lang]['config.form.date2.time.'+selectedTime.closest('.time-interval').attr('data-time')]+' '+timeArr[0]+'시 '+timeArr[1]+'분';
31267                $('.sale-calendar-box .start-time').html(selectedTimeTxt);
31268                
31269                if (w == 'time') {
31270                    $('.setting-sale-time .setting-datetime-input').slideUp(400, function(){
31271                        $('.setting-sale-time').removeClass('open');
31272                    });
31273                }
31274            }
31275            break;
31276        case 'saleEndDateTime':
31277            if(c == '') {
31278                lang = 'ko';
31279                blocklang = 'ko';
31280            } else {
31281                lang = c;
31282                blocklang = c;
31283            }
31284
31285            var selectedTimeTxt = '';
31286            checkSelectedDate = selectedDate.split('.');
31287
31288            if(selectedDate) {
31289                if(lang == 'ko') {
31290                    $('.sale-calendar-box .end-date').html(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일');
31291                } else {
31292                    $('.sale-calendar-box .end-date').html(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]);
31293                }
31294
31295                var saleStartDateTime = $('#sale-start-datetime').val();
31296                var saleEndDateTime = $('#sale-end-datetime').val();
31297
31298                var startDate = saleStartDateTime.split(' ')[0];
31299                var startTime = saleStartDateTime.split(' ')[1];
31300
31301                if (w == 'calendar') {
31302                    $('.setting-sale-date .setting-datetime-input').slideUp(400, function(){
31303                        $('.setting-sale-date').removeClass('open');
31304                    });
31305
31306                    $('.setting-sale-time .setting-datetime-input').slideDown(400, function(){
31307                        $('.setting-sale-time').addClass('open');
31308                    });
31309                } else {
31310                    if(!w && saleStartDateTime) {
31311                        $('.setting-sale-date').removeClass('open');
31312                        $('.setting-sale-date .setting-datetime-input').css('display', 'none');
31313                        
31314                        $('.setting-sale-time').removeClass('open');
31315                        $('.setting-sale-time .setting-datetime-input').css('display', 'none');
31316                    }
31317                }
31318
31319                $('.time-interval input').prop('disabled', false);
31320                if(saleStartDateTime && startDate == selectedDate.replace(/\./g,'-')) {
31321                    var hour = parseInt(startTime.split(':')[0]);
31322                    var minute = parseInt(startTime.split(':')[1]);
31323                    var mna = (hour >= 12)? 'pm' : 'am';
31324
31325                    if(hour >= 12) {
31326                        if (hour > 12) hour -= 12;
31327                    } else if (hour == 0) hour += 12
31328
31329                    var formattedStartTime = hour.toString().padStart(2, '0') + minute.toString().padStart(2, '0');
31330                    $('.time-interval[data-time="' + mna + '"] input[value="' + formattedStartTime + '"]').prop('disabled', true);
31331                    if(mna == 'pm') {
31332                        $('.time-interval[data-time="am"] input').prop('disabled', true);
31333                        $('.time-interval[data-time="pm"] input[value="' + formattedStartTime + '"]').prevAll('input').prop('disabled', true);
31334                    } else {
31335                        $('.time-interval[data-time="am"] input[value="' + formattedStartTime + '"]').prevAll('input').prop('disabled', true);
31336                    }
31337                    if($('.time-interval input:checked').is(':disabled')) {
31338                        $('.time-interval input:checked').prop('checked', false);
31339                        $('.sale-calendar-box .end-time').html('');
31340                        selectedTime = '';
31341                    }
31342                }
31343            }
31344
31345            if (selectedTime.length > 0) {
31346                var timeArr = selectedTime.next('label').text().split(':');
31347                if(c == 'en') selectedTimeTxt = $.lang[c]['config.form.date2.time.'+selectedTime.closest('.time-interval').attr('data-time')]+' '+timeArr[0]+' : '+timeArr[1];
31348                else selectedTimeTxt = $.lang[lang]['config.form.date2.time.'+selectedTime.closest('.time-interval').attr('data-time')]+' '+timeArr[0]+'시 '+timeArr[1]+'분';
31349                $('.sale-calendar-box .end-time').html(selectedTimeTxt);
31350
31351                if (w == 'time') {
31352                    $('.setting-sale-time .setting-datetime-input').slideUp(400, function(){
31353                        $('.setting-sale-time').removeClass('open');
31354                    });
31355                }
31356            }
31357            break;
31358        default:
31359            if(selectedDate) {
31360                $('.term-setting').removeClass('hide');
31361                if(lang == 'ko') {
31362                    $('.term-setting').text(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일');
31363                } else {
31364                    $('.term-setting').text(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]);
31365                }
31366            }
31367            break;
31368    }
31369    // if(selectedDate && startTime.length > 0 && endTime.length > 0) {
31370    //     var startTimeTxt = (startTime.attr('name') == 'am') ? '오전 '+startTime.next('label').text():'오후 '+startTime.next('label').text();
31371    //     var endTimeTxt = (endTime.attr('name') == 'am') ? '오전 '+endTime.next('label').text() :'오후 '+endTime.next('label').text();
31372
31373    //     var s = startTime.val();
31374    //     var e = endTime.val();
31375    //     var sHour = (startTime.attr('name') == 'pm')? Number(s.substr(0, 2))+12 : Number(s.substr(0, 2));
31376    //     var sMinute = Number(s.substr(2));
31377    //     var eHour = (endTime.attr('name') == 'pm')? Number(e.substr(0, 2))+12 : Number(e.substr(0, 2));
31378    //     var eMinute = Number(e.substr(2));
31379        
31380    //     if(sHour == 24) sHour = 12;
31381    //     else if(sHour == 12) sHour = 0;
31382    //     if(eHour == 24) eHour = 12;
31383    //     else if(eHour == 12) eHour = 0;
31384
31385    //     var startDateTime = new Date(checkSelectedDate[0], checkSelectedDate[1], checkSelectedDate[2], sHour, sMinute);
31386    //     var endDateTime = new Date(checkSelectedDate[0], checkSelectedDate[1], checkSelectedDate[2], eHour, eMinute);
31387    //     var elapsedMSec = endDateTime.getTime()-startDateTime.getTime();
31388    //     var elapsedHour = elapsedMSec/1000/60/60;
31389    //     console.log(sHour, sMinute, startDateTime, endDateTime, elapsedMSec, elapsedHour);
31390    //     var totalTimesTxt = (elapsedMSec%3600000 == 0)? ' ('+elapsedHour+'시간)' : ' ('+Math.floor(elapsedHour)+'시간 30분)';
31391    //     $('.term-setting').removeClass('hide');
31392    //     $('.term-setting').text(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+' 일 '+startTimeTxt+' ~ '+ endTimeTxt + totalTimesTxt);
31393    // }
31394}
31395
31396// function calendarDateTimeStr(blocklang, w) {
31397//     if(typeof w == 'undefined') w = '';
31398//     var lang = (blocklang)? blocklang:LANG
31399//     var selectedDate = $('#select-date-ymd').val();
31400//     var checkSelectedDate = selectedDate.split('.');
31401//     var inputType = ($('.setting-datetime-input').length > 0)? $('.setting-datetime-input').attr('data-type') : $('.form-calendar-box').attr('data-type');
31402//     var selectedTime = $('.time-interval input:checked');
31403
31404//     switch (inputType) {
31405//         case 'date2':
31406//             if(selectedDate && selectedTime.length > 0) {
31407//                 $('.term-setting').removeClass('hide');
31408//                 var selectedTimeTxt = ' '+$.lang[lang]['config.form.date2.time.'+selectedTime.attr('name')]+' '+selectedTime.next('label').text();            
31409//                 if(lang == 'ko') {
31410//                     $('.term-setting').text(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일'+selectedTimeTxt);
31411//                 } else {
31412//                     $('.term-setting').text(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]+selectedTimeTxt);
31413//                 }
31414//             }
31415//             break;
31416//         case 'etc-product-date':
31417//         case 'etc-product-datetime':
31418//             lang = 'ko';
31419//             blocklang = 'ko';
31420            
31421//             var selectedTimeTxt = '';
31422//             selectedDate = $('#etc-start-date-txt').val();
31423//             checkSelectedDate = selectedDate.split('.');
31424
31425//             var startDate = $('#etc-start-date-txt').val();
31426//             var endDate = $('#etc-end-date-txt').val();
31427//             if(selectedDate) {
31428//                 $('.term-setting').removeClass('hide');
31429//                 if($('#etc-status').val() == 'P') { //기간
31430//                     var checkStartDate = startDate.split('.');
31431//                     var checkEndDate = endDate.split('.');
31432//                     if (selectedTime.length > 0) selectedTimeTxt = '<br>'+$.lang[lang]['config.form.date2.time.'+selectedTime.attr('name')]+' '+selectedTime.next('label').text();            
31433//                     if(blocklang == 'ko') {
31434//                         $('.term-setting .start-date').html(checkStartDate[0]+'년 '+checkStartDate[1]+'월 '+checkStartDate[2]+' 일');
31435//                         $('.term-setting .end-date').html(checkEndDate[0]+'년 '+checkEndDate[1]+'월 '+checkEndDate[2]+' 일'+selectedTimeTxt);
31436//                     } else {
31437//                         $('.term-setting .start-date').html(checkStartDate[1]+'/'+checkStartDate[2]+'/'+checkStartDate[0]);
31438//                         $('.term-setting .end-date').html(checkEndDate[1]+'/'+checkEndDate[2]+'/'+checkEndDate[0]+selectedTimeTxt);
31439//                     }
31440//                 } else {
31441//                     if (selectedTime.length > 0) selectedTimeTxt = ' '+$.lang[lang]['config.form.date2.time.'+selectedTime.attr('name')]+' '+selectedTime.next('label').text();            
31442//                     if(lang == 'ko') {
31443//                         $('.term-setting').html(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일'+selectedTimeTxt);
31444//                     } else {
31445//                         $('.term-setting').html(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]+selectedTimeTxt);
31446//                     }
31447//                 }
31448//             }
31449//             break;
31450//         case 'saleStartDateTime':
31451//             lang = 'ko';
31452//             blocklang = 'ko';
31453//             console.log('w', w);
31454//             var selectedTimeTxt = '';
31455//             checkSelectedDate = selectedDate.split('.');
31456
31457//             if(selectedDate) {
31458//                 if(lang == 'ko') {
31459//                     $('.sale-calendar-box .start-date').html(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일');
31460//                 } else {
31461//                     $('.sale-calendar-box .start-date').html(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]);
31462//                 }
31463                
31464//                 var saleStartDateTime = $('#sale-start-datetime').val();
31465                
31466//                 if (w == 'calendar') {
31467//                     $('.setting-sale-date .setting-datetime-input').slideUp(400, function(){
31468//                         $('.setting-sale-date').removeClass('open');
31469//                     });
31470
31471//                     $('.setting-sale-time .setting-datetime-input').slideDown(400, function(){
31472//                         $('.setting-sale-time').addClass('open');
31473//                     });
31474//                 } else {
31475//                     if(!w && saleStartDateTime) {
31476//                         $('.setting-sale-date').removeClass('open');
31477//                         $('.setting-sale-date .setting-datetime-input').css('display', 'none');
31478                        
31479//                         $('.setting-sale-time').removeClass('open');
31480//                         $('.setting-sale-time .setting-datetime-input').css('display', 'none');
31481//                     }
31482//                 }
31483//             }
31484
31485//             if (selectedTime.length > 0) {
31486//                 var timeArr = selectedTime.next('label').text().split(':');
31487//                 selectedTimeTxt = $.lang[lang]['config.form.date2.time.'+selectedTime.closest('.time-interval').attr('data-time')]+' '+timeArr[0]+'시 '+timeArr[1]+'분';
31488//                 $('.sale-calendar-box .start-time').html(selectedTimeTxt);
31489                
31490//                 if (w == 'time') {
31491//                     $('.setting-sale-time .setting-datetime-input').slideUp(400, function(){
31492//                         $('.setting-sale-time').removeClass('open');
31493//                     });
31494//                 }
31495//             }
31496//             break;
31497//         case 'saleEndDateTime':
31498//             lang = 'ko';
31499//             blocklang = 'ko';
31500
31501//             var selectedTimeTxt = '';
31502//             checkSelectedDate = selectedDate.split('.');
31503
31504//             if(selectedDate) {
31505//                 if(lang == 'ko') {
31506//                     $('.sale-calendar-box .end-date').html(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일');
31507//                 } else {
31508//                     $('.sale-calendar-box .end-date').html(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]);
31509//                 }
31510
31511//                 var saleStartDateTime = $('.'+selectEL).find('.calendar-modal-container .sdate .start').val();
31512//                 var saleEndDateTime = $('.'+selectEL).find('.calendar-modal-container .edate .end').val();
31513
31514//                 var selectedDate = ($('#select-date-ymd').val() || '').trim();
31515//                 var checkSelectedDate = selectedDate ? selectedDate.split('.') : [];
31516
31517//                 if (w == 'calendar') {
31518//                     $('.setting-sale-date .setting-datetime-input').slideUp(400, function(){
31519//                         $('.setting-sale-date').removeClass('open');
31520//                     });
31521
31522//                     $('.setting-sale-time .setting-datetime-input').slideDown(400, function(){
31523//                         $('.setting-sale-time').addClass('open');
31524//                     });
31525//                 } else {
31526//                     if(!w && saleStartDateTime) {
31527//                         $('.setting-sale-date').removeClass('open');
31528//                         $('.setting-sale-date .setting-datetime-input').css('display', 'none');
31529                        
31530//                         $('.setting-sale-time').removeClass('open');
31531//                         $('.setting-sale-time .setting-datetime-input').css('display', 'none');
31532//                     }
31533//                 }
31534
31535//                 $('.time-interval input').prop('disabled', false);
31536//                 if(saleStartDateTime && startDate == selectedDate.replace(/\./g,'-')) {
31537//                     var hour = parseInt(startTime.split(':')[0]);
31538//                     var minute = parseInt(startTime.split(':')[1]);
31539//                     var mna = (hour >= 12)? 'pm' : 'am';
31540
31541//                     if(hour >= 12) {
31542//                         if (hour > 12) hour -= 12;
31543//                     } else if (hour == 0) hour += 12
31544
31545//                     var formattedStartTime = hour.toString().padStart(2, '0') + minute.toString().padStart(2, '0');
31546//                     $('.time-interval[data-time="' + mna + '"] input[value="' + formattedStartTime + '"]').prop('disabled', true);
31547//                     if(mna == 'pm') {
31548//                         $('.time-interval[data-time="am"] input').prop('disabled', true);
31549//                         $('.time-interval[data-time="pm"] input[value="' + formattedStartTime + '"]').prevAll('input').prop('disabled', true);
31550//                     } else {
31551//                         $('.time-interval[data-time="am"] input[value="' + formattedStartTime + '"]').prevAll('input').prop('disabled', true);
31552//                     }
31553//                     if($('.time-interval input:checked').is(':disabled')) {
31554//                         $('.time-interval input:checked').prop('checked', false);
31555//                         $('.sale-calendar-box .end-time').html('');
31556//                         selectedTime = '';
31557//                     }
31558//                 }
31559//             }
31560
31561//             if (selectedTime.length > 0) {
31562//                 var timeArr = selectedTime.next('label').text().split(':');
31563//                 selectedTimeTxt = $.lang[lang]['config.form.date2.time.'+selectedTime.closest('.time-interval').attr('data-time')]+' '+timeArr[0]+'시 '+timeArr[1]+'분';
31564//                 $('.sale-calendar-box .end-time').html(selectedTimeTxt);
31565
31566//                 if (w == 'time') {
31567//                     $('.setting-sale-time .setting-datetime-input').slideUp(400, function(){
31568//                         $('.setting-sale-time').removeClass('open');
31569//                     });
31570//                 }
31571//             }
31572//             break;
31573//         default:
31574//             if(selectedDate) {
31575//                 $('.term-setting').removeClass('hide');
31576//                 if(lang == 'ko') {
31577//                     $('.term-setting').text(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일');
31578//                 } else {
31579//                     $('.term-setting').text(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]);
31580//                 }
31581//             }
31582//             break;
31583//     }
31584// }
31585
31586function scrollToCurrentYearMonth() {
31587    $('.year-picker').scrollTop(0);
31588    $('.month-picker').scrollTop(0);
31589    var offsetYear = $('.year-picker .current').position().top - 30;
31590    var offsetMonth = $('.month-picker .current').position().top - 30;
31591    $('.year-picker').scrollTop(offsetYear);
31592    $('.month-picker').scrollTop(offsetMonth);
31593}
31594
31595function calInputWidth(inputObj) {
31596    let inputTxt = inputObj.val().replace(/[\u3131-\u318E\uAC00-\uD7A3]/g, '');
31597    let Num = Number(removeCommas(inputTxt));
31598
31599    let $tempSpan = $('<span>').css({
31600        'font-size': inputObj.css('font-size'),
31601        'font-family': inputObj.css('font-family'),
31602        'visibility': 'hidden',
31603        'white-space': 'pre'
31604    }).text(inputTxt);
31605    
31606    $('body').append($tempSpan);
31607    
31608    let inputWidth = Math.floor($tempSpan.width()) + 5;
31609    if(inputWidth < 13 || Num == 0) inputWidth = 13;
31610    inputObj.width(inputWidth);
31611    $tempSpan.remove();
31612}
31613
31614function calDiscount(inputObj) {
31615    var orgPrice = Number(removeCommas($('#prod-sale').text())),
31616        discountRate = inputObj.val(),
31617        discountUnit = $('#prod-discount-unit').attr('data-value'),
31618        price = 0;
31619
31620    discountRate = Number(discountRate.replace(/[^0-9]/g, ''));
31621    if($('.form-group.discount-append').hasClass('discount-multi')) {
31622        switch(discountUnit) {
31623            case 'W':
31624                inputObj.val(number_format(discountRate));
31625                break;
31626            case 'P':
31627                if(discountRate >= 100) {
31628                    discountRate = 100;
31629                }
31630                inputObj.val(discountRate);
31631                
31632                break;
31633        }
31634    } else {
31635        switch(discountUnit) {
31636            case 'W':
31637                price = orgPrice - discountRate;
31638                if(price < 0) {
31639                    price = 0;
31640                    inputObj.val(number_format(orgPrice));
31641                } else {
31642                    inputObj.val(number_format(discountRate));
31643                }
31644                break;
31645            case 'P':
31646                if(discountRate >= 100) {
31647                    price = 0;
31648                    discountRate = 100;
31649                } else {
31650                    var discountPrice = orgPrice * (discountRate / 100);
31651                    price = Math.round(orgPrice - discountPrice);
31652                    // if($('#price-cut-btn').is(':checked')) price = Math.floor(price / 10) * 10;
31653                }
31654                
31655                // if (price % 10 == 0 || price == 0) $('#price-cut-btn').addClass('disabled');
31656                // else $('#price-cut-btn').removeClass('disabled');
31657                inputObj.val(discountRate);
31658                
31659                break;
31660        } //end switch
31661        console.log('price', price);
31662
31663        $('#prod-price').val(number_format(price));
31664        calInputWidth($('#prod-price'));
31665    }
31666    
31667}
31668
31669$(document).on('click', '.element[data-type="review"]  a[data-review]', function(e){
31670    e.preventDefault();
31671    if ($(this).closest('.element').hasClass('review-sample-block')) return false;
31672
31673    if (PAGE_MODE != 'c') {
31674        var seq = $(this).attr('data-review');
31675        $.shoppingmall.viewReviewModal(property.SID, seq);
31676    }
31677});
31678
31679
31680var configDateTime = function(el) {
31681    var field_type = $(el).attr('data-type');
31682    var id = (field_type.indexOf('etc-product-date') > -1) ? $('#prod-no').val() : $(el).closest('.form-sort-item').attr('data-id');
31683    var func = $(el).attr('data-setting');
31684    var field_setting = {};
31685    // console.log('field_type', field_type, el);
31686
31687    if (field_type.indexOf('etc-product-date') > -1) {
31688        field_setting.term = ($('#etc-term').val()) ? JSON.parse($('#etc-term').val()) : {};
31689        field_setting.excludeDate = { 'date': $('#etc-exclude-date').val() };
31690        field_setting.time = ($('#etc-time').val()) ? JSON.parse($('#etc-time').val()) : {};
31691    } else if (field_type.indexOf('sale-product-datetime') > -1) {
31692        field_setting.term = ($('#etc-term').val()) ? JSON.parse($('#etc-term').val()) : {};
31693    } else {
31694        $.ajax({
31695            url: '/template/forms/field_config',
31696            dataType: 'json',
31697            type: 'POST',
31698            data: { sid: SID, id: id },
31699            async: false,
31700            cache: false,
31701            success: function(data) {
31702                checkError(data);
31703                field_setting = data;
31704            }
31705        });
31706    }
31707    // console.log(field_setting);
31708
31709    var term = (field_setting.term) ? field_setting.term : {};
31710    var excludeDate = (field_setting.excludeDate) ? field_setting.excludeDate : {};
31711    var time = (field_setting.time) ? field_setting.time : {};
31712
31713    //term
31714    var startDate = (term.start_date !== undefined && term.start_date != '') ? term.start_date : '';
31715    var endDate = (term.end_date !== undefined && term.end_date != '') ? term.end_date : '';
31716    var dateWeek = (term.date_week !== undefined && term.date_week != '') ? term.date_week : 'A';
31717    var days = (term.days !== undefined && term.days != '') ? term.days.split('|') : [];
31718    var daysObj = {
31719        'sun': 0,
31720        'mon': 1,
31721        'tue': 2,
31722        'wed': 3,
31723        'thu': 4,
31724        'fri': 5,
31725        'sat': 6,
31726    }
31727
31728    //excludeDate
31729    var exceptDate = (excludeDate.date !== undefined) ? excludeDate.date : '';
31730
31731    //time
31732    var interval = (time.interval !== undefined) ? time.interval : '30';
31733    var am = (time.am !== undefined) ? time.am.split('|') : [];
31734    var pm = (time.pm !== undefined) ? time.pm.split('|') : [];
31735    var timeCnt = am.length + pm.length;
31736    // var disabled = null;
31737
31738    // var allTimeChecked = '';
31739    // if (interval == '10' && timeCnt == 144) allTimeChecked = 'checked';
31740    // if (interval == '20' && timeCnt == 72) allTimeChecked = 'checked';
31741    // if (interval == '30' && timeCnt == 48) allTimeChecked = 'checked';
31742    // if (interval == '60' && timeCnt == 24) allTimeChecked = 'checked';
31743
31744    var language = (LANG != 'ko') ? 'en' : 'ko';
31745    var blocklang = ($('[form-seq="' + id + '"]').closest('.element').attr('data-blocklang')) ? $('[form-seq="' + id + '"]').closest('.element').attr('data-blocklang') : LANG;
31746
31747    var modal_title = '';
31748    var modal_str = '';
31749    var modal_class = 'modal-dialog cl-cmmodal cl-s-btn setting-form-option-date2 cl-close-btn cover';
31750    switch (func) {
31751        case 'term':
31752            modal_title = $.lang[LANG]['config.form.date.title'];
31753            modal_str = '\
31754                <input type="hidden" id="etc-date-week" value="' + dateWeek + '">\
31755                <div class="display-flex align-items-center setting-row">\
31756                    <div class="setting-label">' + $.lang[LANG]['config.form.date.dateWeek.label'] + '</div>\
31757                    <div class="btn-group btn-group-justified week">\
31758                        <label class="btn checked">' + $.lang[LANG]['config.form.date.dateWeek.entire'] + '<input type="radio" name="week" value="A" checked></label>\
31759                        <label class="btn">' + $.lang[LANG]['config.form.date.dateWeek.weekday'] + '<input type="radio" name="week" value="W"></label>\
31760                        <label class="btn">' + $.lang[LANG]['config.form.date.dateWeek.weekend'] + '<input type="radio" name="week" value="K"></label>\
31761                    </div>\
31762                </div>\
31763                <div class="display-flex align-items-center setting-row">\
31764                    <div class="setting-label">' + $.lang[LANG]['config.form.date.day.label'] + '</div>\
31765                    <div class="btn-group btn-group-justified day">\
31766                        <label class="btn checked">' + $.lang[LANG]['config.form.date.day.sun'] + '<input type="checkbox" name="day" value="sun" checked></label>\
31767                        <label class="btn checked">' + $.lang[LANG]['config.form.date.day.mon'] + '<input type="checkbox" name="day" value="mon" checked></label>\
31768                        <label class="btn checked">' + $.lang[LANG]['config.form.date.day.tue'] + '<input type="checkbox" name="day" value="tue" checked></label>\
31769                        <label class="btn checked">' + $.lang[LANG]['config.form.date.day.wed'] + '<input type="checkbox" name="day" value="wed" checked></label>\
31770                        <label class="btn checked">' + $.lang[LANG]['config.form.date.day.thu'] + '<input type="checkbox" name="day" value="thu" checked></label>\
31771                        <label class="btn checked">' + $.lang[LANG]['config.form.date.day.fri'] + '<input type="checkbox" name="day" value="fri" checked></label>\
31772                        <label class="btn checked">' + $.lang[LANG]['config.form.date.day.sat'] + '<input type="checkbox" name="day" value="sat" checked></label>\
31773                    </div>\
31774                </div>\
31775                <div class="term-calendar-box">\
31776                    <input type="hidden" id="select-calendar" value="term-datepicker">\
31777                    <input type="hidden" id="etc-start-date-prev" value="' + startDate + '">\
31778                    <input type="hidden" id="etc-end-date-prev" value="' + endDate + '">\
31779                    <input type="hidden" id="etc-start-date-txt" value="' + startDate + '">\
31780                    <input type="hidden" id="etc-end-date-txt" value="' + endDate + '">\
31781                    <input type="hidden" id="select-except-date">\
31782                    <div id="term-datepicker"></div>\
31783                </div>\
31784                <div class="term-setting hide" data-blocklang="' + blocklang + '">\
31785                    <span class="start-date"></span> ~ <span class="end-date"></span>\
31786                </div>\
31787            ';
31788            break;
31789        case 'saleStartDateTime':
31790        case 'saleEndDateTime':
31791            modal_class = 'modal-dialog cl-cmmodal cl-s-btn setting-form-option-date2 setting-product-sale-datetime cl-close-btn cover';
31792            var timeClass = 'start-time';
31793            if(func == 'saleStartDateTime') {
31794                modal_title = '시작 날짜/시간 선택';
31795                modal_str = '\
31796                <div class="term-calendar-box sale-calendar-box setting-sale-date">\
31797                    <div class="setting-label display-flex align-items-center space-between">\
31798                        <div class="display-flex align-items-center">\
31799                            <span>날짜 선택</span>\
31800                            <span class="start-date datetime-txt" data-blocklang="' + blocklang + '"></span>\
31801                        </div>\
31802                        <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>\
31803                    </div>\
31804                    <div class="setting-datetime-input" data-type="' + func + '">\
31805                        <input type="hidden" id="select-calendar" value="term-datepicker">\
31806                        <input type="hidden" id="select-date-ymd" value="">\
31807                        <input type="hidden" id="etc-start-date-prev" value="">\
31808                        <input type="hidden" id="etc-start-date-txt" value="">\
31809                        <div id="sale-datepicker"></div>\
31810                    </div>\
31811                </div>\
31812                ';
31813            } else {
31814                modal_title = '종료 날짜/시간 선택';
31815                modal_str = '\
31816                <div class="term-calendar-box sale-calendar-box setting-sale-date">\
31817                    <div class="setting-label display-flex align-items-center space-between">\
31818                        <div class="display-flex align-items-center">\
31819                            <span>날짜 선택</span>\
31820                            <span class="end-date datetime-txt" data-blocklang="' + blocklang + '"></span>\
31821                        </div>\
31822                        <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>\
31823                    </div>\
31824                    <div class="setting-datetime-input" data-type="' + func + '">\
31825                        <input type="hidden" id="select-calendar" value="term-datepicker">\
31826                        <input type="hidden" id="select-date-ymd" value="">\
31827                        <input type="hidden" id="etc-start-date-prev" value="">\
31828                        <input type="hidden" id="etc-start-date-txt" value="">\
31829                        <input type="hidden" id="etc-end-date-prev" value="">\
31830                        <input type="hidden" id="etc-end-date-txt" value="">\
31831                        <div id="sale-datepicker"></div>\
31832                    </div>\
31833                </div>\
31834                ';
31835                timeClass = 'end-time';
31836            }
31837            
31838            modal_str += '\
31839                <div class="term-calendar-box sale-calendar-box setting-sale-time">\
31840                    <div class="setting-label display-flex align-items-center space-between">\
31841                        <div class="display-flex align-items-center">\
31842                            <span>시간 선택</span>\
31843                            <span class="'+timeClass+' datetime-txt" data-blocklang="' + blocklang + '"></span>\
31844                        </div>\
31845                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
31845<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>\
31846                    </div>\
31847                    <div class="setting-datetime-input" data-type="' + func + '" style="display:none;">\
31848                        <div class="display-flex align-items-center setting-row">\
31849                            <div class="setting-label">' + $.lang[LANG]['config.form.date2.time.interval.label'] + '</div>\
31850                            <div class="newcheckbox hand">\
31851                                <label>\
31852                                    <div class="newcheckboxSvgRadio">\
31853                                        <input type="radio" class="cl-common-form-radio-hide" name="time_interval" value="30" checked>\
31854                                        <svg viewBox="0 0 18 18" width="18" height="18">\
31855                                            <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>\
31856                                        </svg>\
31857                                        <svg class="active" viewBox="0 0 18 18" width="18" height="18">\
31858                                            <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>\
31859                                            <circle cx="9" cy="9" r="6"></circle>\
31860                                        </svg>\
31861                                    </div>\
31862                                    <span>' + $.lang[LANG]['config.form.date2.time.interval.30'] + '</span>\
31863                                </label>\
31864                            </div>\
31865                            <div class="newcheckbox hand">\
31866                                <label>\
31867                                    <div class="newcheckboxSvgRadio">\
31868                                        <input type="radio" class="cl-common-form-radio-hide" name="time_interval" value="60">\
31869                                        <svg viewBox="0 0 18 18" width="18" height="18">\
31870                                            <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>\
31871                                        </svg>\
31872                                        <svg class="active" viewBox="0 0 18 18" width="18" height="18">\
31873                                            <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>\
31874                                            <circle cx="9" cy="9" r="6"></circle>\
31875                                        </svg>\
31876                                    </div>\
31877                                    <span>' + $.lang[LANG]['config.form.date2.time.interval.60'] + '</span>\
31878                                </label>\
31879                            </div>\
31880                        </div>\
31881                        <div class="setting-row am">\
31882                            <div class="setting-label">' + $.lang[LANG]['config.form.date2.time.am'] + '</div>\
31883                            <div class="display-flex time-interval" data-time="am"></div>\
31884                        </div>\
31885                        <div class="setting-row">\
31886                            <div class="setting-label">' + $.lang[LANG]['config.form.date2.time.pm'] + '</div>\
31887                            <div class="display-flex time-interval" data-time="pm"></div>\
31888                        </div>\
31889                    </div>\
31890                </div>\
31891            ';
31892            break;
31893        case 'excludeDate':
31894            modal_title = $.lang[LANG]['config.form.date.excludeDate'];
31895            modal_str = '\
31896            <div class="except-calendar-box">\
31897                <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>\
31898                <input type="hidden" id="select-calendar" value="etc-except-date-picker">\
31899                <input type="hidden" class="etc-date" id="etc-except-date" value="">\
31900                <input type="hidden" id="etc-start-date-txt" value="' + startDate + '">\
31901                <input type="hidden" id="etc-end-date-txt" value="' + endDate + '">\
31902                <input type="hidden" id="etc-date-week" value="' + dateWeek + '">\
31903                <input type="hidden" id="select-except-date" value="' + exceptDate + '">\
31904                <input type="hidden" id="term-days" value="' + term.days + '">\
31905                <div id="etc-except-date-picker"></div>\
31906            </div>\
31907            <div class="term-setting hide" data-blocklang="' + blocklang + '">\
31908                <span class="start-date"></span> ~ <span class="end-date"></span>\
31909            </div>\
31910            ';
31911            break;
31912        case 'time':
31913            modal_title = $.lang[LANG]['config.form.date2.time'];
31914            modal_class += ' setting-times';
31915            modal_str = '\
31916            <div class="guide-wrap">\
31917                <div class="display-flex align-items-center setting-row">\
31918                    <div class="setting-label">' + $.lang[LANG]['config.form.date2.time.interval.label'] + '</div>\
31919                    <div class="newcheckbox hand">\
31920                        <label>\
31921                            <div class="newcheckboxSvgRadio">\
31922                                <input type="radio" class="cl-common-form-radio-hide" name="time_interval" value="60">\
31923                                <svg viewBox="0 0 18 18" width="18" height="18">\
31924                                    <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>\
31925                                </svg>\
31926                                <svg class="active" viewBox="0 0 18 18" width="18" height="18">\
31927                                    <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>\
31928                                    <circle cx="9" cy="9" r="6"></circle>\
31929                                </svg>\
31930                            </div>\
31931                            <span>' + $.lang[LANG]['config.form.date2.time.interval.60'] + '</span>\
31932                        </label>\
31933                    </div>\
31934                    <div class="newcheckbox hand">\
31935                        <label>\
31936                            <div class="newcheckboxSvgRadio">\
31937                                <input type="radio" class="cl-common-form-radio-hide" name="time_interval" value="30" checked>\
31938                                <svg viewBox="0 0 18 18" width="18" height="18">\
31939                                    <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>\
31940                                </svg>\
31941                                <svg class="active" viewBox="0 0 18 18" width="18" height="18">\
31942                                    <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>\
31943                                    <circle cx="9" cy="9" r="6"></circle>\
31944                                </svg>\
31945                            </div>\
31946                            <span>' + $.lang[LANG]['config.form.date2.time.interval.30'] + '</span>\
31947                        </label>\
31948                    </div>\
31949                    <div class="newcheckbox hand">\
31950                        <label>\
31951                            <div class="newcheckboxSvgRadio">\
31952                                <input type="radio" class="cl-common-form-radio-hide" name="time_interval" value="20">\
31953                                <svg viewBox="0 0 18 18" width="18" height="18">\
31954                                    <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>\
31955                                </svg>\
31956                                <svg class="active" viewBox="0 0 18 18" width="18" height="18">\
31957                                    <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>\
31958                                    <circle cx="9" cy="9" r="6"></circle>\
31959                                </svg>\
31960                            </div>\
31961                            <span>' + $.lang[LANG]['config.form.date2.time.interval.20'] + '</span>\
31962                        </label>\
31963                    </div>\
31964                    <div class="newcheckbox hand">\
31965                        <label>\
31966                            <div class="newcheckboxSvgRadio">\
31967                                <input type="radio" class="cl-common-form-radio-hide" name="time_interval" value="10">\
31968                                <svg viewBox="0 0 18 18" width="18" height="18">\
31969                                    <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 
319690-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
31970                                </svg>\
31971                                <svg class="active" viewBox="0 0 18 18" width="18" height="18">\
31972                                    <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>\
31973                                    <circle cx="9" cy="9" r="6"></circle>\
31974                                </svg>\
31975                            </div>\
31976                            <span>' + $.lang[LANG]['config.form.date2.time.interval.10'] + '</span>\
31977                        </label>\
31978                    </div>\
31979                </div>\
31980                <div class="setting-row am">\
31981                    <label for="all-time-select" class="all-time display-flex align-items-center">\
31982                        <div class="newcheckbox hand">\
31983                            <input id="all-time-select" class="hide" type="checkbox">\
31984                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
31985                                <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"/>\
31986                            </svg>\
31987                            <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
31988                                <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"/>\
31989                            </svg>\
31990                        </div>\
31991                        <span>' + $.lang[LANG]['config.form.date2.time.selectAll'] + '</span>\
31992                    </label>\
31993                    <div class="setting-label">' + $.lang[LANG]['config.form.date2.time.am'] + '</div>\
31994                    <div class="display-flex time-interval" data-time="am"></div>\
31995                </div>\
31996                <div class="setting-row">\
31997                    <div class="setting-label">' + $.lang[LANG]['config.form.date2.time.pm'] + '</div>\
31998                    <div class="display-flex time-interval" data-time="pm"></div>\
31999                </div>\
32000            </div>\
32001            ';
32002            break;
32003    }
32004
32005    var settingModal = $(el).showModalFlat(modal_title, modal_str, true, true, function() { //confirm
32006        var postData = {};
32007        switch (func) {
32008            case 'term':
32009                if (!$('#etc-start-date-txt').val() || !$('#etc-end-date-txt').val()) {
32010                    alert('날짜 기간을 선택해주세요.');
32011                    return false;
32012                }
32013                var days = new Array();
32014                $('input[name="day"]:checked').each(function(i, v) {
32015                    days.push($(v).val());
32016                });
32017                postData = {
32018                    'term': {
32019                        'select_terms': 'Y',
32020                        'date_week': $('#etc-date-week').val(),
32021                        'start_date': $('#etc-start-date-txt').val(),
32022                        'end_date': $('#etc-end-date-txt').val(),
32023                        'days': (days.length > 0) ? days.join('|') : ''
32024                    }
32025                };
32026
32027                startDate = $('#etc-start-date-txt').val();
32028                endDate = $('#etc-end-date-txt').val();
32029
32030                if (field_type.indexOf('etc-product-date') > -1 && startDate && endDate) { //etc product
32031                    $('#etc-week').val($('#etc-date-week').val());
32032                    $('#etc-start-date').val(startDate);
32033                    $('#etc-end-date').val(endDate);
32034                    $('#etc-term').val(JSON.stringify(postData.term));
32035                    $('.term-setting .setting-text .content').text(startDate + ' ~ ' + endDate);
32036                }
32037
32038                break;
32039            case 'saleStartDateTime':
32040            case 'saleEndDateTime':
32041                var selectedDate = $('#select-date-ymd').val();
32042
32043                if (!selectedDate || $('.time-interval input:checked').length == 0) {
32044                    alert('날짜와 시간을 선택해주세요.');
32045                    return false;
32046                }
32047
32048                if (!selectedDate || $('.time-interval input:checked').length == 0) {
32049                    alert('날짜와 시간을 선택해주세요.');
32050                    return false;
32051                }
32052
32053                var mna = $('.time-interval input:checked').parent().attr('data-time');
32054                var selectedTime = convertTime24(mna, $('.time-interval input:checked').val());
32055                var saleDateTime = selectedDate + '. ' + convertTime12(selectedTime);
32056                var saleDateTimeVal = selectedDate.replace(/\./g, '-') + ' ' + selectedTime + ':00';
32057                console.log(selectedTime);
32058                if(func == 'saleStartDateTime') {
32059                    var startDateTime = new Date(saleDateTimeVal);
32060                    var currentDateTime = new Date();
32061
32062                    if($('#sale-end-datetime').val()) {
32063                        var endDateTime = new Date($('#sale-end-datetime').val());
32064                        if(endDateTime <= startDateTime) {
32065                            startDateTime.setHours(startDateTime.getHours() + 1);
32066                            console.log(startDateTime);
32067                            var endDateTimeVal = convertDateObjToStr(startDateTime);
32068                            var endDateTime = endDateTimeVal.split(' ');
32069
32070                            $('#sale-end-datetime').val(endDateTimeVal);
32071                            $('.sale-setting .setting-text .content-end').text(endDateTime[0] + '. ' + convertTime12(endDateTime[1]));
32072                        }
32073                    }
32074                    
32075                    $('.sale-setting .setting-text .content-start').text(saleDateTime);
32076                    $('#sale-start-datetime').val(saleDateTimeVal);
32077                } else {
32078                    var endDateTime = new Date(saleDateTimeVal);
32079
32080                    if($('#sale-start-datetime').val()) {
32081                        var startDateTime = new Date($('#sale-start-datetime').val());
32082                        if(startDateTime >
32082= endDateTime) {
32083                            alert('판매 시작 시간보다 나중 시간을 선택해 주세요.');
32084                            return false;
32085                        }
32086                    }
32087
32088                    $('.sale-setting .setting-text .content-end').text(saleDateTime);
32089                    $('#sale-end-datetime').val(saleDateTimeVal);
32090                }
32091
32092                break;
32093            case 'excludeDate':
32094                postData = {
32095                    'excludeDate': {
32096                        'date': $('#select-except-date').val(),
32097                    }
32098                };
32099
32100                if (field_type.indexOf('etc-product-date') > -1) { //etc product
32101                    if ($('#select-except-date').val()) {
32102                        $('#etc-exclude-date').val($('#select-except-date').val());
32103                        $('.exclude-setting .setting-text .content').text($('#select-except-date').val());
32104                        $('.exclude-setting .setting-text').attr('data-toggle', 'tooltip');
32105                        $('.exclude-setting .setting-text').attr('data-original-title', "<div class='except-date-tooltip'>" + $('#select-except-date').val() + "</div>");
32106                    } else {
32107                        $('#etc-exclude-date').val('');
32108                        $('.exclude-setting .setting-text .content').text('');
32109                        $('.exclude-setting .setting-text').removeAttr('data-toggle');
32110                        $('.exclude-setting .setting-text').removeAttr('data-original-title');
32111                    }
32112                }
32113                break;
32114            case 'time':
32115                if ($('.time-interval input:checked').length == 0) {
32116                    alert($.lang[LANG]['config.form.date2.time.excludeAll']);
32117                    return false;
32118                }
32119
32120                var interval = $('input[name="time_interval"]:checked').val();
32121                var am = new Array();
32122                var pm = new Array();
32123                $('input[name="am"]:checked').each(function(i, v) {
32124                    // if ($(v).next('label').hasClass('hide')) {
32125                    //     return true;
32126                    // }
32127                    am.push($(v).val());
32128                });
32129                $('input[name="pm"]:checked').each(function(i, v) {
32130                    // if ($(v).next('label').hasClass('hide')) {
32131                    //     return true;
32132                    // }
32133                    pm.push($(v).val());
32134                });
32135                postData = {
32136                    'time': {
32137                        'interval': interval,
32138                        'am': (am.length > 0) ? am.join('|') : '',
32139                        'pm': (pm.length > 0) ? pm.join('|') : '',
32140                    }
32141                };
32142
32143                if (field_type.indexOf('etc-product-date') > -1) {
32144                    $('#etc-time').val(JSON.stringify(postData.time));
32145                }
32146                break;
32147        }
32148        // console.log(id, postData);
32149        // console.log('field_type', field_type);
32150        if (field_type.indexOf('etc-product-date') == -1 && field_type.indexOf('sale-product-datetime') == -1) { //form date
32151            var settings = {
32152                'type': 'val',
32153                'value': JSON.stringify(postData),
32154            }
32155
32156            if (itemsAjax) itemsAjax.abort();
32157            itemsAjax = $.ajax({
32158                url: "/template/forms/items",
32159                async: true,
32160                type: "post",
32161                dataType: "json",
32162                data: {
32163                    sid: SID,
32164                    id: id,
32165                    field: field_type,
32166                    val_type: func,
32167                    settings: settings
32168                },
32169                success: function(data) {
32170                    checkError(data);
32171                    initDateTimeConf(SID, id, field_type);
32172                }
32173            });
32174        }
32175
32176
32177        // saveFormElement();
32178        settingModal.modal('hide');
32179    }, 'cancel', 'ok', modal_class, true, function() { //close
32180        if (func == 'term' && (!$('#etc-start-date-txt').val() || !$('#etc-end-date-txt').val())) {
32181            if (!$('#etc-start-date-prev').val() && !$('#etc-end-date-prev').val()) {
32182                $('input[name="select_terms-' + id + '"][value="N"]').prop('checked', true);
32183                $('.form-sort-item[data-id="' + id + '"] .setting-date2[data-setting="term"]').addClass('disabled');
32184            }
32185        }
32186        settingModal.modal('hide');
32187    }, function() { //show
32188        if (field_type.indexOf('etc-product-date') > -1) {
32189            startDate = $('#etc-start-date').val();
32190            endDate = $('#etc-end-date').val();
32191            lang = 'ko';
32192            $('#etc-start-date-txt').val(startDate);
32193            $('#etc-end-date-txt').val(endDate);
32194        }
32195
32196        if (startDate && endDate) {
32197            var checkStartDate = startDate.split('.');
32198            var checkEndDate = endDate.split('.');
32199
32200            $('.term-setting').removeClass('hide');
32201            if (blocklang == 'ko') {
32202                $('.term-setting .start-date').text(checkStartDate[0] + '년 ' + checkStartDate[1] + '월 ' + checkStartDate[2] + ' 일');
32203                $('.term-setting .end-date').text(checkEndDate[0] + '년 ' + checkEndDate[1] + '월 ' + checkEndDate[2] + ' 일');
32204            } else {
32205                $('.term-setting .start-date').text(checkStartDate[1] + '/' + checkStartDate[2] + '/' + checkStartDate[0]);
32206                $('.term-setting .end-date').text(checkEndDate[1] + '/' + checkEndDate[2] + '/' + checkEndDate[0]);
32207            }
32208        }
32209        // console.log(language);
32210        $('#term-datepicker').html('');
32211        var currentYear = new Date().getFullYear();
32212        switch (func) {
32213            case 'term':
32214                var termPicker = new Datepickk({
32215                    container: document.querySelector('#term-datepicker'),
32216                    inline: true,
32217                    range: true,
32218                    exp: false,
32219                    lang: language,
32220                    startDate: (startDate.replace(/\./g, '/')) ? new Date(startDate.replace(/\./g, '/')) : new Date(),
32221                    minDate: new Date(1900, 0, 1),
32222                    maxDate: new Date(currentYear + 15, 11, 31),
32223                });
32224
32225                if (dateWeek) {
32226                    $('.btn-group.week label').removeClass('checked');
32227                    $('input[value="' + dateWeek + '"]').prop('checked', true);
32228                    $('input[value="' + dateWeek + '"]').closest('label').addClass('checked');
32229                    disabled = (days.length > 0) ? getDisabledDays(days) : [];
32230                    termPicker.disabledDays = (disabled.length > 0) ? disabled : null;
32231                }
32232
32233                if (startDate && endDate) {
32234                    $('input[name="day"]').prop('checked', false);
32235                    $('input[name="day"]').closest('label').removeClass('checked');
32236                    termPicker.setSelectedDates(startDate, 'start');
32237                    termPicker.setSelectedDates(endDate, 'end');
32238                }
32239
32240                if (days) {
32241                    $.each(days, function(i, v) {
32242                        $('input[value="' + v + '"]').prop('checked', true);
32243                        $('input[value="' + v + '"]').closest('label').addClass('checked');
32244                    });
32245                }
32246                $('input[name="week"]').on('change', function() {
32247                    var value = $(this).val();
32248                    $('#etc-date-week').val(value);
32249                    $('.btn-group.week label').removeClass('checked');
32250                    if ($(this).is(':checked')) $(this).closest('label').addClass('checked');
32251                    termPicker.disabledDays = null;
32252                    $('#etc-start-date-txt').val('');
32253                    $('#etc-end-date-txt').val('');
32254                    if (field_type.indexOf('etc-product-date') == -1) $('.term-setting').addClass('hide');
32255                    switch (value) {
32256                        case 'A':
32257                            $('input[name="day"]').prop('checked', true);
32258                            $('input[name="day"]').closest('label').addClass('checked');
32259                            termPicker.disabledDays = null;
32260                            break;
32261                        case 'W':
32262                            $('input[name="day"][value="sat"], input[name="day"][value="sun"]').prop('checked', false)
32263                            $('input[name="day"][value="sat"], input[name="day"][value="sun"]').closest('label').removeClass('checked');
32264                            $('input[name="day"]').not('[value="sat"],[value="sun"]').prop('checked', true);
32265                            $('input[name="day"]').not('[value="sat"],[value="sun"]').closest('label').addClass('checked');
32266                            termPicker.disabledDays = [0, 6];
32267                            break;
32268                        case 'K':
32269                            $('input[name="day"][value="sat"], input[name="day"][value="sun"]').prop('checked', true);
32270                            $('input[name="day"][value="sat"], input[name="day"][value="sun"]').closest('label').addClass('checked');
32271                            $('input[name="day"]').not('[value="sat"],[value="sun"]').prop('checked', false);
32272                            $('input[name="day"]').not('[value="sat"],[value="sun"]').closest('label').removeClass('checked');
32273                            termPicker.disabledDays = [1, 2, 3, 4, 5];
32274                            break;
32275                    }
32276
32277                    termPicker.setSelectedDates($('#etc-start-date-txt').val(), 'start');
32278                    termPicker.setSelectedDates($('#etc-end-date-txt').val(), 'end');
32279                });
32280
32281                $('input[name="day"]').on('change', function() {
32282                    if ($(this).is(':checked')) $(this).closest('label').addClass('checked');
32283                    else $(this).closest('label').removeClass('checked');
32284
32285                    if ($('input[name="day"]:checked').length == 0) {
32286                        alert($.lang[LANG]['config.form.date.day.excludeAll']);
32287                        $(this).prop('checked', true);
32288                        $(this).closest('label').addClass('checked');
32289                        return false;
32290                    }
32291
32292                    termPicker.disabledDays = null;
32293                    disabled = getDisabledDays();
32294
32295                    termPicker.disabledDays = disabled;
32296                    termPicker.setSelectedDates($('#etc-start-date-txt').val(), 'start');
32297                    termPicker.setSelectedDates($('#etc-end-date-txt').val(), 'end');
32298                });
32299                break;
32300            case 'excludeDate':
32301                var disabled = null;
32302                if (dateWeek == 'W') {
32303                    disabled = [0, 6];
32304                } else if (dateWeek == 'K') {
32305                    disabled = [1, 2, 3, 4, 5];
32306                }
32307                if (days.length > 0) {
32308                    disabled = [0, 1, 2, 3, 4, 5, 6];
32309                    $.each(days, function(i, v) {
32310                        enableIdx = disabled.indexOf(daysObj[v]);
32311                        if (enableIdx > -1) {
32312                            disabled.splice(enableIdx, 1);
32313                        }
32314                    });
32315                }
32316
32317                var exceptPicker = new Datepickk({
32318                    container: document.querySelector('#etc-except-date-picker'),
32319                    inline: true,
32320                    exp: true,
32321                    disabledDays: disabled,
32322                    lang: language,
32323                    minDate: new Date(1900, 0, 1),
32324                    maxDate: new Date(currentYear + 15, 11, 31),
32325                });
32326
32327                exceptPicker.disabledDays = (disabled.length > 0) ? disabled : null;
32328
32329                if (startDate && endDate) {
32330                    var checkStartDate = startDate.split('.');
32331                    var checkEndDate = endDate.split('.');
32332
32333                    exceptPicker.minDate = new Date(Number(checkStartDate[0]), Number(checkStartDate[1]) - 1, Number(checkStartDate[2]));
32334                    exceptPicker.maxDate = new Date(Number(checkEndDate[0]), Number(checkEndDate[1]) - 1, Number(checkEndDate[2]));
32335                }
32336
32337                displaySelectedDates();
32338
32339                $('.unselect-all').on('click', function() {
32340                    $('#select-except-date').val('');
32341                    $('#etc-except-date-picker input').prop('checked', false);
32342                    $('#etc-except-date-picker input').removeClass('active');
32343                });
32344
32345                break;
32346            case 'saleStartDateTime':
32347            case 'saleEndDateTime':
32348                var saleStartDateTime = $('#sale-start-datetime').val();
32349                var saleEndDateTime = $('#sale-end-datetime').val();
32350                startDate = saleStartDateTime.split(' ')[0];
32351                endDate = saleEndDateTime.split(' ')[0];
32352                var startTime = saleStartDateTime.split(' ')[1];
32353                var endTime = saleEndDateTime.split(' ')[1];
32354
32355                var currentDateTime = new Date();
32356                currentDateTime.setDate(currentDateTime.getDate() - 1);
32357                // console.log('currentDateTime', currentDateTime, new Date());
32358
32359                var datepickkObj = {
32360                    container: document.querySelector('#sale-datepicker'),
32361                    inline: true,
32362                    range: false,
32363                    exp: false,
32364                    lang: language,
32365                    startDate: (startDate)? startDate : currentDateTime,
32366                    minDate: currentDateTime,
32367                    maxDate: new Date(currentYear + 15, 11, 31),
32368                };
32369                
32370                if(func == 'saleStartDateTime') {
32371                    if(saleStartDateTime) {
32372                        $('#select-date-ymd').val(startDate.replace(/-/g, '.'));
32373                    } else {
32374                        $('.setting-sale-date').addClass('open');
32375                    }
32376                }
32377                console.log('currentDateTime', currentDateTime);
32378                if(func == 'saleEndDateTime') {
32379                    var datepickk_startDate = currentDateTime;
32380
32381                    if(saleStartDateTime) {
32382                        datepickk_startDate = (new Date() > new Date(saleStartDateTime))? new Date() : new Date(saleStartDateTime.replace(/-/g, '/'));
32383                        console.log('datepickk_startDate', datepickk_startDate);
32384                        datepickk_startDate.setDate(datepickk_startDate.getDate() - 1);
32385                    }
32386                    if(saleEndDateTime) {
32387                        $('#select-date-ymd').val(endDate.replace(/-/g, '.'));
32388                        if(new Date() > new Date(saleEndDateTime)) {
32389                            datepickk_startDate = new Date();
32390                            datepickk_startDate.setDate(datepickk_startDate.getDate() - 1);
32391                        }
32392                    } else {
32393                        $('.setting-sale-date').addClass('open');
32394                    }
32395
32396                    datepickkObj = {
32397                        container: document.querySelector('#sale-datepicker'),
32398                        inline: true,
32399                        range: false,
32400                        exp: false,
32401                        lang: language,
32402                        startDate: (endDate)? endDate : datepickk_startDate,
32403                        minDate: datepickk_startDate,
32404                        maxDate: new Date(currentYear + 15, 11, 31),
32405                    };
32406                }
32407                var termPicker = new Datepickk(datepickkObj);
32408                displaySelectedDates();
32409                
32410                $('.time-interval').each(function(i, v) {
32411                    var mna = $(v).data('time');
32412                    var times = '\
32413                        <input type="radio" id="' + mna + '-12-00" class="hide" name="sale_time" value="1200">\
32414                        <label for="' + mna + '-12-00">12:00</label>\
32415                        <input type="radio" id="' + mna + '-12-30" class="half-time hide" name="sale_time" value="1230">\
32416                        <label for="' + mna + '-12-30" class="half-time">12:30</label>\
32417                        \
32418                        <input type="radio" id="' + mna + '-1-00" class="hide" name="sale_time" value="
324180100">\
32419                        <label for="' + mna + '-1-00">1:00</label>\
32420                        <input type="radio" id="' + mna + '-1-30" class="half-time hide" name="sale_time" value="0130">\
32421                        <label for="' + mna + '-1-30" class="half-time">1:30</label>\
32422                        \
32423                        <input type="radio" id="' + mna + '-2-00" class="hide" name="sale_time" value="0200">\
32424                        <label for="' + mna + '-2-00">2:00</label>\
32425                        <input type="radio" id="' + mna + '-2-30" class="half-time hide" name="sale_time" value="0230">\
32426                        <label for="' + mna + '-2-30" class="half-time">2:30</label>\
32427                        \
32428                        <input type="radio" id="' + mna + '-3-00" class="hide" name="sale_time" value="0300">\
32429                        <label for="' + mna + '-3-00">3:00</label>\
32430                        <input type="radio" id="' + mna + '-3-30" class="half-time hide" name="sale_time" value="0330">\
32431                        <label for="' + mna + '-3-30" class="half-time">3:30</label>\
32432                        \
32433                        <input type="radio" id="' + mna + '-4-00" class="hide" name="sale_time" value="
324330400">\
32434                        <label for="' + mna + '-4-00">4:00</label>\
32435                        <input type="radio" id="' + mna + '-4-30" class="half-time hide" name="sale_time" value="0430">\
32436                        <label for="' + mna + '-4-30" class="half-time">4:30</label>\
32437                        \
32438                        <input type="radio" id="' + mna + '-5-00" class="hide" name="sale_time" value="0500">\
32439                        <label for="' + mna + '-5-00">5:00</label>\
32440                        <input type="radio" id="' + mna + '-5-30" class="half-time hide" name="sale_time" value="0530">\
32441                        <label for="' + mna + '-5-30" class="half-time">5:30</label>\
32442                        \
32443                        <input type="radio" id="' + mna + '-6-00" class="hide" name="sale_time" value="0600">\
32444                        <label for="' + mna + '-6-00">6:00</label>\
32445                        <input type="radio" id="' + mna + '-6-30" class="half-time hide" name="sale_time" value="0630">\
32446                        <label for="' + mna + '-6-30" class="half-time">6:30</label>\
32447                        \
32448                        <input type="radio" id="' + mna + '-7-00" class="hide" name="sale_time" value="
324480700">\
32449                        <label for="' + mna + '-7-00">7:00</label>\
32450                        <input type="radio" id="' + mna + '-7-30" class="half-time hide" name="sale_time" value="0730">\
32451                        <label for="' + mna + '-7-30" class="half-time">7:30</label>\
32452                        \
32453                        <input type="radio" id="' + mna + '-8-00" class="hide" name="sale_time" value="0800">\
32454                        <label for="' + mna + '-8-00">8:00</label>\
32455                        <input type="radio" id="' + mna + '-8-30" class="half-time hide" name="sale_time" value="0830">\
32456                        <label for="' + mna + '-8-30" class="half-time">8:30</label>\
32457                        \
32458                        <input type="radio" id="' + mna + '-9-00" class="hide" name="sale_time" value="0900">\
32459                        <label for="' + mna + '-9-00">9:00</label>\
32460                        <input type="radio" id="' + mna + '-9-30" class="half-time hide" name="sale_time" value="0930">\
32461                        <label for="' + mna + '-9-30" class="half-time">9:30</label>\
32462                        \
32463                        <input type="radio" id="' + mna + '-10-00" class="hide" name="sale_time" value="1000">\
32464                        <label for="' + mna + '-10-00">10:00</label>\
32465                        <input type="radio" id="' + mna + '-10-30" class="half-time hide" name="sale_time" value="1030">\
32466                        <label for="' + mna + '-10-30" class="half-time">10:30</label>\
32467                        \
32468                        <input type="radio" id="' + mna + '-11-00" class="hide" name="sale_time" value="1100">\
32469                        <label for="' + mna + '-11-00">11:00</label>\
32470                        <input type="radio" id="' + mna + '-11-30" class="half-time hide" name="sale_time" value="1130">\
32471                        <label for="' + mna + '-11-30" class="half-time">11:30</label>\
32472                        ';
32473                    $(v).html(times);
32474                }); //end each
32475
32476                $('input[name="time_interval"][value="' + interval + '"]').prop('checked', true);
32477
32478                if(func == 'saleStartDateTime' && saleStartDateTime) {
32479                    var hour = parseInt(startTime.split(':')[0]);
32480                    var minute = parseInt(startTime.split(':')[1]);
32481                    var mna = 'am';
32482                    if(hour >= 12) {
32483                        if (hour > 12) hour -= 12;
32484                        mna = 'pm';   
32485                    } else if (hour == 0) hour += 12
32486                    var formattedTime = hour.toString().padStart(2, '0') + minute.toString().padStart(2, '0');
32487                    $('.time-interval[data-time="' + mna + '"] input[value="' + formattedTime + '"]').prop('checked', true);
32488                    getDateTimeStr(language);
32489                }
32490 
32491                if(func == 'saleEndDateTime') {
32492                    if(saleStartDateTime && startDate == endDate) {
32493                        var hour = parseInt(startTime.split(':')[0]);
32494                        var minute = parseInt(startTime.split(':')[1]);
32495                        var mna = (hour >= 12)? 'pm' : 'am';
32496
32497                        if(hour >= 12) {
32498                            if (hour > 12) hour -= 12;
32499                        } else if (hour == 0) hour += 12
32500
32501                        var formattedStartTime = hour.toString().padStart(2, '0') + minute.toString().padStart(2, '0');
32502                        $('.time-interval[data-time="' + mna + '"] input[value="' + formattedStartTime + '"]').prop('disabled', true);
32503                        if(mna == 'pm') {
32504                            $('.time-interval[data-time="am"] input').prop('disabled', true);
32505                            $('.time-interval[data-time="pm"] input[value="' + formattedStartTime + '"]').prevAll('input').prop('disabled', true);
32506                        } else {
32507                            $('.time-interval[data-time="am"] input[value="' + formattedStartTime + '"]').prevAll('input').prop('disabled', true);
32508                        }
32509                    }
32510                    if(saleEndDateTime) {
32511                        var hour = parseInt(endTime.split(':')[0]);
32512                        var minute = parseInt(endTime.split(':')[1]);
32513                        var mna = 'am';
32514                        if(hour >= 12) {
32515                            if (hour > 12) hour -= 12;
32516                            mna = 'pm';   
32517                        } else if (hour == 0) hour += 12
32518                        var formattedTime = hour.toString().padStart(2, '0') + minute.toString().padStart(2, '0');
32519                        $('.time-interval[data-time="' + mna + '"] input[value="' + formattedTime + '"]').prop('checked', true);
32520                        getDateTimeStr(language);
32521                    }
32522                }
32523
32524                var time_interval = $('input[name="time_interval"]:checked').val();
32525
32526                switch (time_interval) {
32527                    case 10:
32528                        dateTimeModal.find('.time-interval label.ten-time').removeClass('hide');
32529                        break;
32530                    case 20:
32531                        dateTimeModal.find('.time-interval label.twt-time').removeClass('hide');
32532                        break;
32533                    case 30:
32534                        dateTimeModal.find('.time-interval label.half-time').removeClass('hide');
32535                        break;
32536                    case 60:
32537                        dateTimeModal.find('.time-interval label').removeClass('hide');
32538                        break;
32539                }
32540
32541                $('input[name="time_interval"]').on('change', function() {
32542                    if ($(this).val() == 60) {
32543                        $('.time-interval label.half-time').addClass('hide');
32544                        if ($('#all-time-select').is(':checked')) {
32545                            $('.time-interval input.o-time').prop('checked', true);
32546                        }
32547                    } else { //30
32548                        $('.time-interval label.half-time').removeClass('hide');
32549                        if ($('#all-time-select').is(':checked')) {
32550                            $('.time-interval input').prop('checked', true);
32551                        }
32552                    }
32553                });
32554
32555                $('.time-interval input').on('change', function(){
32556                    getDateTimeStr(language, 'time');
32557                });
32558
32559                $('.sale-calendar-box .setting-label').on('click', function(){
32560                    var $saleCalendarBox = $(this).closest('.sale-calendar-box');
32561
32562                    if($saleCalendarBox.hasClass('open')) {
32563                        $('.sale-calendar-box .setting-datetime-input').slideUp(400, function(){
32564                            $('.sale-calendar-box').removeClass('open');
32565                        });
32566                    } else{
32567                        $('.sale-calendar-box .setting-datetime-input').slideUp(400, function(){
32568                            $('.sale-calendar-box').removeClass('open');
32569                        });
32570
32571                        $saleCalendarBox.find('.setting-datetime-input').slideDown(400, function(){
32572                            $saleCalendarBox.addClass('open');
32573                        });
32574                    }
32575                });
32576
32577                break;
32578            case 'time':
32579                $('.time-interval').each(function(i, v) {
32580                    var mna = $(v).data('time');
32581                    var times = '\
32582                    <input type="checkbox" id="'+mna+'-12-00" class="o-time hide" name="'+mna+'" value="1200">\
32583                    <label for="'+mna+'-12-00" class="o-time">12:00</label>\
32584                    \
32585                    <input type="checkbox" id="'+mna+'-12-10" class="ten-time hide" name="'+mna+'" value="1210">\
32586                    <label for="'+mna+'-12-10" class="ten-time">12:10</label>\
32587                    \
32588                    <input type="checkbox" id="'+mna+'-12-20" class="ten-time twt-time hide" name="'+mna+'" value="1220">\
32589                    <label for="'+mna+'-12-20" class="ten-time twt-time">12:20</label>\
32590                    \
32591                    <input type="checkbox" id="'+mna+'-12-30" class="ten-time half-time hide" name="'+mna+'" value="1230">\
32592                    <label for="'+mna+'-12-30" class="ten-time half-time">12:30</label>\
32593                    \
32594                    <input type="checkbox" id="'+mna+'-12-40" class="ten-time twt-time hide" name="'+mna+'" value="1240">\
32595                    <label for="'+mna+'-12-40" class="ten-time twt-time">12:40</label>\
32596                    \
32597                    <input type="checkbox" id="'+mna+'-12-50" class="ten-time hide" name="'+mna+'" value="1250">\
32598                    <label for="'+mna+'-12-50" class="ten-time">12:50</label>\
32599                    ';
32600
32601                    for(let t = 1; t <= 11; t++) {
32602                        let hstr = t.toString().padStart(2, '0');
32603                        times += '\
32604                            <input type="checkbox" id="'+mna+'-'+t+'-00" class="o-time hide" name="'+mna+'" value="'+hstr+'00">\
32605                            <label for="'+mna+'-'+t+'-00" class="o-time">'+t+':00</label>\
32606                            \
32607                            <input type="checkbox" id="'+mna+'-'+t+'-10" class="ten-time hide" name="'+mna+'" value="'+hstr+'10">\
32608                            <label for="'+mna+'-'+t+'-10" class="ten-time">'+t+':10</label>\
32609                            \
32610                            <input type="checkbox" id="'+mna+'-'+t+'-20" class="ten-time twt-time hide" name="'+mna+'" value="'+hstr+'20">\
32611                            <label for="'+mna+'-'+t+'-20" class="ten-time twt-time">'+t+':20</label>\
32612                            \
32613                            <input type="checkbox" id="'+mna+'-'+t+'-30" class="ten-time half-time hide" name="'+mna+'" value="'+hstr+'30">\
32614                            <label for="'+mna+'-'+t+'-30" class="ten-time half-time">'+t+':30</label>\
32615                            \
32616                            <input type="checkbox" id="'+mna+'-'+t+'-40" class="ten-time twt-time hide" name="'+mna+'" value="'+hstr+'40">\
32617                            <label for="'+mna+'-'+t+'-40" class="ten-time twt-time">'+t+':40</label>\
32618                            \
32619                            <input type="checkbox" id="'+mna+'-'+t+'-50" class="ten-time hide" name="'+mna+'" value="'+hstr+'50">\
32620                            <label for="'+mna+'-'+t+'-50" class="ten-time">'+t+':50</label>\
32621                        ';
32622                    }
32623                    // var times = '\
32624                    //     <input type="checkbox" id="' + mna + '-12-00" class="hide" name="' + mna + '" value="1200">\
32625                    //     <label for="' + mna + '-12-00">12:00</label>\
32626                    //     <input type="checkbox" id="' + mna + '-12-30" class="half-time hide" name="' + mna + '" value="1230">\
32627                    //     <label for="' + mna + '-12-30" class="half-time">12:30</label>\
32628                    //     \
32629                    //     <input type="checkbox" id="' + mna + '-1-00" class="hide" name="' + mna + '" value="
326290100">\
32630                    //     <label for="' + mna + '-1-00">1:00</label>\
32631                    //     <input type="checkbox" id="' + mna + '-1-30" class="half-time hide" name="' + mna + '" value="0130">\
32632                    //     <label for="' + mna + '-1-30" class="half-time">1:30</label>\
32633                    //     \
32634                    //     <input type="checkbox" id="' + mna + '-2-00" class="hide" name="' + mna + '" value="0200">\
32635                    //     <label for="' + mna + '-2-00">2:00</label>\
32636                    //     <input type="checkbox" id="' + mna + '-2-30" class="half-time hide" name="' + mna + '" value="0230">\
32637                    //     <label for="' + mna + '-2-30" class="half-time">2:30</label>\
32638                    //     \
32639                    //     <input type="checkbox" id="' + mna + '-3-00" class="hide" name="' + mna + '" value="0300">\
32640                    //     <label for="' + mna + '-3-00">3:00</label>\
32641                    //     <input type="checkbox" id="' + mna + '-3-30" class="half-time hide" name="' + mna + '" value="0330">\
32642                    //     <label for="' + mna + '-3-30" class="half-time">3:30</label>\
32643                    //     \
32644                    //     <input type="checkbox" id="' + mna + '-4-00" class="hide" name="' + mna + '" value="0400">\
32645                    //     <label for="' + mna + '-4-00">4:00</label>\
32646                    //     <input type="checkbox" id="' + mna + '-4-30" class="half-time hide" name="' + mna + '" value="0430">\
32647                    //     <label for="' + mna + '-4-30" class="half-time">4:30</label>\
32648                    //     \
32649                    //     <input type="checkbox" id="' + mna + '-5-00" class="hide" name="' + mna + '" value="0500">\
32650                    //     <label for="' + mna + '-5-00">5:00</label>\
32651                    //     <input type="checkbox" id="' + mna + '-5-30" class="half-time hide" name="' + mna + '" value="0530">\
32652                    //     <label for="' + mna + '-5-30" class="half-time">5:30</label>\
32653                    //     \
32654                    //     <input type="checkbox" id="' + mna + '-6-00" class="hide" name="' + mna + '" value="0600">\
32655                    //     <label for="' + mna + '-6-00">6:00</label>\
32656                    //     <input type="checkbox" id="' + mna + '-6-30" class="half-time hide" name="' + mna + '" value="0630">\
32657                    //     <label for="' + mna + '-6-30" class="half-time">6:30</label>\
32658                    //     \
32659                    //     <input type="checkbox" id="' + mna + '-7-00" class="hide" name="' + mna + '" value="0700">\
32660                    //     <label for="' + mna + '-7-00">7:00</label>\
32661                    //     <input type="checkbox" id="' + mna + '-7-30" class="half-time hide" name="' + mna + '" value="0730">\
32662                    //     <label for="' + mna + '-7-30" class="half-time">7:30</label>\
32663                    //     \
32664                    //     <input type="checkbox" id="' + mna + '-8-00" class="hide" name="' + mna + '" value="0800">\
32665                    //     <label for="' + mna + '-8-00">8:00</label>\
32666                    //     <input type="checkbox" id="' + mna + '-8-30" class="half-time hide" name="' + mna + '" value="0830">\
32667                    //     <label for="' + mna + '-8-30" class="half-time">8:30</label>\
32668                    //     \
32669                    //     <input type="checkbox" id="' + mna + '-9-00" class="hide" name="' + mna + '" value="0900">\
32670                    //     <label for="' + mna + '-9-00">9:00</label>\
32671                    //     <input type="checkbox" id="' + mna + '-9-30" class="half-time hide" name="' + mna + '" value="0930">\
32672                    //     <label for="' + mna + '-9-30" class="half-time">9:30</label>\
32673                    //     \
32674                    //     <input type="checkbox" id="' + mna + '-10-00" class="hide" name="' + mna + '" value="1000">\
32675                    //     <label for="' + mna + '-10-00">10:00</label>\
32676                    //     <input type="checkbox" id="' + mna + '-10-30" class="half-time hide" name="' + mna + '" value="1030">\
32677                    //     <label for="' + mna + '-10-30" class="half-time">10:30</label>\
32678                    //     \
32679                    //     <input type="checkbox" id="' + mna + '-11-00" class="hide" name="' + mna + '" value="1100">\
32680                    //     <label for="' + mna + '-11-00">11:00</label>\
32681                    //     <input type="checkbox" id="' + mna + '-11-30" class="half-time hide" name="' + mna + '" value="1130">\
32682                    //     <label for="' + mna + '-11-30" class="half-time">11:30</label>\
32683                    //     ';
32684                    $(v).html(times);
32685                }); //end each
32686
32687                $('input[name="time_interval"][value="' + interval + '"]').prop('checked', true);
32688                if (am) {
32689                    $.each(am, function(i, v) {
32690                        $('.time-interval[data-time="am"] input[value="' + v + '"]').prop('checked', true);
32691                        $('.time-interval[data-time="am"] input[value="' + v + '"] + label').addClass('ui-selected');
32692                    });
32693                }
32694                if (pm) {
32695                    $.each(pm, function(i, v) {
32696                        $('.time-interval[data-time="pm"] input[value="' + v + '"]').prop('checked', true);
32697                        $('.time-interval[data-time="pm"] input[value="' + v + '"] + label').addClass('ui-selected');
32698                    });
32699                }
32700
32701                var time_interval = $('input[name="time_interval"]:checked').val();
32702                // if (time_interval == 60) {
32703                //     $('.time-interval label.half-time').addClass('hide');
32704                // } else { //30
32705                //     $('.time-interval label.half-time').removeClass('hide');
32706                // }
32707                // console.log('time_interval', time_interval);
32708                $('.time-interval label:not(.o-time)').addClass('hide');
32709                switch (time_interval) {
32710                    case '10':
32711                        $('.time-interval label').removeClass('hide');
32712                        break;
32713                    case '20':
32714                        $('.time-interval label.twt-time').removeClass('hide');
32715                        break;
32716                    case '30':
32717                        $('.time-interval label.half-time').removeClass('hide');
32718                        break;
32719                }
32720
32721                $('input[name="time_interval"]').on('change', function() {
32722                    let time_interval = $(this).val();
32723                    // if ($(this).val() == 60) {
32724                    //     $('.time-interval label.half-time').addClass('hide');
32725                    //     if ($('#all-time-select').is(':checked')) {
32726                    //         $('.time-interval input:not(.half-time)').prop('checked', true);
32727                    //     }
32728                    // } else { //30
32729                    //     $('.time-interval label.half-time').removeClass('hide');
32730                    //     if ($('#all-time-select').is(':checked')) {
32731                    //         $('.time-interval input').prop('checked', true);
32732                    //     }
32733                    // }
32734                    $('.time-interval label:not(.o-time)').addClass('hide');
32735
32736                    switch (time_interval) {
32737                        case '10':
32738                            $('.time-interval label').removeClass('hide');
32739                            if ($('#all-time-select').is(':checked')) {
32740                                $('.time-interval input').prop('checked', true);
32741                                $('.time-interval input + label').addClass('ui-selected');
32742                            }
32743                            break;
32744                        case '20':
32745                            $('.time-interval label.twt-time').removeClass('hide');
32746                            if ($('#all-time-select').is(':checked')) {
32747                                $('.time-interval input.twt-time').prop('checked', true);
32748                                $('.time-interval input.twt-time + label').addClass('ui-selected');
32749
32750                            }
32751                            break;
32752                        case '30':
32753                            $('.time-interval label.half-time').removeClass('hide');
32754                            if ($('#all-time-select').is(':checked')) {
32755                                $('.time-interval input.half-time').prop('checked', true);
32756                            }
32757                            break;
32758                        case '60':
32759                            if ($('#all-time-select').is(':checked')) {
32760                                $('.time-interval input.o-time').prop('checked', true);
32761                            }
32762                            break;
32763                    }
32764                });
32765
32766                isSelectedAllTimes();
32767
32768                $('#all-time-select').change(function() {
32769                    var time_interval = $('input[name="time_interval"]:checked').val();
32770                    if ($(this).is(':checked')) {
32771                        $('.time-interval label').prev('input').prop('checked', true);
32772                        $('.time-interval label').addClass('ui-selected');
32773                    } else {
32774                        $('.time-interval input').prop('checked', false);
32775                        $('.time-interval label').removeClass('ui-selected');
32776                    }
32777                });
32778
32779                $('.time-interval[data-time] input[type=checkbox]').on('change', function(){
32780                    timeSelect($(this).next('label'), 'click');
32781                    isSelectedAllTimes();
32782                });
32783
32784                $('.setting-form-option-date2').closest('.modal').mousedown(function(e) {
32785                    e.metaKey = true; // Mac에서는 Command 키, Windows에서는 Ctrl 키 역할
32786                }).selectableScroll({
32787                    filter: 'label',
32788                    cancel: 'input[type=radio], .newcheckbox label, #all-time-select, label.all-time, button',
32789                    delay: 100,
32790                    selected: function(e, ui) {
32791                        timeSelect(ui.selected);
32792                    },
32793                    stop: function(e, ui) {
32794                        $('.time-interval[data-time] label').each(function(idx, v) {
32795                            if($(v).hasClass('.all-time')) return true;
32796                            let chk = $("#" + $(v).attr("for"));
32797                            // console.log('chk', chk);
32798                            if(chk.is(':checked')) {
32799                                $(v).addClass('ui-selected');
32800                            } else {
32801                                $(v).removeClass('ui-selected');
32802                            }
32803                        });
32804                    
32805                        isSelectedAllTimes();
32806                    },
32807                });
32808                break;
32809        }
32810
32811        $(document).off('click', '.d-year, .d-month');
32812        $(document).on('click', '.d-year, .d-month', function() {
32813            $('.d-month-year-picker').toggleClass('d-show');
32814            scrollToCurrentYearMonth();
32815        });
32816
32817        function timeSelect(label, action) {
32818            if(typeof action == 'undefined') action = '';
32819            // console.log(label);
32820            let interval = $('input[name=time_interval]:checked').val();
32821            let chk = $("#" + $(label).attr('for'));
32822            let t = chk.prevAll('input.ten-time');
32823            // console.log('chk', chk);
32824            if(action == 'click') {
32825                if(chk.is(':checked')) {
32826                    label.addClass('ui-selected'); // 체크박스 선택
32827                } else {
32828                    label.removeClass('ui-selected'); // 체크박스 선택
32829                }
32830            } else {
32831                if(chk.is(':checked')) {
32832                    chk.prop("checked", false); // 체크박스 선택
32833                } else {
32834                    chk.prop("checked", true); // 체크박스 선택
32835                }
32836            }
32837            
32838            switch (interval) {
32839                case '20':
32840                    if(chk.is(':checked') && $(t[0]).prevAll('input.o-time, input.twt-time').first().is(':checked')) {
32841                        $(t[0]).prop('checked', true);
32842                        if(action == 'click') $(t[0]).next('label').addClass('ui-selected');
32843                    } else {
32844                        $(t[0]).prop('checked', false);
32845                        if(action == 'click') $(t[0]).next('label').removeClass('ui-selected');
32846                    }
32847                    break;
32848                case '30':
32849                    if(chk.is(':checked') && $(t[0]).prevAll('input.o-time, input.half-time').first().is(':checked')) {
32850                        $(t[0]).prop('checked', true);
32851                        $(t[1]).prop('checked', true);
32852                        if(action == 'click') {
32853                            $(t[0]).next('label').addClass('ui-selected');
32854                            $(t[1]).next('label').addClass('ui-selected');
32855                        }
32856                    } else {
32857                        $(t[0]).prop('checked', false);
32858                        $(t[1]).prop('checked', false);
32859                        if(action == 'click') {
32860                            $(t[0]).next('label').removeClass('ui-selected');
32861                            $(t[1]).next('label').removeClass('ui-selected');
32862                        }                        
32863                    }
32864
32865                    break;
32866                case '60':
32867                    if(chk.is(':checked') && $(t[0]).prevAll('input.o-time').first().is(':checked')) {
32868                        $(t[0]).prop('checked', true);
32869                        $(t[1]).prop('checked', true);
32870                        $(t[2]).prop('checked', true);
32871                        $(t[3]).prop('checked', true);
32872                        $(t[4]).prop('checked', true);
32873                        if(action == 'click') {
32874                            $(t[0]).next('label').addClass('ui-selected');
32875                            $(t[1]).next('label').addClass('ui-selected');
32876                            $(t[2]).next('label').addClass('ui-selected');
32877                            $(t[3]).next('label').addClass('ui-selected');
32878                            $(t[4]).next('label').addClass('ui-selected');
32879                        }                        
32880                    } else {
32881                        $(t[0]).prop('checked', false);
32882                        $(t[1]).prop('checked', false);
32883                        $(t[2]).prop('checked', false);
32884                        $(t[3]).prop('checked', false);
32885                        $(t[4]).prop('checked', false);
32886                        if(action == 'click') {
32887                            $(t[0]).next('label').removeClass('ui-selected');
32888                            $(t[1]).next('label').removeClass('ui-selected');
32889                            $(t[2]).next('label').removeClass('ui-selected');
32890                            $(t[3]).next('label').removeClass('ui-selected');
32891                            $(t[4]).next('label').removeClass('ui-selected');
32892                        }                                                
32893                    }
32894                    
32895                    break;
32896            }
32897        }
32898
32899        function isSelectedAllTimes() {
32900            let interval = $('input[name=time_interval]:checked').val();
32901            let am = $('.time-interval[data-time="am"] label:not(.hide)').prev('input[type="checkbox"]:checked');
32902            let pm = $('.time-interval[data-time="pm"] label:not(.hide)').prev('input[type="checkbox"]:checked');
32903            let timeCnt = am.length + pm.length;
32904            // console.log('timeCnt', timeCnt);
32905            let allTimeChecked = '';
32906            if (interval == '10' && timeCnt == 144) allTimeChecked = 'checked';
32907            if (interval == '20' && timeCnt == 72) allTimeChecked = 'checked';
32908            if (interval == '30' && timeCnt == 48) allTimeChecked = 'checked';
32909            if (interval == '60' && timeCnt == 24) allTimeChecked = 'checked';
32910
32911            if(allTimeChecked) {
32912                $('#all-time-select').prop('checked', true);
32913            } else {
32914                $('#all-time-select').prop('checked', false);
32915            }
32916        }
32917    }, function() { //hide
32918        if (func == 'term' && (!$('#etc-start-date-txt').val() || !$('#etc-end-date-txt').val())) {
32919            if (!$('#etc-start-date-prev').val() && !$('#etc-end-date-prev').val()) {
32920                $('input[name="select_terms-' + id + '"][value="N"]').prop('checked', true);
32921                $('.form-sort-item[data-id="' + id + '"] .setting-date2[data-setting="term"]').addClass('disabled');
32922            }
32923        }
32924        settingModal.modal('hide');
32925    });
32926}
32927
32928var calendarDateTime = function(el, id, type, se, fulltime, locale) {
32929    var field_type = 'sale-product-datetime';
32930    var func = (se == 'sdate') ? 'saleStartDateTime' : 'saleEndDateTime';
32931
32932    var sid = (typeof property != 'undefined') ? property.SID : SID;
32933    var blocklang = locale;
32934    var field_setting = {};
32935    var etcDateState = 'N';
32936    var $scopeCtx = (typeof selectEL !== 'undefined') ? $('.' + el) : $('.calendar-modal-container');
32937    var isAllDay = $scopeCtx.find('input.all-day').is(':checked');
32938
32939    //기본값
32940    $default_term = {
32941        'select_terms' : 'N',
32942        'start_date' : '',
32943        'end_date' : '',
32944        'date_week' : 'A',
32945        'days' : 'sun|mon|tue|wed|thu|fri|sat',
32946    };
32947    $default_excludeDate = {'date' : ''};
32948    $default_time = {
32949        'interval' : '30',
32950        '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',
32951        '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'
32952    };
32953    $default_color = {'highlight' : '4789e7'};
32954
32955    field_setting = {
32956        'term' : $default_term,
32957        'excludeDate' : $default_excludeDate,
32958        'time' : $default_time,
32959        'color' : $default_color,
32960    };
32961
32962    var term = (field_setting.term)? field_setting.term:{};
32963    var excludeDate = (field_setting.excludeDate)? field_setting.excludeDate:{};
32964    var time = (type != 'date' && field_setting.time)? field_setting.time:{};
32965    var color = (field_setting.color)? field_setting.color:{};
32966
32967    var startDate = (term.start_date !== undefined)? term.start_date:''; 
32968    var endDate = (term.end_date !== undefined)? term.end_date:'';
32969    var dateWeek = (term.date_week !== undefined)? term.date_week:'';
32970    var days = (term.days !== undefined)? term.days.split('|'):[];
32971    var daysObj = {
32972        'sun': 0, 'mon': 1, 'tue': 2, 'wed': 3, 'thu': 4, 'fri': 5, 'sat': 6,
32973    }
32974
32975    var exceptDate = (excludeDate.date !== undefined) ? excludeDate.date : '';
32976
32977    var interval = (time.interval !== undefined) ? time.interval : '30';
32978    var am = (time.am !== undefined) ? time.am.split('|') : [];
32979    var pm = (time.pm !== undefined) ? time.pm.split('|') : [];
32980    var timeCnt = am.length + pm.length;
32981    var language = (locale != 'ko') ? 'en' : 'ko';
32982    var blocklang = ($('[form-seq="' + id + '"]').closest('.element').attr('data-blocklang')) ? $('[form-seq="' + id + '"]').closest('.element').attr('data-blocklang') : locale;
32983
32984    var modal_title = '';
32985    var modal_str = '';
32986    var modal_class = 'modal-dialog cl-cmmodal cl-s-btn setting-form-option-date2 cl-close-btn cover';
32987    
32988    modal_class = 'modal-dialog cl-cmmodal cl-s-btn setting-form-option-date2 setting-product-sale-datetime cl-close-btn cover';
32989    var timeClass = 'start-time';
32990    if(func == 'saleStartDateTime') {
32991        // modal_title = '시작 날짜/시간 선택';
32992        modal_title = $.lang[locale]['config.calendar.sdate'];
32993        modal_str = '\
32994        <div class="term-calendar-box sale-calendar-box setting-sale-date">\
32995            <div class="setting-label display-flex align-items-center space-between">\
32996                <div class="display-flex align-items-center">\
32997                    <span>'+ $.lang[locale]['config.calendar.date'] +'</span>\
32998                    <span class="start-date datetime-txt" data-blocklang="' + blocklang + '"></span>\
32999                </div>\
33000                <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>\
33001            </div>\
33002            <div class="setting-datetime-input" data-type="' + func + '">\
33003                <input type="hidden" id="select-calendar" value="term-datepicker">\
33004                <input type="hidden" id="select-date-ymd" value="">\
33005                <input type="hidden" id="etc-start-date-prev" value="">\
33006                <input type="hidden" id="etc-start-date-txt" value="">\
33007                <input type="hidden" id="clang" value="'+ locale +'">\
33008                <div id="sale-datepicker"></div>\
33009            </div>\
33010        </div>\
33011        ';
33012    } else {
33013        // modal_title = '종료 날짜/시간 선택';
33014        modal_title = $.lang[locale]['config.calendar.edate'];
33015        modal_str = '\
33016        <div class="term-calendar-box sale-calendar-box setting-sale-date">\
33017            <div class="setting-label display-flex align-items-center space-between">\
33018                <div class="display-flex align-items-center">\
33019                    <span>'+ $.lang[locale]['config.calendar.date'] +'</span>\
33020                    <span class="end-date datetime-txt" data-blocklang="' + blocklang + '"></span>\
33021                </div>\
33022                <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>\
33023            </div>\
33024            <div class="setting-datetime-input" data-type="' + func + '">\
33025                <input type="hidden" id="select-calendar" value="term-datepicker">\
33026                <input type="hidden" id="select-date-ymd" value="">\
33027                <input type="hidden" id="etc-start-date-prev" value="">\
33028                <input type="hidden" id="etc-start-date-txt" value="">\
33029                <input type="hidden" id="etc-end-date-prev" value="">\
33030                <input type="hidden" id="etc-end-date-txt" value="">\
33031                <input type="hidden" id="clang" value="'+ locale +'">\
33032                <div id="sale-datepicker"></div>\
33033            </div>\
33034        </div>\
33035        ';
33036        timeClass = 'end-time';
33037    }
33038    
33039    modal_str += '\
33040        <div class="term-calendar-box sale-calendar-box setting-sale-time">\
33041            <div class="setting-label display-flex align-items-center space-between">\
33042                <div class="display-flex align-items-center">\
33043                    <span>'+ $.lang[locale]['config.calendar.time'] +'</span>\
33044                    <span class="'+timeClass+' datetime-txt" data-blocklang="' + blocklang + '"></span>\
33045                </div>\
33046                <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>\
33047            </div>\
33048            <div class="setting-datetime-input" data-type="' + func + '" style="display:none;">\
33049                <div class="display-flex align-items-center setting-row">\
33050                    <div class="setting-label">' + $.lang[locale]['config.form.date2.time.interval.label'] + '</div>\
33051                    <div class="newcheckbox hand">\
33052                        <label>\
33053                            <div class="newcheckboxSvgRadio">\
33054                                <input type="radio" class="cl-common-form-radio-hide" name="time_interval" value="30" checked>\
33055                                <svg viewBox="0 0 18 18" width="18" height="18">\
33056                                    <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 
330560-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
33057                                </svg>\
33058                                <svg class="active" viewBox="0 0 18 18" width="18" height="18">\
33059                                    <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>\
33060                                    <circle cx="9" cy="9" r="6"></circle>\
33061                                </svg>\
33062                            </div>\
33063                            <span>' + $.lang[locale]['config.form.date2.time.interval.30'] + '</span>\
33064                        </label>\
33065                    </div>\
33066                    <div class="newcheckbox hand">\
33067                        <label>\
33068                            <div class="newcheckboxSvgRadio">\
33069                                <input type="radio" class="cl-common-form-radio-hide" name="time_interval" value="60">\
33070                                <svg viewBox="0 0 18 18" width="18" height="18">\
33071                                    <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>\
33072                                </svg>\
33073                                <svg class="active" viewBox="0 0 18 18" width="18" height="18">\
33074                                    <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>\
33075                                    <circle cx="9" cy="9" r="6"></circle>\
33076                                </svg>\
33077                            </div>\
33078                            <span>' + $.lang[locale]['config.form.date2.time.interval.60'] + '</span>\
33079                        </label>\
33080                    </div>\
33081                </div>\
33082                <div class="setting-row am">\
33083                    <div class="setting-label">' + $.lang[locale]['config.form.date2.time.am'] + '</div>\
33084                    <div class="display-flex time-interval" data-time="am"></div>\
33085                </div>\
33086                <div class="setting-row">\
33087                    <div class="setting-label">' + $.lang[locale]['config.form.date2.time.pm'] + '</div>\
33088                    <div class="display-flex time-interval" data-time="pm"></div>\
33089                </div>\
33090            </div>\
33091        </div>\
33092    ';
33093
33094    var settingModal = $(el).showModalFlat(modal_title, modal_str, true, true, function() { //confirm
33095        function splitHHmm(hmRaw) {
33096            var hm = String(hmRaw).replace(/[^0-9]/g, '').padStart(4, '0'); 
33097            return { hh: hm.slice(0, 2), mm: hm.slice(2, 4) };
33098        }
33099        switch (func) {
33100            case 'saleStartDateTime': {
33101                const selectedDate = $('#select-date-ymd').val();
33102                const $timeChecked = $('.time-interval input:checked');
33103                if (!selectedDate || (!isAllDay && $timeChecked.length === 0)) {
33104                    alert($.lang[locale]['config.calendar.enter-date']);
33105                    return false;
33106                }
33107
33108                let hh = '00', mm = '00';
33109                if (!isAllDay) {
33110                    const mna   = $timeChecked.closest('.time-interval').data('time');
33111                    const hmRaw = convertTime24(mna, $timeChecked.val());
33112                    ({ hh, mm } = splitHHmm(hmRaw)); 
33113                }
33114
33115                const dateDash        = selectedDate.replace(/\./g, '-');
33116                const saleDateTimeVal = `${dateDash} ${hh}:${mm}:00`;
33117                const saleDateTimeUI  = `${dateDash} ${hh}:${mm}`;
33118
33119                $('.sale-setting .setting-text .content-start').text(isAllDay ? selectedDate : (selectedDate + '. ' + convertTime12(hh + mm)));
33120                $('#sale-start-datetime').val(saleDateTimeVal);
33121
33122                (function setStartInput(){
33123                    const $scope = (typeof selectEL !== 'undefined') ? $('.' + el) : $('.calendar-modal-container');
33124                    const saleDateUI = isAllDay ? dateDash : `${dateDash} ${hh}:${mm}`;
33125                    $scope.find('.sdate .start').val(saleDateUI);
33126                })();
33127
33128                (function fixEndAfterStart() {
33129                    function parseLocal(str) {
33130                        if (!str) return null;
33131                        var p = str.trim().split(' ');
33132                        if (p.length < 2) return null;
33133                        var d = p[0].split('-').map(Number);
33134                        var t = p[1].split(':').map(Number);
33135                        return new Date(d[0], (d[1]||1)-1, d[2]||1, t[0]||0, t[1]||0, 0, 0);
33136                    }
33137                    function pad2(n){ return String(n).padStart(2,'0'); }
33138
33139                    const $scope    = (typeof selectEL !== 'undefined') ? $('.' + el) : $('.calendar-modal-container');
33140                    const endInput  = ($scope.find('.edate .end').val() || '').trim();
33141                    const endHidden = ($('#sale-end-datetime').val() || '').trim();
33142                    const endStr    = endInput || endHidden;
33143
33144                    const startDT = parseLocal(saleDateTimeVal);
33145                    const endDT   = parseLocal(endStr);
33146
33147                    if (!endDT || startDT >= endDT) {
33148                        let fixed = new Date(startDT.getTime());
33149                        if (isAllDay) {
33150                            fixed.setHours(23, 59, 0, 0);
33151                        } else {
33152                            fixed.setHours(fixed.getHours() + 1);
33153                        }
33154
33155                        const y = fixed.getFullYear();
33156                        const m = pad2(fixed.getMonth() + 1);
33157                        const d = pad2(fixed.getDate());
33158                        const H = pad2(fixed.getHours());
33159                        const M = pad2(fixed.getMinutes());
33160
33161                        $('#sale-end-datetime').val(`${y}-${m}-${d} ${H}:${M}:00`);
33162
33163                        if (isAllDay) {
33164                            $('.sale-setting .setting-text .content-end').text(`${y}-${m}-${d}`);
33165                        } else {
33166                            $('.sale-setting .setting-text .content-end').text(`${y}-${m}-${d}. ` + convertTime12(H + M));
33167                        }
33168
33169                        $scope.find('.edate .end').val(isAllDay ? `${y}-${m}-${d}` : `${y}-${m}-${d} ${H}:${M}`);
33170                    }
33171                })();
33172
33173                break;
33174            }
33175
33176            case 'saleEndDateTime': {
33177                const selectedDate = $('#select-date-ymd').val();
33178                const $timeChecked = $('.time-interval input:checked');
33179
33180                if (!selectedDate || (!isAllDay && $timeChecked.length === 0)) {
33181                    alert($.lang[locale]['config.calendar.enter-date']);
33182                    return false;
33183                }
33184
33185                let hh = '23', mm = '59';
33186                if (!isAllDay) {
33187                    const mna   = $timeChecked.closest('.time-interval').data('time');
33188                    const hmRaw = convertTime24(mna, $timeChecked.val());
33189                    ({ hh, mm } = splitHHmm(hmRaw));
33190                }
33191
33192                const dateDash        = selectedDate.replace(/\./g, '-');
33193                const saleDateTimeVal = `${dateDash} ${hh}:${mm}:00`;
33194                const saleDateTimeUI  = `${dateDash} ${hh}:${mm}`;
33195
33196                const startHidden = $('#sale-start-datetime').val();
33197                if (startHidden) {
33198                    const startDT = new Date(startHidden.replace(/-/g,'/'));
33199                    const endDT   = new Date(saleDateTimeVal.replace(/-/g,'/'));
33200                    if (startDT >= endDT) {
33201                        alert('시작 시간보다 나중 날짜' + (isAllDay ? '' : '/시간') + '을 선택해 주세요.');
33202                        return false;
33203                    }
33204                }
33205
33206                if (isAllDay) {
33207                    $('.sale-setting .setting-text .content-end').text(selectedDate);
33208                } else {
33209                    $('.sale-setting .setting-text .content-end').text(selectedDate + '. ' + convertTime12(hh + mm));
33210                }
33211                $('#sale-end-datetime').val(saleDateTimeVal);
33212
33213                (function setEndInput(){
33214                    const $scope = (typeof selectEL !== 'undefined') ? $('.' + el) : $('.calendar-modal-container');
33215                    const saleDateUI = isAllDay ? dateDash : `${dateDash} ${hh}:${mm}`;
33216                    $scope.find('.edate .end').val(saleDateUI);
33217                })();
33218                break;
33219            }
33220        }
33221
33222        // saveFormElement();
33223        settingModal.modal('hide');
33224    }, $.lang[locale]['config.cancel'], $.lang[locale]['config.ok'], modal_class, true, function() { //close
33225        
33226        settingModal.modal('hide');
33227    }, function() { //show
33228
33229        if (startDate && endDate) {
33230            var checkStartDate = startDate.split('.');
33231            var checkEndDate = endDate.split('.');
33232
33233            $('.term-setting').removeClass('hide');
33234            if (locale == 'ko') {
33235                $('.term-setting .start-date').text(checkStartDate[0] + '년 ' + checkStartDate[1] + '월 ' + checkStartDate[2] + ' 일');
33236                $('.term-setting .end-date').text(checkEndDate[0] + '년 ' + checkEndDate[1] + '월 ' + checkEndDate[2] + ' 일');
33237            } else {
33238                $('.term-setting .start-date').text(checkStartDate[1] + '/' + checkStartDate[2] + '/' + checkStartDate[0]);
33239                $('.term-setting .end-date').text(checkEndDate[1] + '/' + checkEndDate[2] + '/' + checkEndDate[0]);
33240            }
33241        }
33242
33243        $('#term-datepicker').html('');
33244        var currentYear = new Date().getFullYear();
33245        switch (func) {
33246            case 'saleStartDateTime':
33247            case 'saleEndDateTime': {
33248                var saleStartDateTime =
33249                    ($('.' + el).find('.calendar-modal-container .sdate .start').val() || '').trim() ||
33250                    ($('#sale-start-datetime').val() || '').trim();
33251                var saleEndDateTime =
33252                    ($('.' + el).find('.calendar-modal-container .edate .end').val() || '').trim() ||
33253                    ($('#sale-end-datetime').val() || '').trim();
33254
33255                function splitDateTime(str) {
33256                    if (!str) return { date: '', time: '' };
33257                    var date = str.slice(0, 10);
33258                    var time = (str.length >= 16) ? str.slice(11, 16) : '';
33259                    return { date: date, time: time };
33260                }
33261                var s = splitDateTime(saleStartDateTime);
33262                var e = splitDateTime(saleEndDateTime);
33263                var selStartDate = s.date;
33264                var selEndDate   = e.date;
33265                var selStartTime = s.time;
33266                var selEndTime   = e.time;
33267
33268                function toDateOnly(ymd) {
33269                    if (!ymd) return null;
33270                    var y = +ymd.slice(0, 4), m = +ymd.slice(5, 7) - 1, d = +ymd.slice(8, 10);
33271                    return new Date(y, m, d, 0, 0, 0, 0);
33272                }
33273                var selStartDateOnly = toDateOnly(selStartDate);
33274                var selEndDateOnly   = toDateOnly(selEndDate);
33275
33276                const MIN_DATE = new Date(1900, 0, 1);
33277                const MAX_DATE = new Date(currentYear + 15, 11, 31);
33278
33279                var datepickkObj = {
33280                    container: document.querySelector('#sale-datepicker'),
33281                    inline: true,
33282                    range: false,
33283                    exp: false,
33284                    lang: language,
33285                    startDate: new Date(),
33286                    minDate: MIN_DATE,
33287                    maxDate: MAX_DATE
33288                };
33289
33290                if (func == 'saleStartDateTime') {
33291                    $('.time-interval input').prop('disabled', false).removeAttr('disabled');
33292                    datepickkObj.minDate   = MIN_DATE;
33293                    datepickkObj.maxDate   = MAX_DATE;
33294                    if (selStartDateOnly) datepickkObj.startDate = selStartDateOnly;
33295
33296                    if (selStartDate) $('#select-date-ymd').val(selStartDate.replace(/-/g, '.'));
33297                    // else $('.setting-sale-date').addClass('open');
33298                    $('.setting-sale-date').addClass('open');
33299
33300                } else { // saleEndDateTime
33301                    datepickkObj.minDate   = selStartDateOnly || MIN_DATE;
33302                    datepickkObj.startDate = selEndDateOnly || selStartDateOnly || new Date();
33303
33304                    if (selEndDate) {
33305                        $('#select-date-ymd').val(selEndDate.replace(/-/g, '.'));
33306                    } else if (selStartDate) {
33307                        $('#select-date-ymd').val(selStartDate.replace(/-/g, '.'));
33308                    } else {
33309                        var today = new Date();
33310                        var y = today.getFullYear(), m = String(today.getMonth()+1).padStart(2,'0'), d = String(today.getDate()).padStart(2,'0');
33311                        $('#select-date-ymd').val(`${y}.${m}.${d}`);
33312                        // $('.setting-sale-date').addClass('open');
33313                    }
33314                    $('.setting-sale-date').addClass('open');
33315                }
33316
33317                var termPicker = new Datepickk(datepickkObj);
33318
33319                if (isAllDay) {
33320                    $('.setting-sale-time').hide();
33321                } else {
33322                    $('.setting-sale-time').show();
33323                }
33324                if (func === 'saleEndDateTime' && !isAllDay) {
33325                    const $endScope = $('.sale-calendar-box.setting-sale-date .setting-datetime-input[data-type="saleEndDateTime"]').closest('.modal-dialog');
33326
33327                    function minutesFromInput($input) {
33328                        var v = String($input.val() || '').padStart(4,'0');
33329                        var h = parseInt(v.slice(0,2), 10);
33330                        var m = parseInt(v.slice(2,4), 10);
33331                        var period = $input.closest('.time-interval').data('time');
33332                        if (period === 'am') {
33333                            if (h === 12) h = 0;
33334                        } else {
33335                            if (h !== 12) h += 12;
33336                        }
33337                        return (h * 60) + m;
33338                    }
33339
33340                    function minutesFromStart(str) {
33341                        if (!str) return null;
33342                        var hh = parseInt(str.slice(11,13), 10);
33343                        var mm = parseInt(str.slice(14,16), 10);
33344                        if (isNaN(hh) || isNaN(mm)) return null;
33345                        return hh*60 + mm;
33346                    }
33347
33348                    function refreshEndTimeDisables() {
33349                        const $inputs = $endScope.find('.time-interval input');
33350
33351                        $inputs.prop('disabled', false).removeAttr('disabled');
33352
33353                        const selectedDot = ($('#select-date-ymd').val() || '').trim();
33354                        const $scope = (typeof selectEL !== 'undefined') ? $('.' + el) : $('.calendar-modal-container');
33355                        const startInput  = ($scope.find('.sdate .start').val() || '').trim();
33356                        const startHidden = ($('#sale-start-datetime').val() || '').trim();
33357                        const startStr    = startInput || startHidden;
33358
33359                        if (!selectedDot || !startStr) return;
33360
33361                        const endYmd   = selectedDot.replace(/\./g, '-').slice(0, 10);
33362                        const startYmd = startStr.slice(0, 10);
33363                        if (endYmd !== startYmd) return;
33364
33365                        const startMin = minutesFromStart(startStr);
33366                        if (startMin == null) return;
33367
33368                        $inputs.each(function(){
33369                            const $it = $(this);
33370                            const m = minutesFromInput($it);
33371                            if (m < startMin) $it.prop('disabled', true).attr('disabled','disabled');
33372                        });
33373
33374                        const $checked = $endScope.find('.time-interval input:checked');
33375                        if ($checked.length && $checked.is(':disabled')) {
33376                            $checked.prop('checked', false);
33377                            $('.sale-calendar-box .end-time').html('');
33378                        }
33379                    }
33380
33381                    window.__refreshEndTimeDisables = refreshEndTimeDisables;
33382
33383                    if (termPicker && typeof termPicker.onSelect !== 'undefined') {
33384                        const prev = termPicker.onSelect;
33385                        termPicker.onSelect = function(date){
33386                            if (typeof prev === 'function') prev.call(this, date);
33387                            if (date instanceof Date && !isNaN(date.getTime())) {
33388                                const y = date.getFullYear(), m = String(date.getMonth()+1).padStart(2,'0'), d = String(date.getDate()).padStart(2,'0');
33389                                $('#select-date-ymd').val(`${y}.${m}.${d}`);
33390                            }
33391                            refreshEndTimeDisables();
33392                        };
33393                    } else {
33394                        $('#sale-datepicker').off('click.updateEndTime')
33395                          .on('click.updateEndTime', '.d-day', function(){ setTimeout(refreshEndTimeDisables, 0); });
33396                    }
33397                }
33398
33399                if (typeof displaySelectedDates === 'function') displaySelectedDates();
33400
33401                $('.time-interval').each(function(i, v) {
33402                    var mna = $(v).data('time');
33403                    var times = '\
33404                        <input type="radio" id="' + mna + '-12-00" class="hide" name="sale_time" value="1200">\
33405                        <label for="' + mna + '-12-00">12:00</label>\
33406                        <input type="radio" id="' + mna + '-12-30" class="half-time hide" name="sale_time" value="1230">\
33407                        <label for="' + mna + '-12-30" class="half-time">12:30</label>\
33408                        \
33409                        <input type="radio" id="' + mna + '-1-00" class="hide" name="sale_time" value="
334090100">\
33410                        <label for="' + mna + '-1-00">1:00</label>\
33411                        <input type="radio" id="' + mna + '-1-30" class="half-time hide" name="sale_time" value="0130">\
33412                        <label for="' + mna + '-1-30" class="half-time">1:30</label>\
33413                        \
33414                        <input type="radio" id="' + mna + '-2-00" class="hide" name="sale_time" value="0200">\
33415                        <label for="' + mna + '-2-00">2:00</label>\
33416                        <input type="radio" id="' + mna + '-2-30" class="half-time hide" name="sale_time" value="0230">\
33417                        <label for="' + mna + '-2-30" class="half-time">2:30</label>\
33418                        \
33419                        <input type="radio" id="' + mna + '-3-00" class="hide" name="sale_time" value="0300">\
33420                        <label for="' + mna + '-3-00">3:00</label>\
33421                        <input type="radio" id="' + mna + '-3-30" class="half-time hide" name="sale_time" value="0330">\
33422                        <label for="' + mna + '-3-30" class="half-time">3:30</label>\
33423                        \
33424                        <input type="radio" id="' + mna + '-4-00" class="hide" name="sale_time" value="
334240400">\
33425                        <label for="' + mna + '-4-00">4:00</label>\
33426                        <input type="radio" id="' + mna + '-4-30" class="half-time hide" name="sale_time" value="0430">\
33427                        <label for="' + mna + '-4-30" class="half-time">4:30</label>\
33428                        \
33429                        <input type="radio" id="' + mna + '-5-00" class="hide" name="sale_time" value="0500">\
33430                        <label for="' + mna + '-5-00">5:00</label>\
33431                        <input type="radio" id="' + mna + '-5-30" class="half-time hide" name="sale_time" value="0530">\
33432                        <label for="' + mna + '-5-30" class="half-time">5:30</label>\
33433                        \
33434                        <input type="radio" id="' + mna + '-6-00" class="hide" name="sale_time" value="0600">\
33435                        <label for="' + mna + '-6-00">6:00</label>\
33436                        <input type="radio" id="' + mna + '-6-30" class="half-time hide" name="sale_time" value="0630">\
33437                        <label for="' + mna + '-6-30" class="half-time">6:30</label>\
33438                        \
33439                        <input type="radio" id="' + mna + '-7-00" class="hide" name="sale_time" value="
334390700">\
33440                        <label for="' + mna + '-7-00">7:00</label>\
33441                        <input type="radio" id="' + mna + '-7-30" class="half-time hide" name="sale_time" value="0730">\
33442                        <label for="' + mna + '-7-30" class="half-time">7:30</label>\
33443                        \
33444                        <input type="radio" id="' + mna + '-8-00" class="hide" name="sale_time" value="0800">\
33445                        <label for="' + mna + '-8-00">8:00</label>\
33446                        <input type="radio" id="' + mna + '-8-30" class="half-time hide" name="sale_time" value="0830">\
33447                        <label for="' + mna + '-8-30" class="half-time">8:30</label>\
33448                        \
33449                        <input type="radio" id="' + mna + '-9-00" class="hide" name="sale_time" value="0900">\
33450                        <label for="' + mna + '-9-00">9:00</label>\
33451                        <input type="radio" id="' + mna + '-9-30" class="half-time hide" name="sale_time" value="0930">\
33452                        <label for="' + mna + '-9-30" class="half-time">9:30</label>\
33453                        \
33454                        <input type="radio" id="' + mna + '-10-00" class="hide" name="sale_time" value="1000">\
33455                        <label for="' + mna + '-10-00">10:00</label>\
33456                        <input type="radio" id="' + mna + '-10-30" class="half-time hide" name="sale_time" value="1030">\
33457                        <label for="' + mna + '-10-30" class="half-time">10:30</label>\
33458                        \
33459                        <input type="radio" id="' + mna + '-11-00" class="hide" name="sale_time" value="1100">\
33460                        <label for="' + mna + '-11-00">11:00</label>\
33461                        <input type="radio" id="' + mna + '-11-30" class="half-time hide" name="sale_time" value="1130">\
33462                        <label for="' + mna + '-11-30" class="half-time">11:30</label>\
33463                    ';
33464                    $(v).html(times);
33465                });
33466
33467                if (func === 'saleEndDateTime' && typeof window.__refreshEndTimeDisables === 'function') {
33468                    window.__refreshEndTimeDisables();
33469                }
33470
33471                $('input[name="time_interval"][value="' + interval + '"]').prop('checked', true);
33472
33473                if (func == 'saleStartDateTime' && selStartDate && selStartTime) {
33474                    var hour = parseInt(selStartTime.split(':')[0], 10);
33475                    var minute = parseInt(selStartTime.split(':')[1], 10);
33476                    var mna = 'am';
33477                    if (hour >= 12) { if (hour > 12) hour -= 12; mna = 'pm'; }
33478                    else if (hour === 0) { hour = 12; }
33479                    var formattedTime = String(hour).padStart(2, '0') + String(minute).padStart(2, '0');
33480                    $('.time-interval[data-time="' + mna + '"] input[value="' + formattedTime + '"]').prop('checked', true);
33481                    if (typeof getDateTimeStr === 'function') getDateTimeStr(language, '', locale);
33482                }
33483
33484                var time_interval = $('input[name="time_interval"]:checked').val();
33485                if (typeof dateTimeModal !== 'undefined' && dateTimeModal && dateTimeModal.find) {
33486                    switch (time_interval) {
33487                        case 10: dateTimeModal.find('.time-interval label.ten-time').removeClass('hide'); break;
33488                        case 20: dateTimeModal.find('.time-interval label.twt-time').removeClass('hide'); break;
33489                        case 30: dateTimeModal.find('.time-interval label.half-time').removeClass('hide'); break;
33490                        case 60: dateTimeModal.find('.time-interval label').removeClass('hide'); break;
33491                    }
33492                }
33493
33494                $('input[name="time_interval"]').on('change', function() {
33495                    if ($(this).val() == 60) {
33496                        $('.time-interval label.half-time').addClass('hide');
33497                        if ($('#all-time-select').is(':checked')) {
33498                            $('.time-interval input.o-time').prop('checked', true);
33499                        }
33500                    } else {
33501                        $('.time-interval label.half-time').removeClass('hide');
33502                        if ($('#all-time-select').is(':checked')) {
33503                            $('.time-interval input').prop('checked', true);
33504                        }
33505                    }
33506                    if (func === 'saleEndDateTime' && typeof window.__refreshEndTimeDisables === 'function') {
33507                        setTimeout(window.__refreshEndTimeDisables, 0);
33508                    }
33509                });
33510
33511                $('.time-interval input').on('change', function(){
33512                    if (typeof getDateTimeStr === 'function') getDateTimeStr(language, 'time', locale);
33513                    if (func === 'saleEndDateTime' && typeof window.__refreshEndTimeDisables === 'function') {
33514                        setTimeout(window.__refreshEndTimeDisables, 0);
33515                    }
33516                });
33517
33518                $('.sale-calendar-box .setting-label').on('click', function(){
33519                    var $saleCalendarBox = $(this).closest('.sale-calendar-box');
33520                    if($saleCalendarBox.hasClass('open')) {
33521                        $('.sale-calendar-box .setting-datetime-input').slideUp(400, function(){
33522                            $('.sale-calendar-box').removeClass('open');
33523                        });
33524                    } else{
33525                        $('.sale-calendar-box .setting-datetime-input').slideUp(400, function(){
33526                            $('.sale-calendar-box').removeClass('open');
33527                        });
33528                        $saleCalendarBox.find('.setting-datetime-input').slideDown(400, function(){
33529                            $saleCalendarBox.addClass('open');
33530                        });
33531                    }
33532                });
33533
33534                break;
33535            }
33536        }
33537
33538        $(document).off('click', '.d-year, .d-month');
33539        $(document).on('click', '.d-year, .d-month', function() {
33540            $('.d-month-year-picker').toggleClass('d-show');
33541            scrollToCurrentYearMonth();
33542        });
33543
33544        function timeSelect(label, action) {
33545            if(typeof action == 'undefined') action = '';
33546            let interval = $('input[name=time_interval]:checked').val();
33547            let chk = $("#" + $(label).attr('for'));
33548            let t = chk.prevAll('input.ten-time');
33549
33550            if(action == 'click') {
33551                if(chk.is(':checked')) {
33552                    label.addClass('ui-selected');
33553                } else {
33554                    label.removeClass('ui-selected');
33555                }
33556            } else {
33557                if(chk.is(':checked')) {
33558                    chk.prop("checked", false);
33559                } else {
33560                    chk.prop("checked", true);
33561                }
33562            }
33563            
33564            switch (interval) {
33565                case '20':
33566                    if(chk.is(':checked') && $(t[0]).prevAll('input.o-time, input.twt-time').first().is(':checked')) {
33567                        $(t[0]).prop('checked', true);
33568                        if(action == 'click') $(t[0]).next('label').addClass('ui-selected');
33569                    } else {
33570                        $(t[0]).prop('checked', false);
33571                        if(action == 'click') $(t[0]).next('label').removeClass('ui-selected');
33572                    }
33573                    break;
33574                case '30':
33575                    if(chk.is(':checked') && $(t[0]).prevAll('input.o-time, input.half-time').first().is(':checked')) {
33576                        $(t[0]).prop('checked', true);
33577                        $(t[1]).prop('checked', true);
33578                        if(action == 'click') {
33579                            $(t[0]).next('label').addClass('ui-selected');
33580                            $(t[1]).next('label').addClass('ui-selected');
33581                        }
33582                    } else {
33583                        $(t[0]).prop('checked', false);
33584                        $(t[1]).prop('checked', false);
33585                        if(action == 'click') {
33586                            $(t[0]).next('label').removeClass('ui-selected');
33587                            $(t[1]).next('label').removeClass('ui-selected');
33588                        }                        
33589                    }
33590
33591                    break;
33592                case '60':
33593                    if(chk.is(':checked') && $(t[0]).prevAll('input.o-time').first().is(':checked')) {
33594                        $(t[0]).prop('checked', true);
33595                        $(t[1]).prop('checked', true);
33596                        $(t[2]).prop('checked', true);
33597                        $(t[3]).prop('checked', true);
33598                        $(t[4]).prop('checked', true);
33599                        if(action == 'click') {
33600                            $(t[0]).next('label').addClass('ui-selected');
33601                            $(t[1]).next('label').addClass('ui-selected');
33602                            $(t[2]).next('label').addClass('ui-selected');
33603                            $(t[3]).next('label').addClass('ui-selected');
33604                            $(t[4]).next('label').addClass('ui-selected');
33605                        }                        
33606                    } else {
33607                        $(t[0]).prop('checked', false);
33608                        $(t[1]).prop('checked', false);
33609                        $(t[2]).prop('checked', false);
33610                        $(t[3]).prop('checked', false);
33611                        $(t[4]).prop('checked', false);
33612                        if(action == 'click') {
33613                            $(t[0]).next('label').removeClass('ui-selected');
33614                            $(t[1]).next('label').removeClass('ui-selected');
33615                            $(t[2]).next('label').removeClass('ui-selected');
33616                            $(t[3]).next('label').removeClass('ui-selected');
33617                            $(t[4]).next('label').removeClass('ui-selected');
33618                        }                                                
33619                    }
33620                    
33621                    break;
33622            }
33623        }
33624
33625        function isSelectedAllTimes() {
33626            let interval = $('input[name=time_interval]:checked').val();
33627            let am = $('.time-interval[data-time="am"] label:not(.hide)').prev('input[type="checkbox"]:checked');
33628            let pm = $('.time-interval[data-time="pm"] label:not(.hide)').prev('input[type="checkbox"]:checked');
33629            let timeCnt = am.length + pm.length;
33630            let allTimeChecked = '';
33631            if (interval == '10' && timeCnt == 144) allTimeChecked = 'checked';
33632            if (interval == '20' && timeCnt == 72) allTimeChecked = 'checked';
33633            if (interval == '30' && timeCnt == 48) allTimeChecked = 'checked';
33634            if (interval == '60' && timeCnt == 24) allTimeChecked = 'checked';
33635
33636            if(allTimeChecked) {
33637                $('#all-time-select').prop('checked', true);
33638            } else {
33639                $('#all-time-select').prop('checked', false);
33640            }
33641        }
33642    }, function() { //hide
33643        
33644        settingModal.modal('hide');
33645    });
33646}
33647
33648function convertTime24(mna, timeString) {
33649    var hour = parseInt(timeString.substring(0, 2));
33650    var minute = timeString.substring(2);
33651    // console.log(timeString, minute);
33652    if (mna == 'am' && hour == 12) {
33653        hour -= 12;
33654    }
33655    if (mna == 'pm' && hour !== 12) {
33656        hour += 12;
33657    }
33658
33659    var formattedHour = hour.toString().padStart(2, '0');
33660
33661    return formattedHour + ':' + minute;
33662}
33663
33664function convertTime12(timeString) {
33665    var hour = parseInt(timeString.split(':')[0]);
33666    var minute = parseInt(timeString.split(':')[1]);
33667    var mna = 'am';
33668    if(hour >= 12) {
33669        if (hour > 12) hour -= 12;
33670        mna = 'pm';   
33671    } else if (hour == 0) hour += 12;
33672    var formattedTime = $.lang[LANG]['config.form.date2.time.' + mna] + ' ' + hour.toString().padStart(2, '0') + ':' +  minute.toString().padStart(2, '0');
33673
33674    return formattedTime;
33675}
33676
33677function convertDateObjToStr(dateObj) {
33678    var year = dateObj.getFullYear();
33679    var month = ("0" + (dateObj.getMonth() + 1)).slice(-2);
33680    var day = ("0" + dateObj.getDate()).slice(-2);
33681    var hours = ("0" + dateObj.getHours()).slice(-2);
33682    var minutes = ("0" + dateObj.getMinutes()).slice(-2);
33683    var seconds = ("0" + dateObj.getSeconds()).slice(-2);
33684    var formattedDate = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
33685    return formattedDate;
33686}
33687
33688var changeStatus = function(status,seq) {
33689    if(status == 'lim') return '';
33690    var s = '\
33691    <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>\
33692    <ul class="table-item-status" data-seq="' + seq + '">\
33693        <li class="' + ((status == 'on') ? 'active' : '') + '" data-val="on">판매중</li>\
33694        <li class="' + ((status == 'off' || status == '') ? 'active' : '') + '" data-val="off">판매중지</li>\
33695    </ul>\
33696    ';
33697    return s;
33698}
33699
33700var makeLinkUrl = function(link, one, view) {
33701    var link_url = '';
33702    var link_val = '';
33703    var is_menu = ($.inArray(link.replace(/^\//g, '').replace(/ /g, '-'), MENULIST) > -1) ? true : false;
33704    var regex = /^(((http(s?))\:\/\/)?)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,7}(\:[0-9]+)?(\/\S[^\{\}]*)?$/;
33705    var regex2 = /^((http(s?))\:\/\/)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,7}(\:[0-9]+)?(\/\S[^\{\}]*)?$/;
33706
33707    if (one) {
33708        link_url = (view) ? '/' + CONFIG_URL + 'config/page/view/index#' : '#';
33709        if (is_menu) link_url = '/';
33710    } else {
33711        link_url = (is_menu) ? '/' : '/' + CONFIG_URL + 'config/page/';
33712    }
33713
33714    if (link) {
33715        if (link.match(/^\@/g) !== null) { // link-type: link-bookmark ==> a[attr-bookmark]
33716            var bookmark_seq = link.replace(/^\@/g, '');
33717            if (typeof SETTINGS.blockBookmarkList == 'undefined' || typeof SETTINGS.blockBookmarkList['bookmark' + bookmark_seq] == 'undefined') {
33718                return '';
33719            }
33720        } else if (link.match(/^flink\@[0-9]/gi) !== null) { // link-type: link-file     ==> a[attr-flink]
33721            return link;
33722        } else if ($.inArray(link.replace(/^\//g, '').replace(/ /g, '-'), MENULIST) > -1) { // link-type: link-menu     ==> a[data-user-link]
33723            link_val = link_url + link.replace(/ /g, '-');
33724        } else { // link-type: link-out      ==> a[attr-link]
33725            if(checkBase64Encode(decodeURIComponent(link))) link = Base64.decode(decodeURIComponent(link));
33726            else if (checkBase64Encode(link)) link = Base64.decode(link);
33727
33728            if(!regex2.test(link) && regex.test(link)) link_val = '//' + link;
33729        }
33730
33731        if(link_val == '') link_val = link;
33732    }
33733    return link_val;
33734}
33735
33736var makeLinkList = function(e, type, id, prev_link, add_arr) {
33737    // type: editor -  id : text, button, image
33738    var valid_plan = (typeof VALIDPLAN == 'undefined') ? $.gallery.valid_plan : VALIDPLAN;
33739    var valid_type = (typeof VALIDTYPE == 'undefined') ? $.gallery.valid_type : VALIDTYPE;
33740
33741    var link_content = ((type == 'gallery')) ? '' : '<ul class="link-content edit-link-Content" data-type="' + type + '" data-name="' + id + '">';
33742    var link_icon = { 'menu': 'active', 'bookmark': 'active', 'flink': (valid_plan && valid_type != 'PK') ? 'active' : 'inactive', 'imagePopup': (valid_plan && valid_type != 'PK') ? 'active' : 'inactive' };
33743    var link_disabled = { 'submenu': '', 'bookmark': '', 'flink': (valid_plan && valid_type != 'PK') ? '' : 'disabled', 'imagePopup': (valid_plan && valid_type != 'PK') ? '' : 'disabled' };
33744    var isDefault = '';
33745    var isOut = '';
33746    var isFolder = '';
33747    var isInner = '';
33748    var isBookmark = '';
33749    var isFlink = '';
33750    var isTel_link = '';
33751    var isSms_link = '';
33752    var isPopup = '';
33753    var out_link = '';
33754    var flink_link = {};
33755    var popup_link = {};
33756    var org_prev_link = (prev_link) ? prev_link : '';
33757    var add_arr = (typeof add_arr!='undefined') ? add_arr : [];
33758    var check_tel = ($.inArray('tel', add_arr) > -1) ? true : false;
33759    var check_sms = ($.inArray('sms', add_arr) > -1) ? true : false;
33760    var telsms_link = '';
33761
33762    if (prev_link.match(/^\@/g) !== null) {
33763        isBookmark = 'active';
33764    } else if (prev_link.match(/^flink\@[0-9]/gi) !== null) {
33765        if (valid_plan) {
33766            $.getJSON('/down/flink/get/id/' + prev_link.replace(/^flink\@/gi, ''), {}, function(data) {
33767                checkError(data);
33768
33769                if (typeof data.data == 'object' && !$.isEmptyObject(data.data)) {
33770                    isFlink = 'active';
33771                    flink_link = data.data;
33772                } else {
33773                    prev_link = '';
33774                }
33775            }, 'json');
33776        } else {
33777            prev_link = '';
33778        }
33779    } else if (prev_link.indexOf('googleusercontent') !== -1 || prev_link.indexOf('storage.googleapis.com/cr-resource/image') !== -1){
33780        isPopup = (valid_plan)? 'active':'';
33781    } else if((check_tel || check_sms) && (prev_link.indexOf('tel')>-1 || prev_link.indexOf('sms')>-1)) {
33782        isTel_link = (prev_link.indexOf('tel') > -1 ) ? 'active' : isTel_link;
33783        isSms_link = (prev_link.indexOf('sms') > -1 ) ? 'active' : isSms_link;
33784        telsms_link = prev_link;
33785    } else {
33786        if (type == 'menu') {
33787            if (prev_link == id) { isDefault = 'active'; } else if (MENULIST.includes(prev_link.replace(/ /g, '-'))) { isInner = 'active'; } else if (prev_link == 'folder-menu') { isFolder = 'active'; } else {
33788                isOut = 'active';
33789                if(checkBase64Encode(decodeURIComponent(prev_link))) out_link = Base64.decode(decodeURIComponent(prev_link));
33790                else out_link = decodeURI(prev_link.replace(/%27/g, '&#39;')).replace(/\"/g, '&#34;');
33791            }
33792        }
33793
33794        if ($.inArray(type, ['image', 'gallery', 'popup', 'popupbanner', 'bandbanner', 'quickmenu','fnav', 'showcase', 'editor']) > -1) {
33795            var check_menu_str = (type == 'editor') ? prev_link.replace(/^\//g, '') : prev_link;
33796            if (prev_link == '') {
33797                if (type == 'fnav' || (type == 'editor' && id == 'text')) { 
33798                    isOut = 'active'; 
33799                } else { 
33800                    isDefault = 'active'; 
33801                }
33802            } else if (MENULIST.includes(check_menu_str.replace(/ /g, '-'))) { 
33803                console.log('MENU LINK');
33804                isInner = 'active'; 
33805            } else {
33806                isOut = 'active';
33807                if(checkBase64Encode(decodeURIComponent(prev_link))) out_link = Base64.decode(decodeURIComponent(prev_link));
33808                else out_link = decodeURI(prev_link.replace(/%27/g, '&#39;')).replace(/\"/g, '&#34;');
33809            }
33810        }
33811    }
33812    var one = (typeof ONE == 'undefined') ? $.gallery.one : ONE;
33813    var temp = (type == 'menu') ? 'editor.link.inner.select.menu' : (one) ? 'editor.link.inner.select.page.1' : 'editor.link.inner.select.page.0';
33814    var select_menu_str = (isInner) ? prev_link : $.lang[LANG][temp];
33815    var select_menu_selected = '';
33816
33817    var site_smenu = (typeof SMENU == 'undefined') ? $.gallery.SMENU : SMENU;
33818    var menulist_val = makeMenuLinkList(site_smenu, type, id, prev_link);
33819    var isList = true;
33820    if (menulist_val.length == 0) {
33821        select_menu_str = $.lang[LANG]['editor.link.inner.empty'];
33822        isList = false;
33823        link_disabled['submenu'] = 'disabled';
33824        if (type == 'menu') {
33825            isInner = (isInner == 'active') ? '' : isInner;
33826            isFolder = (isFolder == 'active') ? '' : isFolder;
33827            link_icon['menu'] = 'inactive';
33828        }
33829    }
33830
33831    var isBookmarkList = true;
33832    var select_bookmark_str = $.lang[LANG]['editor.link.bookmark.select'];
33833    var select_bookmark_selected = '';
33834    var bookmarklist_val = makeBookmarkList(SETTINGS.blockBookmarkList, type, id, org_prev_link);
33835
33836    var blockBookmarkList = (typeof SETTINGS.blockBookmarkList != 'undefined' && SETTINGS.blockBookmarkList) ? SETTINGS.blockBookmarkList : {};
33837    var hideArray = blockBookmarkList?.hide || [];
33838    var bookmark_orgprev_link = org_prev_link.replace('@', '');
33839
33840    if (bookmarklist_val.length == 0) {
33841        if (isBookmark == 'active') {
33842            isBookmark = '';
33843            isDefault = 'active';
33844            select_menu_str = $.lang[LANG][temp];
33845        }
33846        isBookmarkList = false;
33847        link_disabled['bookmark'] = 'disabled';
33848        link_icon['bookmark'] = 'inactive';
33849        select_bookmark_str = $.lang[LANG]['editor.link.bookmark.empty'];
33850    } else {
33851        if (typeof SETTINGS.blockBookmarkList[org_prev_link.replace(/^\@/g, 'bookmark')] != 'undefined' && SETTINGS.blockBookmarkList[org_prev_link.replace(/^\@/g, 'bookmark')]) {
33852            select_bookmark_str = SETTINGS.blockBookmarkList['bookmark' + org_prev_link.replace(/^\@/g, '')];
33853            select_bookmark_selected = ' data-link-seq="' + org_prev_link.replace(/^\@/g, '') + '"';
33854        } else {
33855            if (isBookmark == 'active') {
33856                isBookmark = '';
33857                isDefault = 'active';
33858                prev_link = $.lang[LANG][temp];
33859            }
33860        }
33861    }
33862
33863    if (hideArray.length > 0) {
33864        if (hideArray.includes(bookmark_orgprev_link)) {
33865            isBookmark = '';
33866            isDefault = 'active';
33867        }
33868    }
33869
33870    // if($('.' + selectEL).attr('data-img-parallax') == 'true') {
33871    //     link_disabled['imagePopup'] = 'disabled';
33872    //     link_icon['imagePopup'] = 'inactive';
33873    //     if(isPopup == 'active') {
33874    //         isPopup = '';
33875    //         isDefault = 'active';
33876    //     }
33877    // }
33878
33879    if (type == 'menu') {
33880        if (isDefault == '' && isOut == '' && isInner == '' && isBookmark == '' && isFlink == '' && isFolder == '') { isDefault = 'active'; }
33881    }
33882    if (type == 'showcase') {
33883        if (isDefault == '' && isOut == '' && isInner == '' && isBookmark == '') { isDefault = 'active'; }
33884    }
33885    if ($.inArray(type, ['gallery', 'popup', 'popupbanner', 'bandbanner', 'quickmenu']) > -1) {
33886        if (isDefault == '' && isOut == '' && isInner == '' && isBookmark == '' && isFlink == '' && isTel_link == '' && isSms_link == '') { isDefault = 'active'; }
33887    }
33888    if (type == 'image') {
33889        if (isDefault == '' && isOut == '' && isInner == '' && isBookmark == '' && isFlink == '' && isPopup == '') { isDefault = 'active'; }
33890    }
33891    if (type == 'fnav') {
33892        if (isOut == '' && isInner == '' && isBookmark == '') { isOut = 'active'; }
33893    }
33894    if (type == 'editor') {
33895        if (isOut == '' && isInner == '' && isBookmark == '' && isFlink == '') {
33896            if (id == 'text') { isOut = 'active'; } else if (id == 'button' || id == 'image') { isDefault = 'active'; }
33897        }
33898    }
33899
33900    var link_deafult_text = {
33901        'menu': $.lang[LANG]['editor.link.default'],
33902        'gallery': $.lang[LANG]['editor.link.default'],
33903        'image': $.lang[LANG]['editor.link.default.image'],
33904        'popup': $.lang[LANG]['editor.link.default.popup'],
33905        'popupbanner': $.lang[LANG]['editor.link.default.popupbanner'],
33906        'bandbanner': $.lang[LANG]['editor.link.default.bandbanner'],
33907        'quickmenu': $.lang[LANG]['editor.link.default.quickmenu'],
33908        'showcase': $.lang[LANG]['editor.link.default.showcase'],
33909        'editor': $.lang[LANG]['editor.link.default.editor'],
33910    };
33911
33912    link_content += (type == 'fnav' || (type == 'editor' && id == 'text')) ? '' : '\
33913            <li class="link-type ' + isDefault + '">\
33914                <div class="link-default">\
33915                    ' + clSVG('checkbox_active',20,20,false) + '\
33916                    <h5>' + link_deafult_text[type] + '</h5>\
33917                </div>\
33918            </li>\
33919    ';
33920
33921    link_content += '\
33922            <li class="link-type ' + isOut + '">\
33923                <div class="link-out">\
33924                    ' + clSVG('checkbox_active',20,20,false) + '\
33925                    <h5>' + $.lang[LANG]['editor.link.out'] + '</h5>\
33926                    <div class="cl-common-form-wrap nonplace-holder">\
33927                        <div class="cl-common-form-group">\
33928                            <input type="text" class="link-input" placeholder="' + $.lang[LANG]['editor.link.input.info'] + '" value="' + out_link + '">\
33929                        </div>\
33930                    </div>\
33931                </div>\
33932            </li>\
33933    ';
33934
33935    if (type == 'menu') {
33936        link_content += '\
33937            <li class="link-type ' + isInner + ' ' + link_disabled['submenu'] + '">\
33938                <div class="link-inner">\
33939                    ' + clSVG('checkbox_'+link_icon['menu'],20,20,false) + '\
33940                    <h5>' + $.lang[LANG]['editor.link.inner'] + '</h5>\
33941                    <div class="group-wrap">\
33942                        <div class="input-group">\
33943                            <div class="inner-toggle btn btn-sm dropdown-toggle ' + link_disabled['submenu'] + '" data-toggle="dropdown">\
33944                                <span class="select-link">' + select_menu_str + '</span>';
33945        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>';
33946        link_content += '\
33947                            </div>\
33948                            <ul class="dropdown-menu link-innerlist" role="menu">\
33949                                ' + menulist_val + '\
33950                            </ul>\
33951                        </div>\
33952                    <div>\
33953                </div>\
33954            </li>\
33955        ';
33956    }
33957
33958    if ($.inArray(type, ['image', 'gallery', 'popup', 'popupbanner', 'bandbanner', 'quickmenu', 'fnav', 'showcase', 'editor']) > -1) {
33959        var lang_text = 'editor.link.inner.menu';
33960        if (isInner && type == 'image' && $('<ul>' + menulist_val + '</ul>').children('li[data-userlink="' + prev_link + '"]').length == 0) {
33961            $('<ul>' + menulist_val + '</ul>').children().each(function() {
33962                if ($(this).attr('data-userlink').replace(/ /g, '-') == prev_link.replace(/ /g, '-')) {
33963                    prev_link = $(this).attr('data-userlink');
33964                }
33965            });
33966        }
33967
33968
33969        var select_inner_str = (isInner && type == 'editor') ? prev_link.replace(/\//g, '') 
33969: select_menu_str;
33970        var select_inner_selected = (isInner) ? ' data-link-val="' + prev_link.replace(/\//g, '') + '"' : '';
33971
33972        link_content += '\
33973            <li class="link-type ' + isInner + ' ' + link_disabled['submenu'] + '">\
33974                <div class="link-menu">\
33975                    ' + clSVG('checkbox_active',20,20,false) + '\
33976                    <h5>' + $.lang[LANG][lang_text] + '</h5>\
33977                    <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'] + '">\
33978                        <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"/>\
33979                        <rect x="6" y="9" width="1" height="1"/>\
33980                        <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"/>\
33981                    </svg>\
33982                    <div class="group-wrap">\
33983                        <div class="btn-group">\
33984                            <div class="inner-toggle btn btn-sm dropdown-toggle ' + link_disabled['submenu'] + '" data-toggle="dropdown">\
33985                                <span class="select-link" ' + select_inner_selected + '>' + select_inner_str + '</span>';
33986        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>';
33987        link_content += '\
33988                            </div>\
33989                            <ul class="dropdown-menu link-innerlist" role="menu">\
33990                                ' + menulist_val + '\
33991                            </ul>\
33992                        </div>\
33993                    </div>\
33994                </div>\
33995            </li>\
33996        ';
33997    }
33998
33999    link_content += '\
34000            <li class="link-type ' + isBookmark + ' ' + link_disabled['bookmark'] + '">\
34001                <div class="link-bookmark">\
34002                    ' + clSVG('checkbox_'+link_icon['bookmark'],20,20,false) + '\
34003                    <h5>' + $.lang[LANG]['editor.link.bookmark'] + '</h5>\
34004                    <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'] + '">\
34005                        <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"/>\
34006                        <rect x="6" y="9" width="1" height="1"/>\
34007                        <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"/>\
34008                    </svg>\
34009                    <div class="group-wrap">\
34010                        <div class="btn-group">\
34011                            <div class="bookmark-toggle btn btn-sm dropdown-toggle inner-toggle ' + link_disabled['bookmark'] + '" data-toggle="dropdown">\
34012                                <span class="select-bookmark" ' + select_bookmark_selected + '>' + select_bookmark_str + '</span>\
34013    ';
34014
34015    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>';
34016    link_content += '\
34017                            </div>\
34018                            <ul class="dropdown-menu link-bookmarklist" role="bookmark">\
34019                                ' + bookmarklist_val + '\
34020                            </ul>\
34021                        </div>\
34022                    </div>\
34023                </div>\
34024            </li>\
34025    ';
34026
34027    if ($.inArray(type, ['menu', 'image', 'gallery', 'popup', 'popupbanner', 'bandbanner', 'quickmenu', 'editor']) > -1) {
34028        var service = (typeof SERVICE == 'undefined') ? $.gallery.service : SERVICE;
34029        var flink_popover_str = (service.indexOf('gabia') > -1) ? $.lang[LANG]['editor.link.file.info.gabia'] : $.lang[LANG]['editor.link.file.info'];
34030        var flink_s = Number(flink_link.size);
34031        var flink_unit = (flink_s > 1024) ? 'unit_m' : '';
34032        var flink_size = (flink_s > 1024) ? flink_s / 1024 : flink_s;
34033
34034        if(LUX) flink_popover_str = $.lang[LANG]['editor.link.file.info.lux'];
34035
34036        link_content += '\
34037            <li class="link-type ' + isFlink + ' ' + link_disabled['flink'] + ' flink">\
34038                <div class="link-file">\
34039                    ' + clSVG('checkbox_'+link_icon['flink'],20,20,false) + '\
34040                    <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 + '">\
34041                        <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"/>\
34042                        <rect x="6" y="9" width="1" height="1"/>\
34043                        <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.
3404366 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"/>\
34044                    </svg></h5>\
34045                    <div class="group-wrap">\
34046        ';
34047
34048        link_content += (valid_plan && valid_type != 'PK') ? '\
34049                        <div class="btn-group">\
34050                            <span class="btn btn-sm fileinput-button flink-add">\
34051                              ' + clSVG('paperclip', '16', '16', false, '') + '\
34052                              <span> ' + $.lang[LANG]['editor.link.file.btn'] + '</span>\
34053                            </span>\
34054                        </div>\
34055                        <span class="prop-flink-ctrl ' + isFlink + '">\
34056                            <span class="flink-info" ' + ((isFlink) ? 'data-id="' + flink_link.seq + '"' : '') + '>\
34057                                <span class="flink-name">' + ((isFlink) ? flink_link.name : '') + '</span>\
34058                                <span class="flink-size ' + flink_unit + '">' + ((isFlink) ? flink_size.toFixed(0) : '') + '</span>\
34059                            </span>\
34060                            <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>\
34061                        </span>\
34062        ' : '\
34063                        <div class="btn-group">\
34064                            <span class="btn btn-sm btn-flink-upgrade">\
34065                              ' + clSVG('paperclip', '16', '16', false, '') + '\
34066                              <span> ' + $.lang[LANG]['editor.link.file.btn'] + '</span>\
34067                            </span>\
34068                        </div>\
34069                        <!--<div class="btn-group">\
34070                            <a class="btn btn-sm btn-flink-upgrade" href="' + ((SERVICE.indexOf('gabia') > -1) ? '//www.gabia.com/mygabia/service" target="_blank' : '/upgrade/site/') + '">\
34071                              ' + clSVG('planupgrade',18,18) + '<span>' + $.lang[LANG]['dashbord.toolbar.upgrade-site'] + '</span>\
34072                            </a>\
34073                        </div>-->\
34074        ';
34075        link_content += '\
34076                  </div>\
34077                </div>\
34078            </li>\
34079        ';
34080    }
34081
34082    var telsms_link_2 = telsms_link.replace(/(tel|sms)\:/gi,'');
34083    var telsms_link_array = [];
34084    var tel_link_array = [];
34085    var sms_link_array = [];
34086   
34087    if(check_tel || check_sms) {
34088        if(telsms_link_2.indexOf('-') > -1) {
34089            if(prev_link.indexOf('tel')>-1) tel_link_array = telsms_link_2.split('-'); 
34090            else if(prev_link.indexOf('sms')>-1) sms_link_array = telsms_link_2.split('-');
34091        }
34092
34093        if(tel_link_array.length === 2) tel_link_array = ['', tel_link_array[0], tel_link_array[1]];
34094        if(sms_link_array.length === 2) sms_link_array = ['', sms_link_array[0], sms_link_array[1]];
34095
34096        link_content += `
34097            <li class="link-type ${isTel_link} tel">
34098                <div class="link-tel">
34099                    ${clSVG('checkbox_active',20,20,false)}
34100                    <h5>${$.lang[LANG]['editor.link.tel']}</h5>
34101                    <div class="cl-common-form-wrap nonplace-holder">
34102                        <div class="cl-common-form-group">
34103                            <input type="number" class="link-input" placeholder="000" value="${tel_link_array[0] || ''}">
34104                        </div>
34105                        <span class="text">-</span>
34106                        <div class="cl-common-form-group">
34107                            <input type="number" class="link-input" placeholder="0000" value="${tel_link_array[1] || ''}">
34108                        </div>
34109                        <span class="text">-</span>
34110                        <div class="cl-common-form-group">
34111                            <input type="number" class="link-input" placeholder="0000" value="${tel_link_array[2] || ''}">
34112                        </div>
34113                    </div>
34114                </div>
34115            </li>
34116            <li class="link-type ${isSms_link} sms">
34117                <div class="link-sms">
34118                    ${clSVG('checkbox_active',20,20,false)}
34119                    <h5>${$.lang[LANG]['editor.link.sms']}</h5>
34120                    <div class="cl-common-form-wrap nonplace-holder">
34121                        <div class="cl-common-form-group">
34122                            <input type="number" class="link-input" placeholder="000" value="${sms_link_array[0] || ''}">
34123                        </div>
34124                        <span class="text">-</span>
34125                        <div class="cl-common-form-group">
34126                            <input type="number" class="link-input" placeholder="0000" value="${sms_link_array[1] || ''}">
34127                        </div>
34128                        <span class="text">-</span>
34129                        <div class="cl-common-form-group">
34130                            <input type="number" class="link-input" placeholder="0000" value="${sms_link_array[2] || ''}">
34131                        </div>
34132                    </div>
34133                </div>
34134            </li>
34135        `;
34136    }
34137
34138    if (type == 'image') {
34139        var popup_popover_str = (SERVICE.indexOf('gabia') > -1) ? $.lang[LANG]['editor.link.imagePopup.info.gabia'] : $.lang[LANG]['editor.link.imagePopup.info'];
34140        var popup_info = prev_link.split('||');
34141        var popupLink = popup_info[0];
34142        var popupName = popup_info[1];
34143
34144        link_content += '\
34145            <li class="link-type ' + isPopup + ' ' + link_disabled['imagePopup'] + ' imagePopup">\
34146                <div class="link-popup">\
34147                    ' + clSVG('checkbox_'+link_icon['imagePopup'],20,20,false) + '\
34148                    <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 + '">\
34149                        <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"/>\
34150                        <rect x="6" y="9" width="1" height="1"/>\
34151                        <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"/>\
34152                    </svg></h5>\
34153                    <div class="group-wrap">\
34154        ';
34155
34156        link_content += (VALIDPLAN && VALIDTYPE != 'PK') ? '\
34157                        <div class="btn-group">\
34158                            <span class="btn btn-sm fileinput-button popupImage-add">\
34159                                ' + clSVG('file-image', '13', '13', false, '') + '\
34160                                <span> ' + $.lang[LANG]['editor.link.imagePopup.btn'] + '</span>\
34161                            </span>\
34162                        </div>\
34163                        <span class="prop-popup-ctrl ' + isPopup + '">\
34164                            <span class="popup-info" ' + ((isPopup) ? 'data-popup="' + prev_link + '"' : '') + '>\
34165                                <span class="popup-name">' + ((isPopup) ? popupName : '') + '</span>\
34166                            </span>\
34167                            <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>\
34168                        </span>\
34169        ' : '\
34170                        <div class="btn-group">\
34171                            <span class="btn btn-sm btn-popup-upgrade">\
34172                                ' + clSVG('file-image', '13', '13', false, '') + '\
34173                                <span> ' + $.lang[LANG]['editor.link.imagePopup.btn'] + '</span>\
34174                            </span>\
34175                        </div>\
34176        ';
34177        link_content += '\
34178                  </div>\
34179                </div>\
34180            </li>\
34181        ';
34182    }
34183
34184    if (type == 'menu') {
34185        link_content += '\
34186            <li class="link-type ' + isFolder + ' ' + link_disabled['submenu'] + '">\
34187                <div class="link-folder">' + clSVG('checkbox_'+link_icon['menu'],20,20,false) + '\
34188                    <h5>' + $.lang[LANG]['editor.link.folder'] + '</h5>\
34189                </div>\
34190            </li>\
34191        ';
34192    }
34193    if (type == 'editor') return { 'str': link_content, 'display': select_menu_str };
34194    else return link_content;
34195}
34196
34197var makeMenuLinkList = function(s, type, id, prev_link) {
34198    // console.log(s);
34199    // console.log('type: '+type+', id: '+id+', prev_link: '+prev_link);
34200    var depth = 0;
34201    var str = '';
34202    var isActive = '';
34203    if (type == 'menu') {
34204        menu = function(level, depth) {
34205            $.each(level, function(idx, obj) {
34206                if (obj.name == id && obj.children.length > 0) menu(obj.children, depth + 1);
34207                if (depth != 0) {
34208                    isActive = (prev_link == obj.name) ? 'active' : '';
34209                    str = str + '<li data-userlink="' + obj.name + '" class="' + isActive + '"><a href="javascript:;">' + obj.name + '</a></li>';
34210                }
34211            });
34212            return str;
34213        }
34214        return menu(s, depth);
34215    }
34216
34217    if ($.inArray(type, ['image', 'gallery', 'popup', 'popupbanner', 'bandbanner', 'quickmenu','fnav', 'showcase', 'editor']) > -1) {
34218        menu = function(level, depth) {
34219            $.each(level, function(idx, obj) {
34220                var check_menu_str = (type == 'editor') ? prev_link.replace(/^\//g, '') 
34220: prev_link;
34221                isActive = (check_menu_str.replace(/ /g, '-') == obj.name.replace(/ /g, '-')) ? 'active' : '';
34222                var onoff = (obj.display == 'on') ? '' : ' off';
34223                if (depth == 0) {
34224                    str = str + '<li data-userlink="' + obj.name + '" class="' + isActive + onoff + '"><a href="javascript:;">' + obj.name + '</a></li>';
34225                } else {
34226                    str = str + '\
34227                    <li data-userlink="' + obj.name + '" class="' + isActive + '">\
34228                        <a href="javascript:;"><i class="fa fa-level-up"></i>' + obj.name + '</a>\
34229                    </li>';
34230                }
34231
34232                if (obj.children) menu(obj.children, depth + 1);
34233            });
34234            return str;
34235        }
34236      
34237        return menu(s, depth);
34238    }
34239};
34240$('.menu-edit-cancel').live('click', function() {
34241    menuEdit = false;
34242    menu_edit_cancel();
34243});
34244
34245var menu_edit_cancel = function() {
34246    if ($('#nestable > .dd-list').children().last().prev().attr('data-id') == 'menu-added') {
34247        $('#nestable > .dd-list').children().last().prev().remove();
34248    } else {
34249        $('.menu-edit-cancel').parents('.menu-edit-text').hide();
34250    }
34251    $('#menu-add').show();
34252}
34253
34254$(document)
34255    .on('click', '.flink-cancel', function(e) {
34256        var flinkConfig = $(this).closest('.prop-flink-ctrl');
34257        flinkConfig.removeClass('active');
34258        flinkConfig.find('.flink-info').removeAttr('data-id');
34259        flinkConfig.find('.flink-name,.flink-size').empty();
34260    })
34261    .on('click', '.flink-add', function(e) {
34262        var block_el = (typeof editEL == 'undefined') ? $.gallery.block_el : editEL;
34263    
34264        if(typeof editEL != 'undefined') {
34265            menuConfigToggle('close');
34266            siteConfigToggle('close');
34267        }
34268        var block_el = (typeof editEL == 'undefined') ? $.gallery.block_el : editEL;
34269        $('.g-body .text-menu').removeClass('active').addClass('hide');
34270        if (typeof fr_editor != 'undefined' && fr_editor != '') $(fr_editor.popups.get('link.insert')).addClass('allways');
34271        setResourceBtn(true,{maxcount:1, property:'flink-change', element:`.${block_el}`});
34272    });
34273
34274var setFileLink = function() {
34275    var selectedFlink = $('#filestorage .fitem.selected');
34276    var selected = (selectedFlink.length > 0) ? true : false;
34277    var selected_count = (selected) ? 1 : 0;
34278    var obj = (selected) ? {
34279            'name': selectedFlink.find('p.fitem-name').text(),
34280            'size': selectedFlink.find('p.fitem-size .size').attr('data-size'),
34281            'seq': selectedFlink.find('p.fitem-name').attr('data-seq'),
34282            'file': selectedFlink.find('p.fitem-name').attr('data-source'),
34283        } : {};
34284
34285    var flinkConfig = $('.link-file .prop-flink-ctrl');
34286    var flink_s = Number(obj.size.replace(',', ''));
34287    var flink_unit = (flink_s > 1024) ? 'unit_m' : '';
34288    var flink_size = (flink_s > 1024) ? flink_s / 1024 : flink_s;
34289
34290    flinkConfig.find('.flink-info .flink-name').text(obj.name);
34291    flinkConfig.find('.flink-info .flink-size').text(flink_size.toFixed(0));
34292    if (flink_unit) flinkConfig.find('.flink-info .flink-size').addClass('unit_m');
34293    else flinkConfig.find('.flinkflink-info .flink-size').removeClass('unit_m');
34294    flinkConfig.find('.flink-info').attr('data-id', obj.seq);
34295    flinkConfig.addClass('active');
34296    selectCount = 0;
34297    $('#el-fileupload').modal('hide');
34298}
34299
34300
34301$('.link-type').live({
34302    click: function(e) {
34303        if ($(e.target).is('a') && $(e.target).hasClass('upgrade-link')) return;
34304        if ($(this).hasClass('disabled')) {
34305            $('.link-type').find('.linkguidetext').remove();
34306            var link_type = $(this).children('div[class*="link-"]').attr('class').replace(/^link-/gi, '');
34307            var guide_str = (link_type == 'inner' || link_type == 'folder') ? $.lang[LANG]['editor.link.inner.guide'] : $.lang[LANG]['editor.link.bookmark.guide'];
34308            if (link_type == 'file') {
34309                guide_str = (SERVICE.indexOf('gabia') > -1) ? $.lang[LANG]['editor.link.file.upgrade.gabia'] : $.lang[LANG]['editor.link.file.upgrade'];
34310            } else if (link_type == 'popup') {
34311                if(!VALIDPLAN || VALIDTYPE == 'PK') {
34312                    guide_str = (SERVICE.indexOf('gabia') > -1) ? $.lang[LANG]['editor.link.imagePopup.upgrade.gabia'] : $.lang[LANG]['editor.link.imagePopup.upgrade'];
34313                } else {
34314                    guide_str = '' ;
34315                    return;
34316                }
34317            }
34318
34319            $(this).append('<p class="linkguidetext edit-link-error">' + clSVG('info', 13, 13) + guide_str + '</p>');
34320            return;
34321        }
34322
34323        if ($(this).closest('.link-content[data-type="popup"]').length > 0 && $(this).children('.link-default').length > 0) $('#popup-linktarget-onoff').removeAttr('checked');
34324        $('.link-type').find('.linkguidetext').remove();
34325        $(this).parent().children().removeClass('active');
34326        $(this).addClass('active');
34327
34328        if($(this).children().attr('class') == 'link-default' || $(this).children().attr('class') == 'link-file' || $(this).children().attr('class') == 'link-popup') {
34329            $('#linktarget-onoff').prop('checked', false);
34330            $('#linktarget-onoff').closest('.newcheckbox').addClass('disabled');
34331        } else {
34332            $('#linktarget-onoff').closest('.newcheckbox').removeClass('disabled');
34333        }
34334    }
34335});
34336
34337var getInputLink = function(type) {
34338    var link = '';
34339    var isOkay = true;
34340    var isActive = true;
34341    // var regex = /([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w_\.-]*)/ig;
34342    var regex = /^(((http(s?))\:\/\/||\/\/)?)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,7}(\:[0-9]+)?(\/\S[^\{\}]*)?$/; //http://do doesn't
34343    var regex2 = /^((http(s?))\:\/\/||\/\/)([0-9a-zA-Z\-\_]+\.)+[a-zA-Z]{2,7}(\:[0-9]+)?(\/\S[^\{\}]*)?$/; //http://do
34344    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
34345    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_]*)?$/;
34346    var regexTel = /^tel\:[0-9-+]+$/;
34347
34348    function showInputLinkError(linktype, error) {
34349        $('.link-content').find('.linkguidetext').remove();
34350        var activeLinkConfig = $('.link-content').find('.' + linktype);
34351        var error_class = 'linkguidetext edit-link-error';
34352        var error_txt = '';
34353
34354        if (error == 'empty') {
34355            error_txt = $.lang[LANG]['editor.link.empty.' + linktype.replace('link-', '')];
34356        } else {
34357            if (linktype == 'link-out') {
34358                $('.link-input').focus();
34359                if (error == 'config') error_class = 'linkguidetext modal-layout';
34360                error_txt = (error == 'emoji') ? $.lang[LANG]['config.unable.emoji'] : $.lang[LANG]['editor.menu.input-link.' + error];
34361            }
34362        }
34363
34364        if (typeof error_txt == 'undefined' || error_txt.length == 0) return false;
34365        else activeLinkConfig.after('<p class="' + error_class + '">' + clSVG('info', 13, 13) + error_txt + '</p>');
34366    }
34367
34368    switch (type) {
34369        case 'link-default':
34370            link = '';
34371            isActive = false;
34372            break;
34373
34374        case 'link-out':
34375            link = $('.link-input').val().trim();
34376            isOkay = false;
34377            var error_str = '';
34378
34379            if (link == '') { //input value empty
34380                showInputLinkError(type, 'info');
34381
34382                // $('.link-input').focus();
34383                // 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>');
34384            } else if (link != '') {
34385                if (checkEmojis(link)) {
34386                    showInputLinkError(type, 'emoji');
34387                } else if (link.match('^(tel:|mailto:|sms:)') !== null) {
34388                    isOkay = true;
34389                } else if (!regex2.test(link)) {
34390                    if (regex.test(link)) {
34391                        isOkay = true;
34392                    } else if (regex3.test(link) || regexKR.test(link)) {
34393                        isOkay = true;
34394                        var check_protocol = /^(http(s?)\:\/\/|\/\/?)/;
34395                        if (!check_protocol.test(link)) link = '//' + link;
34396                    } else if (regexTel.test(link)) {
34397                        isOkay = true;
34398                    } else {
34399                        showInputLinkError(type, 'info');
34400                        // $('.link-input').focus();
34401                        // 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>');
34402                    }
34403                } else {
34404                    // if($('.link-out').find('.linkguidetext').length > 0) $('.link-out').find('.linkguidetext').remove();
34405                    isOkay = true;
34406                }
34407            }
34408
34409            if (isOkay) {
34410                if (link.match(/\/config/gi) !== null && link.match(/creatorlink/gi) !== null) {
34411                    isOkay = false;
34412                    showInputLinkError(type, 'config');
34413                } else {
34414                    $('.linkguidetext').remove();
34415                }
34416
34417                if(checkBase64Encode(decodeURIComponent(link))) link = Base64.decode(decodeURIComponent(link));
34418                link = encodeURIComponent(Base64.encode(link));
34419
34420            }
34421            break;
34422
34423        case 'link-inner':
34424        case 'link-menu':
34425            var select_menu = $('.link-innerlist').find('.active');
34426            isOkay = false;
34427            if (select_menu.length > 0) {
34428                link = select_menu.first().attr('data-userlink');
34429                isOkay = true;
34430
34431                $('.linkguidetext').remove();
34432            } else {
34433                showInputLinkError(type, 'empty');
34434            }
34435            break;
34436
34437        case 'link-bookmark':
34438            var select_bookmark = $('.link-bookmarklist').find('.active');
34439            isOkay = false;
34440            if (select_bookmark.length > 0) {
34441                link = select_bookmark.first().attr('data-bookmark').replace('bookmark', '\@');
34442                isOkay = true;
34443
34444                $('.linkguidetext').remove();
34445            } else {
34446                showInputLinkError(type, 'empty');
34447            }
34448            break;
34449
34450        case 'link-folder':
34451            link = 'folder-menu';
34452            break;
34453
34454        case 'link-file':
34455            var ctrl_flink = $('.link-file').find('.prop-flink-ctrl');
34456            var select_flink = ctrl_flink.find('.flink-info');
34457            isOkay = false;
34458            if (typeof select_flink.attr('data-id') != 'undefined' && select_flink.attr('data-id')) {
34459                link = 'flink@' + select_flink.attr('data-id');
34460                isOkay = true;
34461
34462                $('.linkguidetext').remove();
34463            } else {
34464                showInputLinkError(type, 'empty');
34465            }
34466            break;
34467        case 'link-popup':
34468            var ctrl_popup = $('.link-popup').find('.prop-popup-ctrl');
34469            var select_popup = ctrl_popup.find('.popup-info');
34470            isOkay = false;
34471            if (typeof select_popup.attr('data-popup') != 'undefined' && select_popup.attr('data-popup')) {
34472                link = select_popup.attr('data-popup');
34473                isOkay = true;
34474
34475                $('.linkguidetext').remove();
34476            } else {
34477                showInputLinkError(type, 'empty');
34478            }
34479            break;
34480
34481        case 'link-tel':
34482        case 'link-sms':
34483            var link = '';
34484            var total = $(`.${type} .cl-common-form-wrap .link-input`).length;
34485            var link_type = `${type.replace(/link\-/gi,'')}:`;
34486
34487            $.each($(`.${type} .cl-common-form-wrap .link-input`), function(i,v){
34488                if($(this).val().trim() == '') showInputLinkError(type, 'info');
34489                else {
34490                    var split_text = (i==(total-1)) ? '' : '-';
34491                    link += $(this).val().trim() + split_text;
34492                }             
34493            });
34494
34495            link = `${link_type}${link}`;
34496           
34497            break;
34498            
34499        default:
34500            break;
34501    }
34502
34503    var result = [link, isOkay, isActive];
34504    return result;
34505}
34506
34507var getElementType = function() {
34508    var type = '';
34509    var block_el = (typeof selectEL == 'undefined') ? $.gallery.block_el : selectEL;
34510
34511    if(typeof editEL != 'undefined' && editEL != '' && block_el != editEL) block_el = editEL;
34512
34513    switch (block_el) {
34514        case 'el-menu':
34515            type = 'MENU';
34516            break;
34517        case 'el-footer':
34518            type = 'FOOT';
34519            break;
34520        default:
34521            type = 'ELEM';
34522            break;
34523    }
34524    return type;
34525}
34526
34527$('.link-innerlist li').live({
34528    click: function(e) {
34529        $('.link-innerlist li').removeClass('active');
34530        $(this).addClass('active');
34531        var select_userlink = $(this).attr('data-userlink');
34532        $('.link-content .dropdown-toggle .select-link').text(select_userlink).attr('data-link-val', select_userlink);
34533    }
34534});
34535
34536
34537var fixedConfigBtn = function() {
34538    if($('html').hasClass('_scroll')) return;
34539
34540    var parentDocument = $(window.parent.document);
34541    var $detail_modal = parentDocument.find('.product-detail-modal');
34542    if (typeof selectEL == 'undefined' || !selectEL || $('.el-menu header').length == 0 && $detail_modal.length == 0) return false;
34543    var $configEl = $('.' + selectEL + '_ctrl > .config-element');
34544    var $configTmp = $('.' + selectEL + '_ctrl > .config-template');
34545    var $galleryDetail = $('.' + selectEL + '_ctrl > .galleryDetail');
34546    var $navbar = ($detail_modal.length) ? $('.dsgn-body') : $('.el-menu header');
34547    var navbarOffsetTop = ($('.dsgn-body').hasClass('modoo'))? document.querySelector('.el-menu header').getBoundingClientRect().y : $navbar.offset().top;
34548    var checkSidebar = $('.dsgn-body').is('.sidebar');
34549    var headerOffset = (!checkSidebar) ? $navbar.outerHeight() + Math.ceil(navbarOffsetTop) : Math.ceil(navbarOffsetTop) + 15;
34550    var btnOffset = (document.querySelector('.' + selectEL + '_ctrl'))? document.querySelector('.' + selectEL + '_ctrl').getBoundingClientRect().y : 0;
34551    var topPos = (!checkSidebar) ? headerOffset + 15 : Math.ceil(navbarOffsetTop) + 15;
34552    var distance = (headerOffset - btnOffset) / 2;
34553    var remain = $('.' + selectEL).height() + btnOffset - headerOffset;
34554
34555    $configEl.removeClass('fixed-ctrl').attr('style', '');
34556    $configTmp.removeClass('fixed-ctrl').attr('style', '');
34557    $galleryDetail.removeClass('fixed-ctrl').attr('style', '');
34558
34559    if($detail_modal.length) {
34560        topPos = $('.openBandBanner').length ? 163 : 23;
34561        distance = 0;
34562    }
34563    // console.log('$navbar', $navbar);
34564    // console.log('headerOffset', headerOffset);
34565    // console.log('btnOffset', btnOffset);
34566    // console.log('distance', distance);
34567    // console.log('remain', remain);
34568    // console.log('topPos', topPos);
34569
34570    $('body').find(`.addElementButton, .config-element-section`).removeClass('zindex19');
34571    if (selectEL != 'el-menu' && selectEL != 'el-footer') {
34572        var checkHTMLScroll = ($('body').is('.off-config[data-gjs="fixedscroll2"]')) ? true : false;
34573        if (distance > 0 && remain >= 37 || checkHTMLScroll) {
34574            var s_top = ($('body').hasClass('off-config')) ? $('html').scrollTop() : $('.dsgn-body').scrollTop();
34575            var unset_top = (checkHTMLScroll) ? $('html').scrollTop() : 0;
34576            if (s_top == 0 && $navbar.hasClass('transparent') && selectEL == 'el_0') {
34577                var config_t = headerOffset + 10;
34578                config_t -= unset_top;
34579                $configEl.css('top', config_t + 'px');
34580                $configTmp.css('top', config_t + 'px');
34581            } else {
34582                topPos -= unset_top;
34583                $configEl.addClass('fixed-ctrl').css('top', topPos + 'px');
34584                $configTmp.addClass('fixed-ctrl').css('top', topPos + 'px');
34585                $galleryDetail.addClass('fixed-ctrl').css('top', topPos + 'px');
34586            }
34587
34588            if($('.dsgn-body').hasClass('modoo') == false) {
34589                let rightPos = window.innerWidth - $('.' + selectEL).width();
34590                if(checkSidebar) rightPos -= $('.el-menu header').width();
34591                if(rightPos > 0) {
34592                    $configEl.addClass('fixed-ctrl').css('right', `${rightPos + 8}px`);
34593                }
34594            }
34595
34596        } else {
34597            $configEl.removeClass('fixed-ctrl').attr('style', '');
34598            $configTmp.removeClass('fixed-ctrl').attr('style', '');
34599            $galleryDetail.removeClass('fixed-ctrl').attr('style', '');
34600
34601            if( selectEL != 'el-menu' &&
34602                $('html').scrollTop() == 0 && 
34603                $('.el-menu .cl-menu-option[data-moption="ntoggle"]').hasClass('open')
34604            ) {
34605                $('body').find(`.addElementButton.add${selectEL}, .${selectEL}_ctrl.config-element-section`).addClass('zindex19');
34606            }
34607        }
34608    }
34609}
34610
34611var educationModal = function(edu_seq,type,data='') {
34612    var row = '', temp_cont = '', temp_review = '';
34613    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>';
34614
34615    if(type=='list') {
34616        $.ajax({
34617            url:'/main/eduData/type/getData',
34618            type:'post',
34619            dataType:'json',
34620            async: false,
34621            data:{ 'seq' : edu_seq,'type':'list' },
34622            success:function(data) {
34623                row = data.data;
34624                temp_cont = JSON.parse(data.modal_data.replace('\\', ''));
34625                temp_review =  JSON.parse(data.review_data.replace('\\', ''));
34626            }
34627        });
34628    } else {
34629        $.ajax({
34630            url:'/adm/edu/eduEvent/type/getData',
34631            type:'post',
34632            dataType:'json',
34633            async: false,
34634            data:{ 'seq' : data.edu_temp_idx,'type':'update',data:data },
34635            success:function(data) {
34636                row = data.data;
34637                temp_cont = JSON.parse(data.modal_data.replace('\\', ''));
34638                temp_review =  JSON.parse(data.review_data.replace('\\', ''));
34639            }
34640        });
34641    }
34642
34643    var tp_review = (typeof temp_review == 'undefined' || !temp_review) ? false : true ,
34644        tp_target = (typeof temp_cont.target_cont == 'undefined' || !temp_cont.target_cont) ? false : true ,
34645        tp_curri = (typeof temp_cont.curri_cont == 'undefined' || !temp_cont.curri_cont) ? false : true;
34646    var edu_url = "", edu_btn_text = "", btn_active = "active";
34647    if(row.edu_list_closed) {
34648        edu_url = "";
34649        edu_btn_text = "접수마감";
34650        btn_active = "disabled";
34651    } else {
34652        edu_url = "window.open('"+ row.edu_url +"')";
34653        edu_btn_text = row.edu_btn_text;
34654    }
34655
34656    var help_url = 'https://www.creatorlink.net/help';
34657
34658    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>'
34659    : '<li class="level" data-level="">난이도 : '+temp_cont.guide_level+'</li>';
34660    var edu_date = row.edu_date,
34661        edu_new = (edu_date >= '2026-08-14 00:00:00') ? 'new' : 'old';
34662
34663    var edu_header = '\
34664        <div class="edu_head_wrap">\
34665            <div class="edu_head_img only-pc" style="background-image: url(\''+temp_cont.head_pc+'\');"></div>\
34666            <div class="edu_head_img not-pc" style="background-image: url(\''+temp_cont.head_m+'\');"></div>\
34667            <div class="main-title">\
34668                '+temp_cont.pc_title+'\
34669            </div>\
34670            <div class="edu_head_m not-pc">\
34671                <div class="guide">\
34672                    <ul class="note">\
34673                        <li>일시 : '+ row.edu_popupDate +'</li>\
34674                        <li>강의 시간 : '+temp_cont.guide_time+'</li>\
34675                        '+edu_level+'\
34676                        <li>가격 : '+temp_cont.guide_pay+'</li>\
34677                        <li>강의 종류 : '+temp_cont.guide_cate+'</li>\
34678                        <li>최소 인원 : 10명</li>\
34679                    </ul>\
34680                    <ul class="notice">';
34681        edu_header += (edu_new == 'new') ? '\
34682                        <li>강의실 입장 링크는 <span>구글 폼 제출 완료 화면에서 바로 확인 가능</span>하며 강의 개설 확정 시, 교육 당일 신청하신 <span>메일 혹은 알림톡으로도 개별 안내</span>됩니다.</li>\
34683                        ' : '\
34684                        <li>접속 링크는 신청 메일 및 <span>교육 1일 전 개별 알림톡</span> 전달</li>\
34685                        <li>강의실 입장 링크는 <span>수강 신청 시 입력하신 메일 주소로 발송</span>됩니다.</li>';
34686        edu_header += '\
34687                        <li>최소 인원이 충족되지 않으면 <span>강의가 진행되지 않습니다.</span></li>\
34688                    </ul>\
34689                </div>\
34690            </div>\
34691        </div>\
34692    ';
34693
34694    var summary_list = '';
34695    $.each(temp_cont.intro_summary,function(i,v) {
34696        summary_list += '<p>'+popup_svg+' '+v+'</p>';
34697    });
34698
34699    var edu_intro = '\
34700        <section id="intro" class="">\
34701            <div class="teacher">\
34702                    <div class="text not-pc">\
34703                        <p class="title">'+ temp_cont.intro_title +'</p>\
34704                    </div>\
34705                    <div class="photo">\
34706                        <img src="'+ temp_cont.intro_pc_img +'" class="img-responsive only-pc">\
34707                        <img src="'+ temp_cont.intro_m_img +'" class="img-responsive not-pc">\
34708                    </div>\
34709                    <div class="text">\
34710                        <p class="title small only-pc">'+ temp_cont.intro_title +'</i></p>\
34711                        <p class="text">'+ temp_cont.intro_text +'</p>\
34712                        <p class="text name">'+ temp_cont.intro_name +'</p>\
34713                    </div>\
34714            </div>\
34715            <div class="line">\
34716                <p class="title">'+ temp_cont.intro_summary_title +'</p>\
34717                <div class="content">\
34718                    '+summary_list+'\
34719                </div>\
34720            </div>\
34721        </section>\
34722    ';
34723
34724    var target_list = '';
34725
34726    if(tp_target) {
34727    $.each(temp_cont.target_cont,function(i,v) {
34728        target_list += '<p>'+popup_svg+' '+v+'</p>';
34729    });
34730    }
34731
34732    var edu_target = (tp_target) ? '\
34733        <section id="target" class="">\
34734            <div class="">\
34735                <p class="title">'+temp_cont.target_title+'</i></p>\
34736                <div class="content">\
34737                    '+target_list+'\
34738                </div>\
34739            </div>\
34740        </section>\
34741        ' : '' ;
34742
34743    if(tp_curri) {
34744    var curri_list = '';
34745    $.each(temp_cont.curri_cont,function(i,v) {
34746        var collapse = (i==0) ? '' : 'collapsed';
34747        var col_in = (i==0) ? 'in' : '';
34748        var col_toggle = 'collapse';
34749        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>';
34750        var curri_cont_list = '';
34751        $.each(v.content,function(i,v) {
34752            curri_cont_list += '<p>'+v+'</p>';
34753        });
34754
34755        if((temp_cont.curri_cont.length-1 == i)) {
34756            curri_svg ='';
34757            col_toggle = '';
34758        }
34759
34760        curri_list += '\
34761            <div class="panel-heading '+collapse+'" data-toggle="'+col_toggle+'" href="#collapse'+i+'" aria-expanded="false" aria-controls="collapse'+i+'">\
34762                <h4 class="panel-title">\
34763                    '+v.title+'\
34764                    '+curri_svg+'\
34765                </h4>\
34766            </div>\
34767            <div id="collapse'+i+'" class="panel-collapse collapse '+col_in+' multi-collapse">\
34768                <div class="panel-body">\
34769                    '+curri_cont_list+'\
34770                </div>\
34771            </div>\
34772        ';
34773    });
34774    }
34775    
34776    var edu_curri = (tp_curri) ? '\
34777        <section id="curriculum" class="">\
34778            <div class="">\
34779                <p class="title">'+temp_cont.curri_title+'</p>\
34780                <div class="panel-group" id="curriaccordion">\
34781                    <div class="panel panel-default">\
34782                    '+curri_list+'\
34783                    </div>\
34784                </div>\
34785            </div>\
34786        </section>\
34787        ' : '' ;
34788
34789    var edu_etc = '\
34790        <section id="etc" class="">\
34791            <div class="" id="info1">\
34792                <p class="title">강의를 위해 필요한 <i>준비물</i></p>\
34793                <div class="content">\
34794                    <p>'+popup_svg+' 데스크탑 PC <span class="red">(권장)</span> / 노트북</p>\
34795                    <p>'+popup_svg+' 크롬 브라우저</p>\
34796                    <p>'+popup_svg+' 필기도구</p>\
34797                </div>\
34798            </div>\
34799            <div class="line" id="info2">\
34800                <p class="title">온라인 교육 안내 사항</p>\
34801                <div class="content">';
34802        edu_etc += (edu_new == 'new') ? '\
34803                    <p>'+popup_svg+' 강의실 입장 링크는 <b>구글 폼 제출 완료 화면에서 바로 확인 가능</b>하며,<br>교육 당일 신청하신 메일 or 알림톡으로도 개별 발송됩니다.</p>\
34804                    <p>'+popup_svg+' 교육 시간 <b>10분 전부터 입장이 가능</b>합니다.</p>\
34805                    <p>'+popup_svg+' 본인 확인을 위해 반드시 <b>신청서에 적어주신 이름</b>으로 입장해 주시기 바랍니다.</p>\
34806                    <p>'+popup_svg+' 1개 아이디로 <b>중복 참여는 불가능</b>합니다.</p>\
34807                    ' : '\
34808                    <p>'+popup_svg+' 강의실 입장 링크는 수강 신청하며 <b>입력하신 메일 주소로 발송</b>됩니다.</p>\
34809                    <p>'+popup_svg+' 교육 시간 <b>20분 전부터 입장이 가능</b>합니다.</p>\
34810                    <p>'+popup_svg+' 1개 아이디로 <b>중복 참여는 불가능</b>합니다.</p>\
34811                    <p>'+popup_svg+' 강의 관련 문의는 <a href="'+help_url+'"><u>1:1 문의</u></a>에 남겨주세요.</p>';
34812        edu_etc += '\
34813                </div>\
34814            </div>\
34815        </section>\
34816        ';
34817    var edu_review = (tp_review) ? '\
34818        <section id="review" class="">\
34819            <div class="">\
34820                <p class="point">New</p>\
34821                <p class="title">먼저 수강한 분들의<br><i>후기를 들어보세요!</i></p>\
34822                <div class="review-list">\
34823                </div>\
34824                <div class="review-btn hand">\
34825                  <span>수강평 더보기</span>\
34826                </div>\
34827            </div>\
34828        </section>\
34829        ' : '' ;
34830
34831    var edu_sticky = '\
34832        <div class="edu_content_right sticky">\
34833            <div class="sticky">\
34834                <div class="btn-order hand '+ btn_active +'" onclick="' + edu_url + '">'+ edu_btn_text +'</div>\
34835                <div class="guide">\
34836                    <ul class="note">\
34837                        <li>일시 : '+ row.edu_popupDate +'</li>\
34838                        <li>강의 시간 : '+temp_cont.guide_time+'</li>\
34839                        '+edu_level+'\
34840                        <li>가격 : '+temp_cont.guide_pay+'</li>\
34841                        <li>강의 종류 : '+temp_cont.guide_cate+'</li>\
34842                        <li>최소 인원 : 10명</li>\
34843                    </ul>\
34844                    <ul class="notice">';
34845        edu_sticky += (edu_new == 'new') ? '\
34846                        <li>강의실 입장 링크는 <span>구글 폼 제출 완료 화면에서 바로 확인 가능</span>하며 강의 개설 확정 시, 교육 당일 신청하신 <span>메일 혹은 알림톡으로도 개별 안내</span>됩니다.</li>\
34847                        ' : '\
34848                        <li>접속 링크는 신청 메일 및 <span>교육 1일 전 개별 알림톡</span> 전달</li>\
34849                        <li>강의실 입장 링크는 <span>수강 신청 시 입력하신 메일 주소로 발송</span>됩니다.</li>';
34850        edu_sticky += '\
34851                        <li>최소 인원이 충족되지 않으면 <span>강의가 진행되지 않습니다.</span></li>\
34852                    </ul>\
34853                </div>\
34854            </div>\
34855        </div>\
34856    ';
34857    var edu_review_tab = (tp_review) ? '<li class="hand" data-menulink="review">후기<span class="point">New</span></li>' : '';
34858    var edu_target_tab = (tp_target) ? '<li class="hand" data-menulink="target">강의 대상</li>' : '<li class="hand" data-menulink="info1">준비물</li>';
34859    var edu_curri_tab = (tp_curri) ? '<li class="hand" data-menulink="curriculum">커리큘럼</li>' : '<li class="hand" data-menulink="info2">교육안내</li>';
34860
34861
34862    var edu_html = '\
34863        <div class="education_detail">\
34864            <div class="edu_wrap">\
34865                '+edu_header+'\
34866                <div class="edu_content">\
34867                    <div class="edu_content_left">\
34868                        <div class="edu_tab">\
34869                            <ul>\
34870                                <li class="hand active" data-menulink="intro">강의소개</li>\
34871                                '+edu_target_tab+'\
34872                                '+edu_curri_tab+'\
34873                                '+edu_review_tab+'\
34874                            </ul>\
34875                        </div>\
34876                        <div class="edu_section">\
34877                            '+edu_intro+'\
34878                            '+edu_target+'\
34879                            '+edu_curri+'\
34880                            '+edu_etc+'\
34881                            '+edu_review+'\
34882                        </div>\
34883                    </div>\
34884                    '+edu_sticky+'\
34885                </div>\
34886            </div>\
34887        </div>\
34888    ';
34889    
34890    var modal = $(this).showModalFlat('', edu_html, true, false, '', 'close', '', 'guidePopup cl-cmmodal cl-s-btn cover education-modal', false, '', function() {
34891        $.guidePopup.scrollevent(); 
34892
34893        modal.find('.edu_tab li').off('click').on('click', function(e) {
34894        var target = $(this).attr('data-menulink');
34895
34896        var top = ($(this).index())+1,
34897            hsize = (window.innerWidth <= 768) ? 34 : 55,
34898            tab_pos = (window.innerWidth <= 768) ? $('#'+target).position().top + $('.edu_head_wrap').outerHeight() : $('#'+target).position().top;
34899            move = tab_pos - hsize;
34900
34901            modal.find('.guidePopup .modal-content').animate({scrollTop: move},1000, 'easeInOutExpo');
34902        });
34903
34904        modal.find('.guidePopup .modal-content').bind('scroll', function () {
34905        var hsize = (window.innerWidth <= 768) ? 38 : 55,
34906            scrollValue = $('.guidePopup .modal-content').scrollTop() + hsize,
34907            tab_pos = (window.innerWidth <= 768) ? $('.edu_head_wrap').outerHeight() : 0;
34908
34909            if(tp_review) {
34910                if( scrollValue >= $("#target").position().top + tab_pos && scrollValue < $("#curriculum").position().top + tab_pos) {
34911                    $('.edu_tab li').eq(1).addClass('active').siblings().removeClass('active');
34912                } else if( scrollValue >= $("#curriculum").position().top + tab_pos && scrollValue < $("#review").position().top + tab_pos) {
34913                    $('.edu_tab li').eq(2).addClass('active').siblings().removeClass('active');
34914                } else if( scrollValue >= $("#review").position().top + tab_pos) {
34915                    $('.edu_tab li').eq(3).addClass('active').siblings().removeClass('active');
34916                } else {
34917                    $('.edu_tab li').eq(0).addClass('active').siblings().removeClass('active');
34918                }
34919            } else {
34920                if(tp_target) {
34921                    if( scrollValue >= $("#target").position().top + tab_pos && scrollValue < $("#curriculum").position().top + tab_pos) {
34922                        $('.edu_tab li').eq(1).addClass('active').siblings().removeClass('active');
34923                    } else if( scrollValue >= $("#curriculum").position().top + tab_pos) {
34924                        $('.edu_tab li').eq(2).addClass('active').siblings().removeClass('active');
34925                    } else {
34926                        $('.edu_tab li').eq(0).addClass('active').siblings().removeClass('active');
34927                    }
34928                } else {
34929                    if( scrollValue >= $("#info1").position().top + tab_pos && scrollValue < $("#info2").position().top + tab_pos) {
34930                        $('.edu_tab li').eq(1).addClass('active').siblings().removeClass('active');
34931                    } else if( scrollValue >= $("#info2").position().top + tab_pos) {
34932                        $('.edu_tab li').eq(2).addClass('active').siblings().removeClass('active');
34933                    } else {
34934                        $('.edu_tab li').eq(0).addClass('active').siblings().removeClass('active');
34935                    }
34936                }
34937            }
34938        });
34939        if(tp_review) {
34940            $.each(temp_review,function(i,v) {
34941                modal.find('.review-list').append('<li><p class="review">'+v.review+'</p><p class="name">'+v.name+' 님</p></li>');
34942            });
34943            var targets = modal.find('.review-list').children();
34944            for(var i=0; i<targets.length; i+=4){
34945                $('<ul class="hide"></ul>').append(targets.slice(i, i+4)).appendTo('.review-list');
34946            }
34947            modal.find('.review-list').find('ul:eq(0)').removeClass('hide');
34948            modal.find('.review-list').find('ul:eq(1)').removeClass('hide');
34949
34950            modal.find('.review-btn').off('click').on('click', function(e) {
34951                modal.find('.review-list').find('ul.hide:eq(0)').removeClass('hide');
34952                if(modal.find('.review-list').find('ul.hide').length < 1) $(this).addClass('hide');
34953            });
34954        }
34955    });
34956}
34957
34958
34959$(document).ready(function() {
34960    const icons = {
34961        '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>',
34962        '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>',
34963        '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"/>
34963<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>',
34964        '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>'
34965    };
34966
34967    $('#section-top-menu [data-menu-key]').each(function() {
34968        var key = $(this).data('menu-key');
34969        
34970        if (icons[key]) {
34971            $(this).find('.subnav-title').prepend(icons[key]);
34972        }
34973    });
34974});
34975
34976
34977var getColorisHtml = function(val,clr,input_options,input_layout,iswrap,class_obj,tooltip_title) {
34978    // console.log(`val: ${val}`,`val: ${clr}`,`input_options: `,input_options,`input_layout: ${input_layout}`,`iswrap: ${iswrap}`,`class_obj: `,class_obj,`tooltip_title: ${tooltip_title}`);
34979    if(typeof val == 'undefined' || val == '') val = 'transparent';
34980    if(typeof mode == 'undefined') mode = '';
34981    if(typeof layout == 'undefined') layout = '';
34982    if(typeof iswrap == 'undefined') iswrap = true;
34983    if(typeof class_obj == 'undefined') class_obj = {'wrap':'', 'input':''};
34984    if(typeof class_obj['element'] == 'undefined') class_obj['element'] = 'span';
34985    if(typeof class_obj['wrap'] == 'undefined') class_obj['wrap'] = '';
34986    if(typeof class_obj['wrap_attr'] == 'undefined') class_obj['wrap_attr'] = '';
34987    if(typeof class_obj['input'] == 'undefined') class_obj['input'] = '';
34988
34989    if(Array.isArray(val)) val = val[val.length - 1];
34990
34991    var clr_options = '';
34992    $.each(input_options, function(k,v) {
34993        if(v) clr_options += ` ${k}="${v}"`;
34994    });
34995
34996    var clr_input_class = (class_obj['input']) ? class_obj['input'] + ' ' : '';
34997    switch(input_layout) {
34998        case 'thumbnail': clr_input_class += 'clr-thumbnail '; break;
34999        default: break;
35000    }
35001
35002    var colorValueRegex = Coloris.getColorRegex();
35003    var colorWithImportantRegex = /!important$/g;
35004    var checkWithImportant = (val.match(colorWithImportantRegex) !== null) ? true : false;
35005    if(checkWithImportant) {
35006        var tmp_match = val.match(colorValueRegex);
35007        val = (tmp_match) ? tmp_match[0] : 'transparent';
35008    }
35009
35010    if(/(none|inherit|initial)\b/gi.exec(val)) val = val.replace(/(none|inherit|initial)\b/gi, 'transparent');
35011
35012    if(class_obj['input'].indexOf('clr-alphaoff') > -1) val = Coloris.getChangeColorVal(val,'a',1);
35013
35014    var clr_tooltip_title = (tooltip_title) ? tooltip_title : 'editor.color';
35015
35016    var clr_tooltip = (clr_input_class.indexOf('clr-tooltipoff') > -1) ? '' : `data-toggle="tooltip" data-placement="top" title="${$.lang[LANG][clr_tooltip_title]}"`;
35017    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">`;
35018    if(iswrap) {
35019        var clr_wrap_class = class_obj['wrap'];
35020        var clr_wrap_attr = class_obj['wrap_attr'];
35021        var element_type = class_obj['element'];
35022        
35023        clr_html = `<${element_type} class="coloris-picker ${clr_wrap_class}" ${clr_wrap_attr}>${clr_html}</${element_type}>`;
35024    }
35025
35026    return clr_html;
35027}

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.