<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : PlanningReplyPhotoFormMob.html
 * @desc	: 댓글 이미지 팝업
 *============================================================================
 * STYLE24
 * Copyright(C) 2020 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE		 AUTHOR	  DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2021.05.15   sowon		최초 작성
 *******************************************************************************
 -->
<div class="modal-dialog" role="document">
	<div class="modal-content">
		<div class="modal-header">
			<h5 class="modal-title" id="exampleFullLabel">포토/영상리뷰</h5>
		</div>
		<div class="modal-body">
			<div class="pop_cont">
				<div class="photo_list" >
					<ul id="ulGoodsReviewPhoto">
					</ul>
				</div>
				<div class="review_last"   style="display:none;">
					마지막 게시글입니다.
				</div>
				<div class="btn_group_flex"  style="display:none;">
					<div>
						<button type="button" class="btn btn_default" id="btnMore">
							<span>더보기</span>
						</button>
					</div>
				</div>
			</div>
		</div>
	</div>
	<form id="goodsReviewPhotoForm" name="goodsReviewPhotoForm" action="#" th:action="@{'/goods/review/list'}">
		<input type="hidden" name="pageNo" value ="1"/>
		<input type="hidden" name="pageSize" value ="30"/>
		<input type="hidden" name="photoYn" value ="Y"/>
		<input type="hidden" name="goodsCd" th:value ="${params.goodsCd}"/>
	</form>
</div>
<a href="javascript:void(0);" rel="modal:close" onclick="cfCloseLayer('layer_review_photo')" class="close-modal">Close</a>
<script th:inline="javascript">
/*<![CDATA[*/
	
	var fnReviewPhotoGetList = function() {

		gagajf.ajaxFormSubmit($('#goodsReviewPhotoForm').prop('action'), '#goodsReviewPhotoForm', fnGetListCallback);
	}
	
	var fnGetListCallback = function(result) {
		//$('#ulGoodsReviewPhoto').html('');
	
		// 목록
		if (result.dataList != null && result.dataList.length > 0) {
			
			$.each(result.dataList, function(idx, item) {
				let tag = '';
				if (item.reviewAttachList != null && item.reviewAttachList.length > 0){
					var fileGbClass = '';
					$.each(item.reviewAttachList, function(aIdx, reviewAttach){
					//	fileGbClass = '';
					//	if (reviewAttach == "M") fileGbClass = "mov";
				tag += '				<li>\n';
				tag += '					<a href="javascript:void();" onclick="fnGoodsReviewDetail(\''+item.reviewSq+'\');">\n';
				tag += '						<div class="pic">\n';
				if ("I" ==reviewAttach.fileGb){
				tag += '							<span class="thumb" style="background-image:url('+ _imgUrl + reviewAttach.sysFileNm +');"></span>\n'; //<!-- 동영상의 썸네일일 경우 mov 클래스 추가 -->	
				}else{
				tag += '							<span class="thumb mov" style="background-image:url('+_kollusMediaUrl+'/poster/'+reviewAttach.kmcKey+');"></span>\n';
				}
				tag += '						</div>\n';
				tag += '					</a>\n';
				tag += '				</li>\n';		
				return false;
					});	
				}
				
				$('#ulGoodsReviewPhoto').append(tag);
			});
			
		}
		
		if (result.paging.pageable.totalPage > result.paging.pageable.pageNo) {
			$('#btnMore').parent().parent().show();
			$('#goodsReviewPhotoForm input[name=pageNo]').val(result.paging.pageable.pageNo + 1);
		} else {
			$('.review_last').show();
			$('#btnMore').parent().parent().hide();
		}
	}
	
	// 더보기
	$('#btnMore').on('click', function() {
		fnReviewPhotoGetList();
	});
	
	// 상세보기
	var fnGoodsReviewDetail = function(reviewSq){
		cfGoodsReviewDetail([[${params.goodsCd}]],'', 'Y', reviewSq);
		cfCloseLayer('layer_review_photo');
	}
	
	$(document).ready( function() {
		
		fnReviewPhotoGetList();
		
	});
	
/*]]>*/
</script>	
 </html>