<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>
<script type="text/javascript" src="ckfinder/ckfinder.js"></script>
<!-- 瀏覽用燈箱片效果 -->
<link rel="stylesheet" href="/jquery/fancybox/source/jquery.fancybox.css?v=2.1.5" type="text/css" media="screen" />
<script type="text/javascript" src="/jquery/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
</head>
<body>
	<div class="wrapper">
    	<?# header ?>
    	<div class="wrap">
        	<?# sidePage ?>
            <div class="contentMain">
            	<h3><?# editTitle ?></h3>
                <div class="article" style="width: 100%;">
                    <form id="form1" name="form1" action="menuEdit.php" method="post">
                        <input type="hidden" id="id" name="id" value="<?# id ?>" />
                        <input type="hidden" id="pUrl" name="pUrl" value="<?# pUrl ?>" />
                        <fieldset style="width: 100%;">
                        	<div class="titleTyp"><p>功能資訊</p></div>
                            <div style=" background: rgba(75, 141, 248, 0.07); padding: 10px 0;">
                                <p>
                                    <label>功能名稱</label>
                                    <input type="text" id="MenuName" name="MenuName" value="<?# MenuName ?>" style="width: 300px;" />
                                </p>
                                <p>
                                    <label>上層功能</label>
                                    <select id="ParentID" name="ParentID">
                                        <option value="0">主功能</option>
                                            <php:repeater id="listP">
                                                <template>
                                                    <option value="<?# MenuID ?>"><?# MenuName ?></option>
                                                </template>
                                            </php:repeater>
                                    </select>
                                </p>
                                <div class="writList">
                                	<label style="float: left;">功能圖示</label>
                                    <a id="aMIcon" class="fancybox" style="float: left; margin: 0 10px;"><img id="imgMIcon" style="width:50px; height:50px; border:0; display:none;" /></a>
                                    <input type="text" id="MenuIcon" name="MenuIcon" value="<?# MenuIcon ?>" maxlength="128" />
                                    <input type="button" id="btnMIcon" name="btnMIcon" value="瀏覽" />
                                </div>
                                <p>
                                    <label>連結網址</label>
                                    <input type="text" id="MenuLink" name="MenuLink" value="<?# MenuLink ?>" style="width: 300px;" />
                                </p>
                                <p>
                                    <label>開啟方式</label>
                                    <input type="radio" name="LinkTarget" value="_self" />原頁開啟
                                    <input type="radio" name="LinkTarget" value="_blank" />分頁開啟
                                </p>
                                <p>
                                    <label>啟用</label>
                                    <input type="radio" name="Visible" value="1" />啟用
                                    <input type="radio" name="Visible" value="0" />不啟用
                                </p>
                                <p>
                                    <label>排序</label>
                                    <input class="text" type="text" id="OrderNO" name="OrderNO" value="<?# OrderNO ?>" onKeyPress="if (event.keyCode < 48 || event.keyCode >57) event.returnValue = false;" style="width: 300px;" /> <strong>由小到大</strong>
                                </p>
                            </div>
                            <p>
                                <input type="button" id="btnOK" name="btnOK" value="確 定" />
								<input type="button" id="btnCancel" value="返 回" />
                            </p>
                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
        <?# footer ?>
    </div>
<script>
<!--
	function SetFileField(fileUrl,data){
		$('#'+data["selectActionData"]).val(fileUrl);
		$('#'+data["selectActionData"]).change();
	}
	$(function(){
		$(".fancybox").fancybox();

		$('#ParentID').val('<?# ParentID ?>');
		$('input:radio[name="LinkTarget"][value="<?# LinkTarget ?>"]').attr('checked',true);
		$('input:radio[name="Visible"][value="<?# Visible ?>"]').attr('checked',true);

		$('#MenuIcon').change(function(){
			if($(this).val() == ''){
				$('#imgMIcon').attr('src','');
				$('#imgMIcon').css('display','none');
				$('#aMIcon').attr('href','');
			}else{
				$('#imgMIcon').attr('src',$(this).val());
				$('#imgMIcon').css('display','block');
				$('#aMIcon').attr('href',$(this).val());
			}
		});
		$('#MenuIcon').change();

		$('#btnMIcon').click(function(){
			var finder = new CKFinder();
			finder.basePath = 'ckfinder/';
			finder.resourceType = 'Files';
			finder.selectActionFunction = SetFileField;
			finder.selectActionData = 'MenuIcon';
			finder.popup();
		});

		$('#btnOK').click(function(){
			if($('#MenuName').val() == ''){
				alert('功能名稱不可空白!');
				$('#MenuName').focus();
				return false;
			}
			if($('input:radio[name="LinkTarget"]:checked').size() == 0){
				alert('請選擇開啟方式!');
				return false;
			}
			if($('input:radio[name="Visible"]:checked').size() == 0){
				alert('請選擇狀態!');
				return false;
			}
			if($('#OrderNO').val() == ''){
				alert('排序不可空白!');
				$('#OrderNO').focus();
				return false;
			}
			$('#form1').submit();
		});
		$('#btnCancel').click(function(){
			if($('#pUrl').val() == ''){
				location.href = 'menuList.php';
			}else{
				location.href = $('#pUrl').val();
			}
		});
	});
//-->
</script>
</body>
</html>