<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : CardListPopupForm.html
 * @desc    : 카드목록 팝업 화면
 *============================================================================
 * STYLE24
 * Copyright(C) 2019 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2021.02.01   eskim       최초 작성
 *******************************************************************************
 -->	
	<div class="modalPopup" data-width="700">
		<div class="panelStyle">
			<div class="panelTitle">
				<h2>카드목록</h2>
				<button type="button" class="close" onclick="uifnPopupClose('popupCardList')"><i class="fa fa-times"></i></button>
			</div>
			<form id="cardListForm" name="cardListForm" >
			<div class="panelContent">
				<table class="frmStyle">
					<tr>
						<td id="cardArea">
							<th:block th:if="${cardList}" th:each="oneData, status : ${cardList}">
							<label class="chkBox" th:classappend="${not #strings.isEmpty(params.arrCard) and  #strings.contains(params.arrCard,oneData.cd)?'checked':''}"><input type="checkbox" name="card" th:value="${oneData.cd}" th:text="${oneData.cdNm}" th:checked="${not #strings.isEmpty(params.arrCard) and  #strings.contains(params.arrCard,oneData.cd)}"></label>
							</th:block>
						</td>
					</tr>
				</table>
			</div>
			<ul class="panelBar">
				<li class="right">
					<button type="button" class="btnRight btn btn-success btn-lg" id="btnSaveCardList">적용</button>
				</li>
			</ul>
			</form>	
		</div>
	</div>
<script th:inline="javascript">
/*<![CDATA[*/
	
	// 적용 클릭 시
	$('#btnSaveCardList').on('click', function() {
		var arrCardCd = '';
		var arrCardNm = '';
		$("#cardListForm #cardArea label").each(function() {
			if ($(this).find("input:checkbox[name=card]").is(':checked')){
				if (gagajf.isNull(arrCardCd)){
					arrCardCd += $(this).find("input[name=card]").val();
					arrCardNm += $(this).find("input[name=card]").parent('label').text();	
				}else{
					arrCardCd += '/' + $(this).find("input[name=card]").val();
					arrCardNm += '/' + $(this).find("input[name=card]").parent('label').text();
				}
			}
		});
		
		var callback = [[${params.callBackFun}]];

		if( typeof callback != 'undefined' && callback){

			if (typeof callback == 'function') {
				callback(arrCardCd);
			}else{
				if( callback ) {
					if( callback.indexOf("(") == -1 ) eval( callback +"('" + arrCardCd + "','"+ arrCardNm  +"')");
					else eval( callback(arrCardCd, arrCardNm) );
				}
			}
			uifnPopupClose('popupCardList');
		}
		
	});
	
	$(document).ready(function() {
	
	});

/*]]>*/
</script>
</html>