<!DOCTYPE html>
<!--[if IE 8 ]><html dir="ltr" lang="zh-TW" class="ie8"><![endif]-->
<!--[if IE 9 ]><html dir="ltr" lang="zh-TW" class="ie9"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<html dir="ltr" lang="zh-TW">
<!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
<title>管理後臺</title>
<meta name="robots" content="noindex, nofollow" />
<link href="less/page.less" rel="stylesheet/less">
<link href="css/main.css" rel="stylesheet">
<link href="css/page.css" rel="stylesheet">
<script src="/jquery/jquery-1.10.js"></script>
<!-- 瀏覽用燈箱片效果 -->
<link href="/jquery/fancybox-3.0/dist/jquery.fancybox.css" rel="stylesheet">
<script src="/jquery/fancybox-3.0/dist/jquery.fancybox.min.js"></script>
<script>
	if('<?# alertMsg ?>' != ''){
		alert('<?# alertMsg ?>');
		if('<?# goBack ?>' == 'Y') history.back();
	}
	if('<?# locationHref ?>' != '') location.href = '<?# locationHref ?>';
</script>
</head>
<body>
	<?# sidePage ?>
	<div class="pos_rel" id="content">
		<?# header ?>
		<form id="form1" name="form1" method="post">
            <input type="hidden" id="id" name="id" value="<?# id ?>" />
			<div class="row mt_10 mb_5 h3 page_title"><?# page_name ?></div>
			<div class="card">
				<div class="pos_rel bg_g_100 tabs_warp" id="tabs_warp">
					<div class="tabs_list">
						<a class="tabs_item" href="templateSet.php"><?# page_name ?></a>
						<a class="tabs_item" data-action="true" href="javascript:void(0);">版型下載</a>
					</div>
				</div>
				<div class="card_body">
					<div class="mall_5 add_btn"><a class="btn btn_success" href="templateEdit.php">新增版型</a></div>
					<ul class="d_flex list_box" id="templateList">
                        <php:repeater id="list2">
                        <template>
                        <li class="row">
                            <a class="d_block fancybox" data-fancybox href="<?# Image ?>"><img src="<?# Image ?>" /></a>
                            <div class="pall_3 d_flex btnBox">
                                <p class="txt txt_clamp"><?# Name ?></p>
                                <p class="btns">
                                    <a class="mr_2 btn btn_info" href="javascript:void(0);" data-action="down" data-path="<?# Path ?>">下載</a>
                                    <a class="btn btn_warning" href="<?# Website ?>" target="_blank">範例</a>
                                </p>
                            </div>
                        </li>
                        </template>
                        </php:repeater>
                    </ul>
				</div>
			</div>
            <div class="row mt_5 d_flex start_box"><a class="mr_2 btn btn_info" id="btnOK" href="javascript:void(0);">送出</a></div>
		</form>
		<?# footer ?>
	</div>
    <div data-action="loader"><div class="loader-circle"></div></div>
</body>
</html>
<script>
	$(function(){
		$(".fancybox").fancybox();

		$('a[data-action="delItem"]').click(function(){
			if(!confirm('刪除資料後將無法恢復!是否確定要刪除版型資料?')){
				return false;
			}else{
				$.ajax({
					url: 'ajax/template.php',
					async: false,
					type: 'POST',
					data: {'do':'del','id':$(this).data('id')},
					dataType: "text",
					context: $(this).parent('font').parent('p').parent('li'),
					success: function(msg){
						if(msg == '1'){
							$(this).remove();
						}else{
							alert('刪除失敗!\r\n'+msg);
						}
					},
					error: function(){
						alert('系統異常!!');
					}
				});
			}
		});

		$('a[data-action="down"]').click(function(){
			$('div[data-action="loader"]').attr('id', 'lodbg');
			setTimeout("downtemplate("+$(this).data('path')+")", 300);
		});
	});
	function downtemplate(a){
        $.ajax({
            url: 'ajax/template.php',
            async: false,
            type: 'POST',
            data: {'do':'down','path':a},
            dataType: "json",
            success: function(obj){
                if(obj.err == '0'){
                    location.href = 'templateSet.php';
                }else{
                    alert(obj.msg);
                }
            },
            error: function(e){
                alert('系統異常!!');
            }
        });
	}
</script>