<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理後臺</title>
<meta name="keywords" content="管理後臺" />
<meta name="description" content="管理後臺" />
<script src="/jquery/jquery-1.8.2.min.js"></script>
</head>
<body>
	<div class="wrapper">
    	<?# header ?>
    	<div class="wrap">
        	<?# sidePage ?>
            <div class="contentMain">
            	<h3>功能列表</h3>
                <div class="article" style="width: 1200px;">
                    <form id="form1" name="form1" action="template_categoryList.php" method="get">
                            <div class="abbNew" style="width: 125px;"><a href="menuEdit.php?pUrl=<?# encodeUrl ?>">新增功能</a></div>
                            <div class="titleTyp">
                                <div class="userName" style="width: 150px;">功能標題</div>
                                <div class="userName" style="width: 150px;">上層功能</div>
                                <div class="userName" style="width: 250px;">連結網址</div>
                                <div class="visible">狀態</div>
                                <div class="visible">排序</div>
                                <div class="operating" style="width: 350px;">操作</div>
                            </div>
                            <php:repeater id="list">
                                <template>
                                    <div class="listTyp">
                                        <div class="userName" style="width: 150px;"><?# MenuName ?></div>
                                        <div class="userName" style="width: 150px;"><?# ParentName ?></div>
                                        <div class="userName" style="width: 250px;"><?# MenuLink ?></div>
                                        <div class="visible"><?# VisibleName ?></div>
                                        <div class="visible"><?# OrderNO ?></div>
                                        <div class="operating" style="width: 350px;">
                                            <div class="modification"><a href="menuEdit.php?id=<?# MenuID ?>&pUrl=<?# encodeUrl ?>"><span></span>修改</a></div>
                                            <div class="shutDown" style="width: 100px;"><a data-action="cvItem" data-id="<?# MenuID ?>" data-visible="<?# CVisible ?>" href="javascript:void(0);"><span></span><?# CVisibleName ?></a></div><div class="delete">
                                            <a data-action="cvItem" data-id="<?# MenuID ?>" data-visible="<?# CVisible ?>" href="javascript:void(0);"><span></span></a><a data-action="delItem" data-id="<?# MenuID ?>" href="javascript:void(0);">刪除</a></div>
                                        </div>
                                    </div>
                                </template>
                            </php:repeater>
                    </form>
                </div>
            </div>
        </div>
        <?# footer ?>
    </div>
<script>
<!--
	$(function(){
		$('a[data-action="cvItem"]').click(function(){
			if(!confirm('是否確定變更此項功能的狀態?')){
				return false;
			}else{
				$.ajax({
					url: 'ajax/menu.php',
					async: false,
					type: 'POST',
					data: {'do':'vis','id':$(this).data('id'),'vis':$(this).data('visible')},
					dataType: "text",
					context: $(this),
					success: function(msg){
						if(msg == "1"){
							$(this).data('visible','0');
							$(this).text('不使用');
							$(this).parent('td').parent('tr').children('td').eq(3).text('使用');
						}else if(msg == "0"){
							$(this).data('visible','1');
							$(this).text('使用');
							$(this).parent('td').parent('tr').children('td').eq(3).text('不使用');
						}else{
							alert('變更失敗!\r\n'+msg+'!');
						}
					},
					error: function(){
						alert('變更失敗!!');
					}
				});
			}
		});
		$('a[data-action="delItem"]').click(function(){
			if(!confirm('一旦刪除將無法回復!是否確定刪除此項功能?')){
				return false;
			}else{
				$.ajax({
					url: 'ajax/menu.php',
					async: false,
					type: 'POST',
					data: {'do':'del','id':$(this).data('id')},
					dataType: "text",
					context: $(this).parent('td').parent('tr'),
					success: function(msg){
						if(msg == "1"){
							$(this).remove();
						}else{
							alert('刪除失敗!\r\n'+msg);
						}
					},
					error: function(){
						alert('刪除失敗!!');
					}
				});
			}
		});
	});
//-->
</script>
</body>
</html>