1var SITE_BOOKING = function(){ 2 var $booking_wrap, $booking_content_wrap, $booking_view_calendar, $day_booking_wrap, $prod_image_list, $prod_image_list_rolling, $cuurent_day_obj, $prod_detail_wish_count, $prod_detail_content; 3 var data; 4 var target_month, select_day, start_day, end_day; 5 var start_time, end_time; 6 var unselected_end_day = false; 7 var restore_end_day = false; 8 var idx = 0; 9 var current_content_tab = ''; 10 var duration_type = ''; // ìì½ ê¸°ê° íì 11 var min_day = 0; // ìì½ ìµë ì¼ 12 var max_day = 0; // ìì½ ìµë ì¼ 13 var day_list = []; // ë ì§ ë¦¬ì¤í¸ 14 var add_order_progress_check = false; 15 var is_admin = false; 16 var cm_data = {}; 17 var $mfe_booking_wrap; 18 19 var person_num; 20 var init_list = function(d){ 21 data = d; 22 $booking_wrap = $('#'+data.code+' ._booking_wrap'); 23 $booking_view_calendar = $('#'+data.code+' ._booking_view_calendar'); 24 runMobileCalendar($booking_wrap); 25 }; 26 var init_calendar = function(d){ 27 data = d; 28 $mfe_booking_wrap = $('#'+ data.code + ' ._clay_calendar_root'); 29 30 $.ajax({ 31 type : 'POST', 32 url : ('/booking/html_mfe_list.cm'), 33 dataType : 'html', 34 success : function(html){ 35 // magnet-shellì´ ìì¼ë©´ ì ì²´ HTMLì ì½ì 36 $mfe_booking_wrap.html(''); 37 const range = document.createRange(); 38 const $booking_html = range.createContextualFragment(html); 39 $mfe_booking_wrap[0].append($booking_html); 40 } 41 }); 42 }; 43 44 var init_view = function(no,d,st,s,e, dt, mid,mxd,ia ,_cm_data){ 45 idx = no; 46 data = d; 47 duration_type = dt; 48 min_day = mid; 49 max_day = mxd; 50 start_day = s; 51 start_time = parseInt(st); 52 end_day = e; 53 end_time = 2; 54 is_admin = ia; 55 cm_data = $.extend(cm_data,_cm_data); 56 $booking_content_wrap = $('#'+data.code+' ._booking_content_wrap'); 57 $booking_view_calendar = $('#'+data.code+' ._booking_view_calendar'); 58 $day_booking_wrap = $('#'+data.code+' ._day_booking_wrap'); 59 $prod_detail_wish_count = $('#'+data.code+' #prod_detail_wish_count'); 60 $prod_detail_content = $('#'+data.code+' #prod_detail_content'); 61 $prod_image_list = $("#prod_image_list"); 62 $prod_image_list_rolling = $prod_image_list.find("._detail_image"); 63 if(duration_type == 'day' && !is_admin) { 64 const $onElement = $booking_view_calendar.find('.on'); 65 66 if ($onElement.length) { 67 clickViewCalendar($onElement); // ìì½ ê¸°ê° íì ì´ ì¼ìë¨ìì¼ ê²½ì° ì¤ë ë ì§ë¥¼ ìëì¼ë¡ ì íìí´ 68 } 69 } 70 runViewCalendar($booking_view_calendar); 71 startProdImageRolling(); 72 current_content_tab = 'detail'; 73 $booking_content_wrap.find('a._' + current_content_tab).addClass('on'); 74 }; 75 76 var runViewCalendar = function($obj){ 77 78 $booking_view_calendar = $('._booking_view_calendar'); 79 80 day_list = []; 81 $booking_view_calendar.find('.booking_day').each(function(k, v){ 82 day_list.push($(v)); 83 }); 84 85 $booking_view_calendar.find('._day_item').off('click').on('click',function(){ 86 clickViewCalendar($(this)); 87 }); 88 $booking_view_calendar.find('._check_out_item').off('click').on('click',function(){ 89 clickCheckOutViewCalendar($(this)); 90 }); 91 92 }; 93 94 var getValidateDay = function(){ 95 // í´ëì¤ ì´ê¸°í 96 $booking_view_calendar.find('._temp_day_item').addClass('check_out_item'); 97 $booking_view_calendar.find('._temp_day_item').addClass('_check_out_item'); 98 $booking_view_calendar.find('._temp_day_item').addClass('full_day'); 99 $booking_view_calendar.find('._temp_day_item').removeClass('_day_item'); 100 $booking_view_calendar.find('._temp_day_item').removeClass('_temp_day_item'); 101 102 for(var i in day_list){ 103 if(day_list[i].hasClass('on') === true){ // ì ì¤ ë ì§ì ìì¹ë¥¼ êµ¬í¨ 104 var key = 0; 105 var full_day_cnt = 0; 106 for(var i2 = min_day; i2 <= max_day; i2++){ // ìµë ìì½ì¼ ë§í¼ ë°ë³µ 107 key = Number(i) + Number(i2); 108 if(day_list[key].hasClass('full_day') === true){ // ì ì¤ ë ì§ì ìµë ìì½ì¼ ì¬ì´ì ìë ë¤ë¥¸ ìì½ì ì ì¤ ë ì§ë¥¼ ìì½ ê°ë¥ìíë¡ ë³ê²½ 109 day_list[key].removeClass('check_out_item'); 110 day_list[key].removeClass('_check_out_item'); 111 day_list[key].removeClass('full_day'); 112 day_list[key].addClass('_temp_day_item'); 113 day_list[key].addClass('_day_item'); 114 full_day_cnt++; 115 } 116 117 if(full_day_cnt === 1) break;
117 // ì ì¤ ë ì§ê° ìë ë ì ê²½ì° ê°ë¥ìíë¡ ë³ê²½íì§ ìì 118 } 119 break; 120 } 121 } 122 }; 123 124 var clickCheckOutViewCalendar = function($day_obj){ 125 end_time = $day_obj.data('stamp'); 126 if(start_time <end_time){ 127 if(start_day != '' && end_day ==''){ //ì¢ ë£ì¼ì ì í 128 unselected_end_day = false; 129 end_day = $day_obj.data('date'); 130 end_time = $day_obj.data('stamp'); 131 restore_end_day = false; 132 getViewBookingDetail($day_obj); 133 } 134 } 135 }; 136 137 var clickViewCalendar = function($day_obj){ 138 end_time = $day_obj.data('stamp'); 139 if(start_time <end_time){ 140 if(start_day != '' && end_day ==''){ //ì¢ ë£ì¼ì ì í 141 unselected_end_day = false; 142 end_day = $day_obj.data('date'); 143 end_time = $day_obj.data('stamp'); 144 if(max_day == 1 && duration_type == 'day'){ 145 start_day = $day_obj.data('date'); 146 start_time = $day_obj.data('stamp'); 147 end_day = start_day; 148 end_time = start_time; 149 } 150 restore_end_day = false; 151 }else if(start_day != '' && end_day != ''){ //ë¤ì ì¡°ì 152 if(duration_type != 'day'){ // ìì½ ê¸°ê° íì ì´ 1ë° ë¨ìì¼ ê²½ì° 153 unselected_end_day = true; 154 start_day = $day_obj.data('date'); 155 start_time = $day_obj.data('stamp'); 156 restore_end_day = false; 157 end_day = ''; 158 $booking_view_calendar.find('._day_item').removeClass('on').removeClass('keep').removeClass('off'); 159 $booking_view_calendar.find('._check_out_item').removeClass('on').removeClass('keep').removeClass('off'); 160 $day_obj.addClass('on'); 161 getValidateDay(); 162 }else{ // ìì½ ê¸°ê° ì¤ì ì´ 1ì¼ ë¨ìì¼ ê²½ì° ë ì§ ì íì ì¢ ë£ì¼ì 복구íì§ ìì 163 start_day = $day_obj.data('date'); 164 start_time = $day_obj.data('stamp'); 165 restore_end_day = false; 166 end_day = ''; 167 end_time = ''; 168 $booking_view_calendar.find('._day_item').removeClass('on').removeClass('keep').removeClass('off'); 169 $booking_view_calendar.find('._check_out_item').removeClass('on').removeClass('keep').removeClass('off'); 170 $day_obj.addClass('on'); 171 } 172 } 173 }else{ 174 if(duration_type != 'day'){ // ìì½ ê¸°ê° íì ì´ 1ë° ë¨ìì¼ ê²½ì° 175 unselected_end_day = true; 176 start_day = $day_obj.data('date'); 177 start_time = $day_obj.data('stamp'); 178 restore_end_day = false; 179 end_day = ''; 180 end_time = ''; 181 $booking_view_calendar.find('._day_item').removeClass('on').removeClass('keep').removeClass('off'); 182 $booking_view_calendar.find('._check_out_item').removeClass('on').removeClass('keep').removeClass('off'); 183 $day_obj.addClass('on'); 184 getValidateDay(); 185 }else{ // ìì½ ê¸°ê° ì¤ì ì´ 1ì¼ ë¨ìì¼ ê²½ì° ë ì§ ì íì ì¢ ë£ì¼ì 복구íì§ ìì 186 start_day = $day_obj.data('date'); 187 start_time = $day_obj.data('stamp'); 188 restore_end_day = false; 189 end_day = ''; 190 end_time = ''; 191 $booking_view_calendar.find('._day_item').removeClass('on').removeClass('keep').removeClass('off'); 192 $booking_view_calendar.find('._check_out_item').removeClass('on').removeClass('keep').removeClass('off'); 193 $day_obj.addClass('on'); 194 } 195 } 196 getViewBookingDetail($day_obj); 197 }; 198 199 var getViewBookingDetail = function($day_obj){ 200 $cuurent_day_obj = $day_obj; 201 202 var $booking_f = $('#booking_f'); 203 var f_data = $booking_f.serializeObject(); 204 var data = {'idx':idx,'start_day' : start_day, 'end_day':end_day, 'person':person_num}; 205 data = $.extend(f_data,data); 206 $.ajax({ 207 type : 'POST', 208 data : data, 209 url : ('/booking/html_day_booking.cm'), 210 dataType : 'json', 211 success : function(res){ 212 if(res.msg == 'SUCCESS'){ 213 var $html = $(res.html); 214 if(!restore_end_day){ 215 getViewMonth(target_month); 216 } 217 $('._day_booking_wrap').html($html); 218 }else{ 219 restore_end_day = true; 220 end_day = 'error'; 221 end_time = ''; 222 alert(res.msg); 223 } 224 } 225 }); 226 }; 227 228 var getListMonth = function(ym){ 229 $.ajax({ 230 type : 'POST', 231 data : {'target_month' : ym, 'select_day':select_day, 'menu_code' : data['menu_code']}, 232 url : ('/booking/html_list.cm'), 233 dataType : 'html', 234 success : function(html){ 235 var $html = $(html); 236 $booking_wrap.html($html); 237 runMobileCalendar($html); 238 } 239 }); 240 }; 241 var getViewMonth = function(ym){ 242 $.ajax({ 243 type : 'POST', 244 data : {'idx':idx,'target_month' : ym, 'start_day':start_day,'end_day':end_day}, 245 url : ('/booking/html_detail_calendar.cm'), 246 dataType : 'html', 247 success : function(html){ 248 var $html = $(html); 249 target_month = ym; 250 $booking_view_calendar.html($html); 251 runViewCalendar($booking_view_calendar); 252 } 253 }); 254 }; 255 256 const loadBookingDetailCalendar = function (idx, start_day, end_day) { 257 $.ajax({ 258 type: 'POST', 259 data: { idx, start_day, end_day }, 260 url: ('/shop/load_booking_detail_detail_calendar.cm'), 261 dataType: 'json', 262 cache: false, 263 success: function (result) { 264 if (result.msg === 'SUCCESS') { 265 var $html = $(result.output); 266 const $booking_view_calendar = $('._booking_view_calendar'); 267 $booking_view_calendar.html($html); 268 runViewCalendar($booking_view_calendar); 269 } 270 } 271 }); 272 }; 273 274 const loadBookingDayCalendar = function (idx, start_day, end_day) { 275 $.ajax({ 276 type: 'POST', 277 data: { idx, start_day, end_day }, 278 url: ('/shop/load_booking_detail_day_calendar.cm'), 279 dataType: 'json', 280 cache: false, 281 success: function (result) { 282 if (result.msg === 'SUCCESS') { 283 $('._day_booking_wrap').html(result.output); 284 } 285 } 286 }); 287 }; 288 289 var runMobileCalendar = function($obj){ 290 var $nav_left = $obj.find('.slide_left'); 291 var $nav_right = $obj.find('.slide_right'); 292 $nav_left.removeClass('slide_left'); 293 294 $obj.find("._booking_day_slide").owlCarousel({ 295 'mouseDraggable':false, 296 'singleItem':true, 297 'items' : 7 298 }).on('changed.owl.carousel', function(event) { 299 var index = event.item.index; 300 var items = event.item.count; 301 var size = event.page.size; 302 if ( index == 0 ) { 303 $nav_left.removeClass('slide_left'); 304 } else { 305 $nav_left.addClass('slide_left'); 306 } 307 if ( items-size == index ) { 308 $nav_right.removeClass('slide_right'); 309 } else { 310 $nav_right.addClass('slide_right'); 311 } 312 }); 313 314 $obj.find('._booking_date').on('click',function(){ 315 $obj.find('._booking_date').removeClass('on'); 316 $(this).addClass('on'); 317 select_day = $(this).data('day'); 318 $.ajax({ 319 type : 'POST', 320 data : {"select_day":select_day, "menu_code": data['menu_code']}, 321 url : ('/booking/html_day_detail.cm'), 322 cache : false, 323 dataType : 'html', 324 success : function(html){ 325 var $html = $(html); 326 $booking_wrap.find('._booking_day_detail').html($html); 327 } 328 }); 329 }); 330 }; 331 332 var changePerson = function(num){ 333 person_num = num; 334 getViewBookingDetail($cuurent_day_obj); 335 }; 336 337 var changeOption = function(status){ 338 if(status == 'require'){ 339 alert(LOCALIZE.ì¤ëª _í´ë¹ìµì íìì ëë¤()); 340 $('#require_option_check').prop("checked", true); 341 }else{ 342 getViewBookingDetail($cuurent_day_obj); 343 } 344 345 }; 346 347 348 /** 349 * ìí ì´ë¯¸ì§ ë¡¤ë§ ìì 350 */ 351 var startProdImageRolling = function(){ 352 353 var items = $prod_image_list.find('._item'); 354 var is_dots = false;
355 356 is_dots = items.length > 1 ? true : false; 357 358 if(is_dots){ 359 switch(cm_data.paging_style_type){ 360 case 'st00': 361 switch(cm_data.paging_default_style_type){ 362 case 'st00': 363 $prod_image_list_rolling.toggleClass('paging_type_dot paging_type_dot01', true); 364 break; 365 case 'st01': 366 $prod_image_list_rolling.toggleClass('paging_type_dot paging_type_dot02', true); 367 break; 368 } 369 break; 370 case 'st01': 371 $prod_image_list_rolling.toggleClass('paging_type_big_dot', true); 372 break; 373 case 'st02': 374 $prod_image_list_rolling.toggleClass('paging_type_line', true); 375 break; 376 case 'st03': 377 switch(cm_data.paging_active_style_type){ 378 case 'st00': 379 $prod_image_list_rolling.toggleClass('paging_type_count paging_type_count01', true); 380 break; 381 case 'st01': 382 $prod_image_list_rolling.toggleClass('paging_type_count paging_type_count02', true); 383 break; 384 case 'st02': 385 $prod_image_list_rolling.toggleClass('paging_type_count paging_type_count03', true); 386 break; 387 } 388 break; 389 } 390 } 391 392 if (items.length > 1 ) { 393 $prod_image_list_rolling.owlCarousel({ 394 navigation : true, 395 slideSpeed : 300, 396 paginationSpeed : 400, 397 singleItem : true, 398 animateOut : 'fadeOut', 399 items : 1, 400 onInitialized : function(){ 401 // init 402 const owl_item_list = document.querySelectorAll("#prod_image_list .owl-item"); 403 const total = owl_item_list.length; 404 const countDiv = document.createElement("div"); 405 countDiv.innerHTML = '<span class="_numbering_variable">1</span> <span class="_numbering_total">/ '+total+'</span>'; 406 document.querySelector("#_carousel_count_numbering").appendChild(countDiv); 407 }, 408 onChanged : function(){ 409 const owl = $prod_image_list_rolling.data('owlCarousel');
410 let current = 0; 411 if(typeof owl !== "undefined") current = owl._current; 412 const li_list = $prod_image_list.find('li.owl-dot'); 413 li_list.find('a').removeClass('active'); 414 li_list.eq(current).find('a').addClass('active'); 415 // img count changed 416 if(document.querySelector("._numbering_variable")) document.querySelector("._numbering_variable").innerHTML = (parseInt(current) + 1); 417 }, 418 }); 419 } else { 420 // item count 1 í¹ì ìì ë 421 document.querySelector("#_carousel_count_numbering").remove(); 422 } 423 }; 424 425 /** 426 * ìí ì´ë¯¸ì§ ë¡¤ë§ í¹ì ìì¹ ì´ë 427 * @param no 428 */ 429 function changeProdImageRolling(no){ 430 var owl = $prod_image_list_rolling.data('owlCarousel'); 431 if(typeof owl !== "undefined"){ 432 owl.to(no); 433 } 434 } 435 436 var toggleMobileBooking = function(){ 437 if($booking_content_wrap.hasClass('on')){ 438 $booking_content_wrap.removeClass('on'); 439 }else{ 440 $booking_content_wrap.addClass('on'); 441 } 442 }; 443 444 /** 445 * ë°ë¡ 주문í기 ì¶ê° 446 */ 447 var addBooking = function(callback){ 448 var $booking_f = $('#booking_f'); 449 var data = $booking_f.serializeObject(); 450 data = $.extend(data, {'unselected_end_day' : unselected_end_day}); 451 if(unselected_end_day){ 452 data = $.extend(data, {'start_timestamp' : start_time}); 453 } 454 add_order_progress_check = true; 455 $.ajax({ 456 'type' : 'POST', 457 'data' : data, 458 'url' : ('/booking/add_order.cm'), 459 'dataType' : 'json', 460 'cache' : false, 461 success : function(result){ 462 if(result.msg == 'SUCCESS'){ 463 callback(result); 464 }else{ 465 add_order_progress_check = false; 466 alert(result.msg); 467 } 468 } 469 }); 470 }; 471 472 /** 473 * í¹ì ìí ìì리ì¤í¸ ì¶ê° ì²ë¦¬ 474 * @param prod_code 475 */ 476 var addProdWish = function(prod_code){ 477 $.ajax({ 478 type : 'POST', 479 data : {'prod_code' : prod_code}, 480 url : ('/booking/add_prod_wish.cm'), 481 dataType : 'json', 482 success : function(res){ 483 if(res.msg == 'SUCCESS'){ 484 if(res.res == 'add'){ 485 if ( typeof FB_PIXEL != 'undefined' ) FB_PIXEL.AddToWishlist(); 486 $prod_detail_wish_count.parent().addClass('active'); 487 }else if(res.res == 'delete'){ 488 $prod_detail_wish_count.parent().removeClass('active'); 489 } 490 $prod_detail_wish_count.text(res.wish_cnt); 491 }else 492 alert(res.msg); 493 } 494 }); 495 }; 496 497 /** 498 * ìì¸ì ë³´ í ë³ê²½ ì²ë¦¬ 499 * @param type 500 */ 501 var changeContentTab = function(type,r_p, q_p,only_photo){ 502 503 if(current_content_tab != ''){ 504 $booking_content_wrap.find('a._' + current_content_tab).removeClass('on'); 505 } 506 current_content_tab = type; 507 $booking_content_wrap.find('a._' + type).addClass('on'); 508 if(type == 'detail'){ 509 $.ajax({ 510 type : 'POST', 511 data : {'prod_idx' : idx}, 512 url : ('/booking/prod_detail.cm'), 513 dataType : 'json', 514 cache : false, 515 success : function(result){ 516 if(result.msg == 'SUCCESS'){ 517 if(result.content == ''){ 518 $prod_detail_content.html('<div style="text-align: center; padding: 50px 0;"><div class="body_font_color_40" style="font-size: 18px; margin:30px"></div></div>'); 519 }else{ 520 $prod_detail_content.html(result.content); 521 } 522 $prod_detail_content.toggleClass('qna_list', false); 523 }else{ 524 alert(result.msg); 525 } 526 } 527 }); 528 }else if(type == 'review'){ 529 $.ajax({ 530 type : 'POST', 531 data : {'prod_idx' : idx,'review_page' : r_p, 'qna_page' : q_p, 'only_photo' : only_photo}, 532 url : ('/booking/prod_review.cm'), 533 dataType : 'html', 534 cache : false, 535 success : function(result){ 536 $prod_detail_content.html(result); 537 $prod_detail_content.toggleClass('qna_list', false); 538 } 539 }); 540 }else if(type == 'qna'){ 541 $.ajax({ 542 type : 'POST', 543 data : {'prod_idx' : idx, 'review_page' : r_p, 'qna_page' : q_p}, 544 url : ('/booking/prod_qna.cm'), 545 dataType : 'html', 546 cache : false, 547 success : function(result){ 548 $prod_detail_content.html(result); 549 $prod_detail_content.toggleClass('qna_list', true); 550 } 551 }); 552 } 553 }; 554 555 var openBuyerReview = function(prod_code){ 556 $.ajax({ 557 type : 'POST', 558 data : {'prod_code' : prod_code}, 559 url : ('/booking/open_buyer_review.cm'), 560 dataType : 'json', 561 cache : false, 562 async : false, 563 success : function(result){ 564 if(result.msg === 'SUCCESS'){ 565 $.cocoaDialog.open({type : 'eduModal', custom_popup : result.html, width : 800, hide_event : function(){ 566 }}
566); 567 }else{ 568 alert(result.msg); 569 } 570 } 571 }); 572 }; 573 574 var getOnlyPhotoReview = function(only_photo_switch){ 575 var $icon_picture = $('.icon-picture'); 576 $.ajax({ 577 type : 'POST', 578 data : {'prod_idx' : idx, 'only_photo' : only_photo_switch}, 579 url : '/booking/prod_review.cm', 580 dataType : 'html', 581 cache : false, 582 async : false, 583 success : function(result){ 584 $prod_detail_content.html(result); 585 if($icon_picture.hasClass('active')){ 586 $icon_picture.removeClass('active'); 587 }else{ 588 $icon_picture.addClass('active'); 589 } 590 } 591 }); 592 593 594 }; 595 596 return{ 597 'init_list' : function(data){ 598 init_list(data); 599 }, 600 'init_calendar' : function(data){ 601 init_calendar(data); 602 }, 603 'init_view' : function(idx,data,st,s,e, duration_type, min_day, max_day,ia,cm){ 604 init_view(idx,data,st,s,e, duration_type, min_day, max_day,ia,cm); 605 }, 606 'getListMonth' : function(ym){ 607 getListMonth(ym); 608 }, 609 'getViewMonth' : function(ym){ 610 getViewMonth(ym); 611 }, 612 'loadBookingDetailCalendar': function(idx, start_day, end_day) { 613 loadBookingDetailCalendar(idx, start_day, end_day); 614 }, 615 'loadBookingDayCalendar': function(idx, start_day, end_day) { 616 loadBookingDayCalendar(idx, start_day, end_day); 617 }, 618 'changePerson' : function(num){ 619 changePerson(num); 620 }, 621 'changeOption' : function(status){ 622 changeOption(status); 623 }, 624 'changeProdImageRolling' : function(no){ 625 changeProdImageRolling(no); 626 }, 627 'toggleMobileBooking' : function(){ 628 toggleMobileBooking(); 629 }, 630 'addBooking' : function(is_guest_login){ 631 if(add_order_progress_check) return false; 632 addBooking(function(result){ 633 if ( typeof FB_PIXEL != 'undefined' ) FB_PIXEL.InitiateCheckout(); 634 if ( typeof CHANNEL_PLUGIN != 'undefined' ) CHANNEL_PLUGIN.AddOrder(); 635 if (is_guest_login){ //ë¹íì주문ì ë¡ê·¸ì¸ íì´ì§ë¡ ì´ëì²ë¦¬ 636 window.location.href = '/login?booking_order_code=' + result.order_code + '&back_url=' + encodeURIComponent(result.back_url_base64); 637 }else{ //ì¼ë°ì£¼ë¬¸ì¸ê²½ì° ê²°ì íë©´ì¼ë¡ ì´ë 638 window.location.href = "/shop_payment/?order_code=" + encodeURIComponent(result.order_code); 639 } 640 }); 641 }, 642 addProdWish : function(prod_code){ 643 addProdWish(prod_code); 644 }, 645 'changeContentTab' : function(type,r_p, q_p,only_photo){ 646 changeContentTab(type,r_p, q_p,only_photo); 647 }, 648 'openBuyerReview' : function(prod_code){ 649 openBuyerReview(prod_code); 650 }, 651 "getOnlyPhotoReview" : function(only_photo_switch){ 652 getOnlyPhotoReview(only_photo_switch) 653 } 654 } 655}(); 656 657var BOOKING_REVIEW_COMMENT = function(){ 658 var $review_comment_wrap; 659 var $form; 660 var review_code; 661 662 var init = function(code){ 663 $form = $('.m_booking_nav_tools #accordion_review_form_'+code+', .booking_nav_tools #accordion_review_form_'+code); 664 review_code = code; 665 666 $form.each(function(){ 667 const $this = $(this); 668 $this.find('#review_image_upload_btn').setUploadImage({ 669 url : '/shop/upload_image.cm', 670 dropZone : 'icon_img_upload_wrap', 671 singleFileUploads : true, 672 formData : {temp : 'Y'} 673 }, function(res, data){ 674 $this.find("#review_comment_image_box").show(); 675 $.each(data, function(e, tmp){ 676 if(tmp.error == "" || tmp.error == null){ 677 var url = CDN_UPLOAD_URL + tmp.url; 678 var html = '<span class="file-add"><input type="hidden" name="img" value="' + tmp.url + '"><div class="file-add-bg" style="background: url('+url+') no-repeat center center;"></div><em class="del" onclick="BOOKING_REVIEW_COMMENT.removeCommentImg($(this))"></em></span>'; 679 $this.find("#review_comment_image_box").append(html); 680 }else{ 681 alert(tmp.error); 682 } 683 }); 684 }); 685 }); 686 }; 687 688 var imageUploadInit = function(idx){ 689 const $wrapper = $('.m_booking_nav_tools, .booking_nav_tools'); 690 691 $wrapper.each(function(){ 692 const $this = $(this); 693 $this.find("#sub_review_image_box_" + idx).hide(); 694 695 $this.find('#sub_review_image_upload_btn_' + idx).setUploadImage({ 696 url : '/shop/upload_image.cm', 697 dropZone : 'icon_img_upload_wrap', 698 singleFileUploads : true, 699 formData : {temp : 'Y'} 700 }, function(res, data){ 701 $this.find("#sub_review_image_box_" + idx).show(); 702 $.each(data, function(e, tmp){ 703 if(tmp.error == "" || tmp.error == null){ 704 var url = CDN_UPLOAD_URL + tmp.url; 705 var html = '<span class="file-add"><input type="hidden" name="img" value="' + tmp.url + '"><img src="' + url + '"><em class="del" onclick="BOOKING_REVIEW_COMMENT.removeCommentImg($(this))"></em></span>'; 706 $this.find("#sub_review_image_box_" + idx).append(html); 707 }else{ 708 alert(tmp.error); 709 } 710 }); 711 }); 712 713 $this.find('#editor_review_image_upload_btn_' + idx).setUploadImage({ 714 url : '/shop/upload_image.cm', 715 dropZone : 'icon_img_upload_wrap', 716 singleFileUploads : true, 717 formData : {temp : 'Y'} 718 }, function(res, data){ 719 $this.find("#editor_review_image_box_" + idx).show(); 720 $.each(data, function(e, tmp){ 721 if(tmp.error == "" || tmp.error == null){ 722 var url = CDN_UPLOAD_URL + tmp.url; 723 var html = '<span class="file-add"><input type="hidden" name="img" value="' + tmp.url + '"><img src="' + url + '"><em class="del" onclick="BOOKING_REVIEW_COMMENT.removeCommentImg($(this))"></em></span>'; 724 $this.find("#editor_review_image_box_" + idx).append(html); 725 }else{ 726 alert(tmp.error); 727 } 728 }); 729 }); 730 }); 731 }; 732 733 734 var submit = function(t, type, i){ 735 // mobile ë° pc ìì ê°ì id ê° ê³µì í´ë¹ ë¶ë¶ ìì íì... 736 const isMobile_width = (window.innerWidth < SHOP_CONST.WIDTH_MOBILE); 737 switch(type){ 738 case 'main': // pc 리뷰 ëê¸ 739 if (isMobile_width) { 740 var data = $('.m_booking_nav_tools #' + $form.attr('id')).serializeObject(); 741 } else { 742 var data = $('.booking_nav_tools #' + $form.attr('id')).serializeObject(); 743 } 744 break; 745 case 'sub_form': //pc 리뷰 ëëê¸ 746 if (isMobile_width) { 747 var data = $('.m_booking_nav_tools #sub_review_form_' + i).serializeObject(); 748 } else { 749 var data = $('.booking_nav_tools #sub_review_form_' + i).serializeObject(); 750 } 751 break; 752 case 'editor': // pc 리뷰 ëê¸ ìì 753 if (isMobile_width) { 754 var data = $('.m_booking_nav_tools #sub_review_editor_form_' + i).serializeObject(); 755 } else { 756 var data = $('.booking_nav_tools #sub_review_editor_form_' + i).serializeObject(); 757 } 758 break; 759 case 'mobile': // Mobile 리뷰 ëê¸ 760 var data = $('#mobile_review_form').serializeObject(); 761 break; 762 case 'mobile_sub_form': // Mobile 리뷰 ëëê¸ 763 var data = $('#mobile_sub_review_form_' + i).serializeObject(); 764 break; 765 case 'mobile_editor': // Mobile 리뷰 ëê¸ ìì 766 var data = $('#mobile_sub_review_editor_form_' + i).serializeObject(); 767 break; 768 } 769 if(!t.hasClass("btn-writing")){ 770 t.addClass("btn-writing"); 771 } 772 $.ajax({ 773 type : 'POST', 774 data : {data : data, review_code : review_code}, 775 url : ('/booking/add_review_comment.cm'), 776 dataType : 'json', 777 async : false, 778 cache : false, 779 success : function(result){ 780 if(t.hasClass("btn-writing")){ 781 t.removeClass("btn-writing"); 782 } 783 if(result.msg == 'SUCCESS'){ 784 $('#comment_count_'+review_code).text(result.comment_count); 785 getReviewCommentHtml(review_code,t); 786 $("div[id^='sub_review_image_box_']").hide(); 787 }else alert(result.msg); 788 } 789 }); 790 }; 791 792 var getReviewCommentHtml = function(code,object){ 793 $review_comment_wrap = $('.review_comment_wrap_'+code); 794 if(!object.hasClass('active')){ 795 $.ajax({ 796 type : 'POST', 797 data : {'code' : code}, 798 url : ('/booking/get_review_comment_list.cm'), 799 dataType : 'json', 800 async : false, 801 cache : false, 802 success : function(result){ 803 if(result.msg === 'SUCCESS'){ 804 $review_comment_wrap.html(result.html); 805 $review_comment_wrap.show(); 806 }else{ 807 alert(result.msg); 808 } 809 } 810 }); 811 }else{ 812 $review_comment_wrap.hide(); 813 } 814 }; 815 816 var removeCommentImg = function(obj){ 817 var box_obj = obj.parent().parent(); 818 obj.parent().remove(); 819 if(box_obj.find('.file-add').length == 0)box_obj.hide(); 820 }; 821 822 var reviewCommentDelete = function(code){ 823 if(confirm(LOCALIZE.ì¤ëª _ìì íìê² ìµëê¹())){ 824 $.ajax({ 825 type : 'POST', 826 data : {code : code, review_code : review_code}, 827 url : ('/booking/delete_review_comment.cm'), 828 async : false, 829 dataType : 'json', 830 success : function(result){ 831 if(result.msg == 'SUCCESS'){ 832 $('#comment_count_'+review_code).text(result.comment_count); 833 getReviewCommentHtml(review_code,$(this)); 834 }else 835 alert(result.msg); 836 } 837 }); 838 } 839 }; 840 841 var EditHide = function(idx){ 842 var editor_form = $("._sub_form_editor_" + idx); 843 editor_form.hide(); 844 $('.tools').show(); 845 editor_form.siblings('._comment_body').show(); 846 editor_form.closest('.comment_area').siblings().show(); 847 editor_form.closest('.comment_area').css('padding-top', ''); 848 editor_form.css('margin-top', ''); 849 }; 850 851 return { 852 init : function(code){ 853 init(code); 854 }, 855 imageUploadInit : function(idx){ 856 imageUploadInit(idx); 857 }, 858 submit : function(t, type, i){ 859 submit(t, type, i); 860 }, 861 getReviewCommentHtml : function(code,object){ 862 getReviewCommentHtml(code,object); 863 }, 864 removeCommentImg : function(obj){ 865 removeCommentImg(obj); 866 }, 867 Delete : function(code){ 868 reviewCommentDelete(code); 869 }, 870 EditHide : function(idx){ 871 EditHide(idx); 872 } 873 874 } 875}(); 876 877var SITE_BOOKING_REVIEW = function(){ 878 var $review_wrap; 879 var $review_form; 880 var $mobile_form; 881 var $rating; 882 var $star; 883 var $m_rating; 884 var $m_star; 885 var $comment_body; 886 var $review_image_box; 887 var $comment_area; 888 var $platform; 889 var images = {}; 890 891 var init = function(t){ 892 switch(t){ 893 case 'pc': 894 $platform = $('.booking_nav_tools'); 895 break; 896 case 'mobile': 897 $platform = $('.m_booking_nav_tools'); 898 break; 899 } 900 $star = $("._star"); 901 $rating = $("#rating"); 902 $review_form = $("#review_form"); 903 904 905 $review_form.find('#review_image_upload_btn').fileupload({ 906 url: '/ajax/review_image_upload.cm', 907 formData: {target: 'site_review', type: 'image'}, 908 dataType: 'json', 909 singleFileUploads: true, 910 limitMultiFileUploads: 1, 911 start: function(e, data){ 912 }, 913 progress: function(e, data){ 914 }, 915 done: function(e, data){ 916 $.each(data.result.files, function(e, tmp){ 917 if(tmp.error == null){ 918 $review_form.find("#review_image_box").show(); 919 $review_form.find('._btn_add_image').toggleClass('no-margin', false); 920 var url = tmp.url; 921 images[tmp.code] = url; 922 var html = '<span class="file-add _img_'+tmp.code+'"><input type="hidden" name="img" value="' + tmp.name + '"><div class="img-thumb-wrap"><img src="' + CDN_UPLOAD_URL + url + '"></div><a class="del" href="javascript:;" onclick="SITE_BOOKING_REVIEW.deleteReviewImage(\''+tmp.code+ '\')" ><i class="btm bt-times vertical-middle" aria-hidden="true"></i></a></span>'; 923 $review_form.find("#review_image_box ._btn_add_image").before(html); 924 }else{ 925 alert(tmp.error); 926 } 927 }); 928 }, 929 fail: function(e, data){ 930 alert(getLocalizeString("ì¤ëª _ì ë¡ëìì¤í¨íììµëë¤", "", "ì ë¡ëì ì¤í¨ íììµëë¤.")); 931 } 932 }); 933 934 935 // $mobile_form = $platform.find('#mobile_review_form'); 936 // $m_rating = $mobile_form.find('#mobile_rating'); 937 // $m_star = $mobile_form.find('._star'); 938 // $mobile_form.find("#mobile_review_image_box").hide(); 939 // 940 // $mobile_form.find('#mobile_review_image_upload_btn').setUploadImage({ 941 // url : '/shop/upload_image.cm', 942 // dropZone : 'icon_img_upload_wrap', 943 // singleFileUploads : true, 944 // formData : {temp : 'Y'} 945 // }, function(res, data){ 946 // $mobile_form.find("#mobile_review_image_box").show(); 947 // $.each(data, function(e, tmp){ 948 // if(tmp.error == "" || tmp.error == null){ 949 // var url = CDN_UPLOAD_URL + tmp.url; 950 // var html = '<span class="file-add"><input type="hidden" name="img" value="' + tmp.name + '"><div class="file-add-bg" style="background: url('+url+') no-repeat center center;"></div><em class="del" onclick="POST_COMMENT.removeCommentImg($(this))"></em></span>'; 951 // $mobile_form.find("#mobile_review_image_box").append(html); 952 // }else{ 953 // alert(tmp.error); 954 // } 955 // }); 956 // }); 957 // autosize($('.textarea_block textarea')); 958 }; 959 960 var changeRating = function(t,n){ 961 if(t == 'desktop'){ 962 $rating.val(n + 1); 963 $star.each(function(e){ 964 if(n <= 0 && e == 0){ 965 if(n == -1){ 966 $(this).removeClass('active'); 967 }else{ 968 $(this).addClass('active'); 969 } 970 }else{ 971 $(this).removeClass('active');
972 if(e <= n){ 973 $(this).addClass('active'); 974 } 975 } 976 }); 977 }else{ 978 $m_rating.val(n + 1); 979 $m_star.each(function(e){ 980 if(n <= 0 && e == 0){ 981 if(n == -1){ 982 $(this).removeClass('active'); 983 }else{ 984 $(this).addClass('active'); 985 } 986 }else{ 987 $(this).removeClass('active'); 988 if(e <= n){ 989 $(this).addClass('active'); 990 } 991 } 992 }); 993 } 994 }; 995 996 var reviewFormShow = function(t){ 997 var sub_form = $("._sub_form_" + t); 998 999 sub_form.data('show', 'Y'); 1000 sub_form.show(); 1001 var comment_add_body = sub_form.find('._comment_add_body_' + t); 1002 1003 $('body').off('mouseup.sub_comment') 1004 .on('mouseup.sub_comment', function(e){ 1005 var $c_target = $(e.target); 1006 var $s_form = $c_target.closest('._sub_form_' + t + ', ._show_sub_form_btn_' + t); 1007 if($s_form.length == 0){ 1008 1009 var text = comment_add_body.val(); 1010 sub_form.data('show', 'N'); 1011 if(text == ''){ 1012 $('body').off('mouseup.sub_comment'); 1013 reviewFormHide(); 1014 } 1015 } 1016 }); 1017 }; 1018 1019 var reviewEditShow = function(t){ 1020 var editor_form = $("._sub_form_editor_" + t); 1021 editor_form.siblings('.block-postmeta').find('.comment_area').hide(); 1022 1023 editor_form.data('show', 'Y'); 1024 editor_form.show(); 1025 1026 }; 1027 1028 var DeleteShow = function(code,prod_code,only_photo){ 1029 var $show_secret_password = $('#show_secret_password'); 1030 var $show_link = $(event.target); 1031 if($show_secret_password.length == 0){ 1032 $show_secret_password = $('<div class="remove-pop" id="show_secret_password" onclick="event.cancelBubble = true;" tabindex="0" style="position:absolute;z-index:99999;"><p>'+LOCALIZE.ì¤ëª _ìì±ìë±ë¡íì ë¹ë°ë²í¸ë¥¼ì ë ¥í´ì£¼ì¸ì()+'</p><div class="input_area"><input type="password" placeholder="'+LOCALIZE.ì¤ëª _ë¹ë°ë²í¸()+'"><button class="btn btn-primary _confirm">'+LOCALIZE.ë²í¼_íì¸ë«ê¸°()+'</button></div></div>').hide(); 1033 $show_link.after($show_secret_password); 1034 } 1035 $show_secret_password.find('input').val(''); 1036 $show_secret_password.show(); 1037 $show_secret_password.off('click', '._confirm') 1038 .on('click', '._confirm', function(){ 1039 var secret_pass = $show_secret_password.find('input').val(); 1040 CheckSecret(code,secret_pass,function(){ 1041 // íì¸í ë¹ë°ë²í¸ë¥¼ ìì ìì²ìë ê·¸ëë¡ ì£ëë¤. ìë²ê° ì¼ê´ë±ë¡ íìì 1042 // ìì ê¶ ì¸ì ì ê·¼ê±°ë¡ ì¼ì§ ìì¼ë¯ë¡, ì´ ê°ì´ ìì¼ë©´ ì ì ìì ë ê±°ì ëë¤. 1043 reviewDelete(code, prod_code,'',only_photo, undefined, secret_pass); 1044 }); 1045 $show_secret_password.hide(); 1046 }); 1047 $('body').off('mousedown.show_secret') 1048 .on('mousedown.show_secret', function(e){ 1049 var $tmp = $(e.target).closest('#show_secret_password'); 1050 if($tmp.length == 0){ 1051 $show_secret_password.hide(); 1052 $('body').off('click.show_secret'); 1053 } 1054 }); 1055 }; 1056 1057 var CheckSecret = function(code,secret_pass,callback){ 1058 $.ajax({ 1059 type:'post', 1060 data:{code:code,secret_pass :secret_pass, type : 'review'}, 1061 url:'/ajax/check_review_pass.cm', 1062 dataType:'json', 1063 success:function(result){ 1064 if(result.msg == 'SUCCESS'){ 1065 if(typeof callback == 'function') 1066 callback(); 1067 }else{ 1068 alert(result.msg); 1069 } 1070 } 1071 }); 1072 }; 1073 1074 var reviewEditHide = function(t){ 1075 var editor_form = $("._sub_form_editor_" + t); 1076 editor_form.hide(); 1077 editor_form.siblings('.block-postmeta').find('.comment_area').show(); 1078 }; 1079 1080 var reviewFormHide = function(){ 1081 $("._sub_review_form").hide(); 1082 }; 1083 1084 var reviewDelete = function(code, prod_code,r_p, only_photo, buyer_permission, secret_pass){ 1085 only_photo = only_photo ? 'Y' : 'N'; 1086 var _msg = buyer_permission == 'Y' ? LOCALIZE.ì¤ëª _í기를ìì íìê² ìµëê¹() : LOCALIZE.ì¤ëª _ìì íìê² ìµëê¹(); 1087 if(confirm(_msg)){ 1088 $.ajax({ 1089 type : 'POST', 1090 data : {'code' : code, 'prod_code' : prod_code, 'review_pass' : secret_pass || ''}, 1091 url : ('/booking/delete_review.cm'), 1092 dataType : 'json', 1093 success : function(result){ 1094 if(result.msg == 'SUCCESS'){ 1095 SITE_BOOKING.changeContentTab('review',r_p,'',only_photo); 1096 }else 1097 alert(result.msg); 1098 } 1099 }); 1100 } 1101 }; 1102 1103 var imageUploadInit = function(n){ 1104 $("#sub_review_image_box_" + n).hide(); 1105 //$("#editor_review_image_box_"+n).hide(); 1106 1107 $('#sub_review_image_upload_btn_' + n).setUploadImage({ 1108 url : '/shop/upload_image.cm', 1109 dropZone : 'icon_img_upload_wrap', 1110 singleFileUploads : true, 1111 formData : {temp : 'Y'} 1112 }, function(res, data){ 1113 $("#sub_review_image_box_" + n).show(); 1114 $.each(data, function(e, tmp){ 1115 if(tmp.error == "" || tmp.error == null){ 1116 var url = CDN_UPLOAD_URL + tmp.url; 1117 var html = '<span class="file-add"><input type="hidden" name="img" value="' + tmp.name + '"><div class="file-add-bg" style="background: url('+url+') no-repeat center center;"></div><em class="del" onclick="POST_COMMENT.removeCommentImg($(this))"></em></span>'; 1118 $("#sub_review_image_box_" + n).append(html); 1119 }else{ 1120 alert(tmp.error); 1121 } 1122 }); 1123 }); 1124 1125 $('#editor_review_image_upload_btn_' + n).setUploadImage({ 1126 url : '/shop/upload_image.cm', 1127 dropZone : 'icon_img_upload_wrap', 1128 singleFileUploads : true, 1129 formData : {temp : 'Y'} 1130 }, function(res, data){ 1131 $("#editor_review_image_box_" + n).show(); 1132 $.each(data, function(e, tmp){ 1133 if(tmp.error == "" || tmp.error == null){ 1134 var url = CDN_UPLOAD_URL + tmp.url; 1135 var html = '<span class="file-add"><input type="hidden" name="img" value="' + tmp.name + '"><div class="file-add-bg" style="background: url('+url+') no-repeat center center;"></div><em class="del" onclick="POST_COMMENT.removeCommentImg($(this))"></em></span>'; 1136 $("#editor_review_image_box_" + n).append(html); 1137 }else{ 1138 alert(tmp.error); 1139 } 1140 }); 1141 }); 1142 }; 1143 1144 var submit = function(t, type, i){ 1145 var data = $review_form.serializeObject(); 1146 data.images = images; 1147 $.ajax({ 1148 type : 'POST', 1149 data : data, 1150 url : ('/booking/add_review.cm'), 1151 dataType : 'json', 1152 cache : false, 1153 success : function(result){ 1154 if(result.msg == 'SUCCESS'){ 1155 reviewCompleted(); 1156 }else 1157 alert(result.msg); 1158 } 1159 }); 1160 }; 1161 1162 var reviewCompleted = function(){ 1163 $.cocoaDialog.close(); 1164 $.ajax({ 1165 type: 'POST', 1166 data: {}, 1167 url: ('/booking/add_review_completed.cm'), 1168 dataType: 'html', 1169 async: false, 1170 cache: false, 1171 success : function(html){ 1172 $.cocoaDialog.open({ 1173 type : 'prod_review_completed', 1174 custom_popup : html, 1175 'close_block' : false, 1176 hide_event : function(){ 1177 location.reload(); 1178 } 1179 }); 1180 } 1181 }); 1182 }; 1183 1184 var createHtml = function(prod_idx, review_page, qna_page,paging_on,only_photo){ 1185 $review_wrap = $platform.find('#prod_detail_content'); 1186 $.ajax({ 1187 type : 'POST', 1188 data : {prod_idx : prod_idx, review_page : review_page, qna_page : qna_page, only_photo : only_photo}
1188, 1189 url : ('/booking/prod_review.cm'), 1190 dataType : 'html', 1191 cache : false, 1192 success : function(result){ 1193 $review_wrap.html(result); 1194 } 1195 }); 1196 }; 1197 1198 1199 var openAddReview = function(idx, prod_code, code){ 1200 $.cocoaDialog.close(); 1201 $.ajax({ 1202 type : 'POST', 1203 data : {'idx' : idx, 'prod_code' : prod_code, 'code' : code}, 1204 url : ('/booking/open_add_review.cm'), 1205 dataType : 'json', 1206 cache : false, 1207 async : false, 1208 success : function(result){ 1209 if(result.msg === 'SUCCESS'){ 1210 $.cocoaDialog.open({type : 'add_review', custom_popup : result.html,'close_block': true, width : 800, hide_event : function(){ 1211 images = {}; 1212 }}); 1213 }else{ 1214 alert(result.msg); 1215 } 1216 } 1217 }); 1218 }; 1219 1220 var EditReviewShow = function (idx, prod_code, code) { 1221 var $show_secret_password = $('#show_secret_password'); 1222 var $show_link = $(event.target); 1223 if ($show_secret_password.length == 0) { 1224 $show_secret_password = $('<div class="remove-pop" id="show_secret_password" onclick="event.cancelBubble = true;" tabindex="0" style="position:absolute;z-index:99999;"><p>' + LOCALIZE.ì¤ëª _ìì±ìë±ë¡íì ë¹ë°ë²í¸ë¥¼ì ë ¥í´ì£¼ì¸ì() + '</p><div class="input_area"><input type="password" placeholder="' + LOCALIZE.ì¤ëª _ë¹ë°ë²í¸() + '"><button class="btn btn-primary _confirm">' + LOCALIZE.ë²í¼_íì¸ë«ê¸°() + '</button></div></div>').hide(); 1225 $show_link.after($show_secret_password); 1226 } 1227 $show_secret_password.find('input').val(''); 1228 $show_secret_password.show(); 1229 $show_secret_password.off('click', '._confirm') 1230 .on('click', '._confirm', function () { 1231 var secret_pass = $show_secret_password.find('input').val(); 1232 CheckSecret(code, secret_pass, function () { 1233 SITE_BOOKING_REVIEW.openAddReview(idx, prod_code, code); 1234 }); 1235 $show_secret_password.hide(); 1236 }); 1237 $('body').off('mousedown.show_secret') 1238 .on('mousedown.show_secret', function (e) { 1239 var $tmp = $(e.target).closest('#show_secret_password'); 1240 if ($tmp.length == 0) { 1241 $show_secret_password.hide(); 1242 $('body').off('click.show_secret'); 1243 } 1244 }); 1245 }; 1246 1247 var convertReviewImage = function(image_list){ 1248 $review_form.find("#review_image_box").show(); 1249 $review_form.find('._btn_add_image').toggleClass('no-margin', false); 1250 for(var i = 0; i < image_list.length; i++){ 1251 images[i] = image_list[i]; 1252 var html = '<span class="file-add _img_'+i+'"><input type="hidden" name="img" value="' + i + '"><div class="img-thumb-wrap"><img src="' + CDN_UPLOAD_URL + image_list[i] + '"></div><a class="del" href="javascript:;" onclick="SITE_BOOKING_REVIEW.deleteReviewImage(\''+i+ '\')" ><i class="btm bt-times vertical-middle" aria-hidden="true"></i></a></span>'; 1253 $review_form.find("#review_image_box ._btn_add_image").before(html); 1254 } 1255 }; 1256 1257 var deleteReviewImage = function(code){ 1258 if ( typeof images[code] != 'undefined' ) { 1259 delete images[code]; 1260 } 1261 $("span._img_"+code).remove(); 1262 }; 1263 1264 var checkReviewData = function(){ 1265 var review_body = $("#review_body").val(); 1266 var check = Object.keys(images).length > 0 || review_body != ''; 1267 if(check){ 1268 if(confirm(LOCALIZE.ì¤ëª _ìì±íë´ì©ì´ëª¨ëì¬ë¼ì§ëë¤())){ 1269 $.cocoaDialog.close(); 1270 }else{ 1271 return false; 1272 } 1273 }else{ 1274 $.cocoaDialog.close(); 1275 } 1276 }; 1277 1278 return { 1279 init : function(t){ 1280 init(t); 1281 }, 1282 submit : function(t,type,i){ 1283 submit(t,type,i); 1284 }, 1285 changeRating : function(t,n){ 1286 changeRating(t,n); 1287 }, 1288 FormShow : function(t){ 1289 reviewFormShow(t); 1290 }, 1291 Delete : function(code, prod_code,r_p, only_photo, buyer_permission, secret_pass){ 1292 reviewDelete(code, prod_code,r_p, only_photo, buyer_permission, secret_pass); 1293 }, 1294 DeleteShow : function(code,prod_code,only_photo){ 1295 DeleteShow(code,prod_code,only_photo); 1296 }, 1297 EditShow : function(t){ 1298 reviewEditShow(t); 1299 }, 1300 EditHide : function(t){ 1301 reviewEditHide(t); 1302 }, 1303 imageUploadInit : function(n){ 1304 imageUploadInit(n); 1305 }, 1306 createHtml : function(prod_idx, review_page, qna_page,paging_on,only_photo){ 1307 createHtml(prod_idx, review_page, qna_page,paging_on,only_photo); 1308 }, 1309 openAddReview : function(idx, prod_code, code){ 1310 openAddReview(idx, prod_code, code); 1311 }, 1312 EditReviewShow : function (idx, prod_code, code) { 1313 EditReviewShow(idx, prod_code, code); 1314 }, 1315 convertReviewImage : function(image_list){ 1316 convertReviewImage(image_list); 1317 }, 1318 deleteReviewImage : function(code){ 1319 deleteReviewImage(code); 1320 }, 1321 reviewCompleted : function(){ 1322 reviewCompleted(); 1323 },
1324 checkReviewData : function(){ 1325 checkReviewData() 1326 } 1327 } 1328}(); 1329 1330var SITE_BOOKING_QNA = function(){ 1331 var $qna_wrap; 1332 var $mobile_form; 1333 var $form; 1334 var $secret; 1335 var $m_secret; 1336 var $platform; 1337 1338 var init = function(t,qna_secret_type){ 1339 switch(t){ 1340 case 'pc': 1341 $platform = $('.booking_nav_tools'); 1342 break; 1343 case 'mobile': 1344 $platform = $('.m_booking_nav_tools'); 1345 break; 1346 } 1347 $mobile_form = $platform.find('#mobile_qna_form'); 1348 $m_secret = $mobile_form.find('._secret'); 1349 $secret = $platform.find('._secret'); 1350 if(qna_secret_type == 'secret'){ 1351 $secret.addClass('active'); 1352 $platform.find('#secret').val('Y'); 1353 }else{ 1354 if(qna_secret_type == 'no_secret'){ 1355 $secret.removeClass('active'); 1356 $platform.find('#secret').val('N'); 1357 }else{ 1358 $secret.on('click', function(){ 1359 if($secret.hasClass('active')){ 1360 $secret.removeClass('active'); 1361 $platform.find('#secret').val('N'); 1362 }else{ 1363 $secret.addClass('active'); 1364 $platform.find('#secret').val('Y'); 1365 } 1366 }); 1367 } 1368 } 1369 if($platform.find('#secret').val() != ''){//ìì ì¼ ê²½ì° ë¹ë°ê¸ ì²´í¬ 1370 if($platform.find('#secret').val() == 'Y'){ 1371 $secret.addClass('active'); 1372 $platform.find('#secret').val('Y'); 1373 }else{ 1374 $secret.removeClass('active'); 1375 $platform.find('#secret').val('N'); 1376 } 1377 } 1378 $mobile_form.find("#mobile_qna_image_box").hide(); 1379 1380 $mobile_form.find('#mobile_qna_image_upload_btn').setUploadImage({ 1381 url : '/shop/upload_image.cm', 1382 dropZone : 'icon_img_upload_wrap', 1383 singleFileUploads : true, 1384 formData : {temp : 'Y'} 1385 }, function(res, data){ 1386 $mobile_form.find("#mobile_qna_image_box").show(); 1387 $.each(data, function(e, tmp){ 1388 if(tmp.error == "" || tmp.error == null){ 1389 var url = CDN_UPLOAD_URL + tmp.url; 1390 var html = '<span class="file-add"><input type="hidden" name="img" value="' + tmp.name + '"><div class="file-add-bg" style="background: url('+url+') no-repeat center center;"></div><em class="del" onclick="POST_COMMENT.removeCommentImg($(this))"></em></span>'; 1391 $mobile_form.find("#mobile_qna_image_box").append(html); 1392 }else{ 1393 alert(tmp.error); 1394 } 1395 }); 1396 }); 1397 autosize($('.textarea_block textarea')); 1398 }; 1399 1400 var qnaFormShow = function(t){ 1401 var sub_form = $("._sub_form_" + t); 1402 1403 sub_form.data('show', 'Y'); 1404 sub_form.show(); 1405 var comment_add_body = sub_form.find('._comment_add_body_' + t); 1406 1407 $('body').off('mouseup.sub_comment') 1408 .on('mouseup.sub_comment', function(e){ 1409 var $c_target = $(e.target); 1410 var $s_form = $c_target.closest('._sub_form_' + t + ', ._show_sub_form_btn_' + t); 1411 if($s_form.length == 0){ 1412 1413 var text = comment_add_body.val(); 1414 sub_form.data('show', 'N'); 1415 if(text == ''){ 1416 $('body').off('mouseup.sub_comment'); 1417 qnaFormHide(); 1418 } 1419 } 1420 }); 1421 }; 1422 1423 var qnaEditShow = function(t){ 1424 var editor_form = $("._sub_form_editor_" + t); 1425 editor_form.siblings('.block-postmeta').find('.feed-summary').hide(); 1426 editor_form.data('show', 'Y'); 1427 editor_form.show(); 1428 editor_form.css('margin-top', '-32px'); 1429 }; 1430 1431 var qnaEditHide = function(t){ 1432 var editor_form = $("._sub_form_editor_" + t); 1433 editor_form.hide(); 1434 editor_form.siblings('.block-postmeta').find('.feed-summary').show(); 1435 }; 1436 1437 1438 var qnaFormHide = function(){ 1439 $("._sub_qna_form").hide(); 1440 }; 1441 var qnaDelete = function(code, prod_code, secret_pass){ 1442 if(confirm(LOCALIZE.ì¤ëª _ìì íìê² ìµëê¹())){ 1443 $.ajax({ 1444 type : 'POST', 1445 data : {code : code, prod_code : prod_code, secret_pass : secret_pass, isbook:'Y'}, 1446 url : ('/shop/delete_qna.cm'), 1447 dataType : 'json', 1448 success : function(result){ 1449 if(result.msg == 'SUCCESS'){ 1450 SITE_BOOKING.changeContentTab('qna'); 1451 }else 1452 alert(result.msg); 1453 } 1454 }); 1455 } 1456 }; 1457 1458 var qnaModify = function(idx, prod_code, secret_pass, is_book, code){ 1459 $.ajax({ 1460 type : 'POST', 1461 data : {idx : idx, prod_code : prod_code, secret_pass : secret_pass, is_book : is_book, code : code}, 1462 url : ('/shop/show_secret_qna.cm'), 1463 dataType : 'json', 1464 success : function(result){ 1465 if(result.msg == 'SUCCESS'){ 1466 // ìì í¼ì ìì ììê²ë§ ë´ë ¤ê°ë¤. ë¹ë°ë²í¸ë¡ íì¸í기 ì ì´ë¼ ìì§ ìì¼ë©´ 1467 // 목ë¡ì ë¤ì ë°ì ë¤ ì°ë¤ â ìë²ê° ì´ì ì´ ì¸ì ì ìì±ìë¡ ë³¸ë¤. 1468 if($("._sub_form_editor_" + idx).length){ 1469 qnaEditShow(idx); 1470 }else{ 1471 // ë³´ê³ ìë íì´ì§ë¥¼ ê·¸ëë¡ ë¤ì ë°ëë¤. 1íì´ì§ë¡ ëìê°ë©´ 1472 // 2íì´ì§ ì´í ê¸ì í¼ì´ ìì´ ì무 ì¼ë ì ì¼ì´ëë¤. 1473 var qna_page = $platform.find('.comment_section').data('qna-page') || ''; 1474 createHtml(result.prod_idx, '', qna_page, function(){ qnaEditShow(idx); }); 1475 } 1476 }else 1477 alert(result.msg); 1478 } 1479 }); 1480 }; 1481 1482 var qnaShow = function(idx, prod_code, secret_pass, is_book, code){ 1483 $.ajax({ 1484 type : 'POST', 1485 data : {idx : idx, prod_code : prod_code, secret_pass : secret_pass, is_book : is_book, code : code}, 1486 url : ('/shop/show_secret_qna.cm'), 1487 dataType : 'json', 1488 success : function(result){ 1489 if(result.msg == 'SUCCESS'){ 1490 $("._comment_body_"+idx).html(result.html); 1491 if(result.isSubComment){ 1492 for(var i in result.sub_comment){ 1493 var sub_data = result.sub_comment[i]; 1494 $("._comment_child_"+idx+"_"+sub_data.idx).html(sub_data.html); 1495 } 1496 } 1497 }else 1498 alert(result.msg); 1499 } 1500 }); 1501 }; 1502 1503 var qnaConfirmShow = function (e, idx, prod_code, type,code){ 1504 var $show_secret_password = $('#show_secret_password'); 1505 if($show_secret_password.length == 0){ 1506 $show_secret_password = $('<div class="remove-pop" id="show_secret_password" style="position:absolute; left:0;top:0;z-index:99999;"><p>'+LOCALIZE.ì¤ëª _ìì±ìë±ë¡íì ë¹ë°ë²í¸ë¥¼ì ë ¥í´ì£¼ì¸ì()+'</p><div class="input_area"><input type="password" placeholder="'+LOCALIZE.ì¤ëª _ë¹ë°ë²í¸()+'"><button class="btn btn-primary _confirm">'+LOCALIZE.ë²í¼_íì¸ë«ê¸°()+'</button></div></div>').hide(); 1507 $('body').append($show_secret_password); 1508 } 1509 var $show_link = $(event.target); 1510 1511 var top = $show_link.offset().top; 1512 var left = $show_link.offset().left; 1513 1514 $show_secret_password.css({ 1515 position : 'absolute', 1516 top : top, 1517 left : left 1518 }); 1519 1520 $show_secret_password.find('input').val(''); 1521 $show_secret_password.show(); 1522 $show_secret_password.off('click', '._confirm') 1523 .on('click', '._confirm', function(){ 1524 var secret_pass = $show_secret_password.find('input').val(); 1525 $show_secret_password.hide(); 1526 switch(type){ 1527 case 'show' :
1528 qnaShow(idx, prod_code, secret_pass, 'Y',code); 1529 break; 1530 case 'modify' : 1531 qnaModify(idx, prod_code, secret_pass, 'Y',code); 1532 break; 1533 case 'delete' : 1534 qnaDelete(code, prod_code, secret_pass); 1535 break; 1536 1537 } 1538 }); 1539 $('body').off('mousedown.show_secret') 1540 .on('mousedown.show_secret', function(e){ 1541 var $tmp = $(e.target).closest('#show_secret_password'); 1542 if($tmp.length == 0){ 1543 $show_secret_password.hide(); 1544 $('body').off('click.show_secret'); 1545 } 1546 }); 1547 }; 1548 1549 var imageUploadInit = function(n){ 1550 $("#sub_qna_image_box_" + n).hide(); 1551 1552 $('#sub_qna_image_upload_btn_' + n).setUploadImage({ 1553 url : '/shop/upload_image.cm', 1554 dropZone : 'icon_img_upload_wrap', 1555 singleFileUploads : true, 1556 formData : {temp : 'Y'} 1557 }, function(res, data){ 1558 $("#sub_qna_image_box_" + n).show(); 1559 $.each(data, function(e, tmp){ 1560 if(tmp.error == "" || tmp.error == null){ 1561 var url = CDN_UPLOAD_URL + tmp.url; 1562 var html = '<span class="file-add"><input type="hidden" name="img" value="' + tmp.name + '"><div class="file-add-bg" style="background: url('+url+') no-repeat center center;"></div><em class="del" onclick="POST_COMMENT.removeCommentImg($(this))"></em></span>'; 1563 $("#sub_qna_image_box_" + n).append(html); 1564 }else{ 1565 alert(tmp.error); 1566 } 1567 }); 1568 }); 1569 1570 $('#editor_qna_image_upload_btn_' + n).setUploadImage({ 1571 url : '/shop/upload_image.cm', 1572 dropZone : 'icon_img_upload_wrap', 1573 singleFileUploads : true, 1574 formData : {temp : 'Y'} 1575 }, function(res, data){ 1576 $("#editor_qna_image_box_" + n).show(); 1577 $.each(data, function(e, tmp){ 1578 if(tmp.error == "" || tmp.error == null){ 1579 var url = CDN_UPLOAD_URL + tmp.url; 1580 var html = '<span class="file-add"><input type="hidden" name="img" value="' + tmp.name + '"><div class="file-add-bg" style="background: url('+url+') no-repeat center center;"></div><em class="del" onclick="POST_COMMENT.removeCommentImg($(this))"></em></span>'; 1581 $("#editor_qna_image_box_" + n).append(html); 1582 }else{ 1583 alert(tmp.error); 1584 } 1585 }); 1586 }); 1587 }; 1588 1589 var submit = function(t, type, i){ 1590 console.log(type); 1591 console.log($form); 1592 console.log($platform); 1593 switch(type){ 1594 case 'main': // PC íí form Q&A 1595 var data = $form.serializeObject(); 1596 break; 1597 case 'sub_form': //PC íí form Q&A ëê¸ 1598 var data = $platform.find('#sub_qna_form_' + i).serializeObject(); 1599 break; 1600 case 'editor': // PC íí form Q&A ìì 1601 var data = $platform.find('#sub_qna_editor_form_' + i).serializeObject(); 1602 break; 1603 case 'mobile': // Mobile íí form Q&A 1604 var data = $platform.find('#mobile_qna_form').serializeObject(); 1605 break; 1606 case 'mobile_sub_form': // Mobile íí form Q&A ëê¸ 1607 var data = $platform.find('#mobile_sub_qna_form_' + i).serializeObject(); 1608 break; 1609 case 'mobile_editor': // Mobile íí form Q&A ìì 1610 var data = $platform.find('#mobile_sub_qna_editor_form_' + i).serializeObject(); 1611 break; 1612 } 1613 if(!t.hasClass("btn-writing")){ 1614 t.addClass("btn-writing"); 1615 } 1616 1617 $.ajax({ 1618 type : 'POST', 1619 data : {data : data, type : type}, 1620 url : ('/booking/add_qna.cm'), 1621 dataType : 'json', 1622 cache : false, 1623 success : function(result){ 1624 if(t.hasClass("btn-writing")){ 1625 t.removeClass("btn-writing"); 1626 } 1627 if(result.msg == 'SUCCESS'){ 1628 SITE_BOOKING.changeContentTab('qna'); 1629 }else 1630 alert(result.msg); 1631 } 1632 }); 1633 }; 1634 1635 var createHtml = function(prod_idx, review_page, qna_page, after){ 1636 $qna_wrap = $platform.find('#prod_detail_content'); 1637 $.ajax({ 1638 type : 'POST', 1639 data : {prod_idx : prod_idx, review_page : review_page, qna_page : qna_page}, 1640 url : ('/booking/prod_qna.cm'), 1641 dataType : 'html', 1642 cache : false, 1643 success : function(result){ 1644 $qna_wrap.html(result); 1645 if(typeof after === 'function') after(); 1646 } 1647 }); 1648 }; 1649 1650 return { 1651 init : function(t,qna_secret_type){ 1652 init(t,qna_secret_type); 1653 }, 1654 submit : function(t,type,i){ 1655 submit(t,type,i); 1656 }, 1657 FormShow : function(t){ 1658 qnaFormShow(t); 1659 }, 1660 Delete : function(code, prod_code){ 1661 qnaDelete(code, prod_code); 1662 }, 1663 EditShow : function(t){ 1664 qnaEditShow(t); 1665 }, 1666 EditHide : function(t){ 1667 qnaEditHide(t); 1668 }, 1669 imageUploadInit : function(n){ 1670 imageUploadInit(n); 1671 }, 1672 confirmShow : function(e, idx, prod_code, type, code){ 1673 qnaConfirmShow(e, idx, prod_code, type, code); 1674 }, 1675 createHtml : function(prod_idx, review_page, qna_page){ 1676 createHtml(prod_idx, review_page, qna_page); 1677 } 1678 } 1679}();
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.