<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="{-:*__THEME__-}/admin/css/c.css" />
<link rel="stylesheet" type="text/css" href="{-:*__THEME__-}/admin/css/mf.css" />
</head>
<body>
<form id="formEdit" action="" method="post">
<dl class="abox">
	<dt><strong>{-:@EDIT-}{-:@MENU-}</strong></dt>
	<dd>
		<table class="formTable">
			<tr>
				<td class="inputTitle">{-:@MENU_SPACE-}</td>
				<td></td>
			</tr>
			<tr>
				<td class="inputArea">
					<select onchange="get_menuList(this.value);" name="ms_alias" id="ms_alias">
						<option  value="">{-:@MENU_SPACE-}</option>
					{-foreach:$_MSL,$ms-}
						<option {-if:$ms['ms_alias']==$_MI['ms_alias']-} selected="selected"{-:/if-} value="{-:$ms['ms_alias']-}">{-:$ms['ms_name']-}</option>
					{-:/foreach-}
					</select>
				</td>
				<td class="inputTip">
					<span class="fc_r">*</span> <span class="fc_gry">{-:@MENU_SPACE_TIP-}</span>
				</td>
			</tr>
			<tr>
				<td class="inputTitle">{-:@PARENT_MENU-}</td>
				<td class="inputTitle">{-:@DISPLAY_ORDER-}</td>
			</tr>
			<tr>
				<td class="inputArea">
					<select name="m_parent_id" id="m_parent_id">
						<option {-if:0==$_MI['m_parent_id']-} selected="selected"{-:/if-} value="0">{-:@TOP_MENU-}</option>
					{-foreach:$_ML,$m-}
						{-if:$m['menu_id']!=$_MI['menu_id']-}
						<option {-if:$m['menu_id']==$_MI['m_parent_id']-} selected="selected"{-:/if-} value="{-:$m['menu_id']-}">{-:$m['m_name']-}</option>
						{-:/if-}
					{-:/foreach-}
					</select>
					<span class="fc_r">*</span> <span class="fc_gry">{-:@M_PARENT_ID_TIP-}</span>
				</td>
				<td class="inputTip">
					<input class="required i" type="text" value="{-:$_MI['m_display_order']-}" name="m_display_order" maxlength="20" size="10"> <span class="fc_r">*</span> <span class="fc_gry">{-:@M_DISPLAY_ORDER_TIP-}</span>
				</td>
			</tr>
			<tr>
				<td class="inputTitle">{-:@NAME-}</td>
				<td></td>
			</tr>
			<tr>
				<td class="inputArea">
					<input class="required i" type="text" value="{-:$_MI['m_name']-}" name="m_name" maxlength="96" size="30">
				</td>
				<td class="inputTip">
					<span class="fc_r">*</span> <span class="fc_gry">{-:@M_NAME_TIP-}</span>
				</td>
			</tr>
			<tr>
				<td class="inputTitle">{-:@TYPE-}</td>
				<td></td>
			</tr>
			<tr>
				<td class="inputArea">
					<label><input type="radio" onclick="$('#compose_url').show();" {-if:0==$_MI['m_type']-} checked="checked"{-:/if-} value="0" name="m_type"> {-:@COMPOSE-}</label>
					<label><input type="radio" onclick="$('#compose_url').hide();" {-if:1==$_MI['m_type']-} checked="checked"{-:/if-} value="1" name="m_type"> {-:@DIRECT-}</label>
				</td>
				<td class="inputTip">
					<span class="fc_r">*</span> <span class="fc_gry">{-:@M_TYPE_TIP-}</span>
				</td>
			</tr>
			<tr id="compose_url"{-if:1==$_MI['m_type']-} style="display:none"{-:/if-}>
				<td class="inputArea">
					<table class="listTable" style="width:80%">
						<tr>
							<th colspan="7">{-:@COMPOSE_URL-}</th>
						</tr>
						<tr>
							<td>home@</td>
							<td>
							<select onchange="get_actnList(this.value);" id="ctrlr">
								<option selected="selected" value="">{-:@CONTROLLER-}</option>
							{-foreach:$_CL,$c-}
								<option value="{-:$c['ctrlr']-}">{-:$c['name']-}</option>
							{-:/foreach-}
							</select>
							</td>
							<td>/</td>
							<td>
							<select id="actn">
							</select>
							</td>
							<td>?</td>
							<td><input class="i" type="text" value="" id="params" maxlength="96" size="10"></td>
							<td><a class="btn_l" onclick='compose_url();'>{-:@COMPOSE-}</a></td>
						</tr>
					</table>
				</td>
				<td class="inputTip">
					<span class="fc_r">*</span> <span class="fc_gry">{-:@COMPOSE_URL_TIP-}</span>
				</td>
			</tr>
			<tr>
				<td class="inputTitle">{-:@URL-}</td>
				<td></td>
			</tr>
			<tr>
				<td class="inputArea">
					<input class="required i" type="text" value="{-:$_MI['m_url']-}" name="m_url" id="m_url" maxlength="96" size="50">
				</td>
				<td class="inputTip">
					<span class="fc_r">*</span> <span class="fc_gry">{-:@M_URL_TIP-}</span>
				</td>
			</tr>
		</table>
	</dd>
</dl><!--/.abox-->
<div id="operation">
	<input type="hidden" value="{-:$_MI['menu_id']-}" name="menu_id">
	<span class="btn_b submit" action="{-url:menu/edit_menu_do-}" to="#formEdit">{-:@SUBMIT-}</span>
</div>
</form>
<script type="text/javascript" src="{-:*__PUBLIC__-}/js/jquery.js"></script>
<script type='text/javascript'>
/* 动态获取菜单列表 */
function get_menuList(ms_alias)
{
	$('#m_parent_id').html('');
	$.getJSON('{-url:menu/get_menuList-}',{ms_alias:ms_alias},function(data){
		$('#m_parent_id').append('<option value="">{-:@TOP_MENU-}</option>');
		for(key in data.data)
		{
			var optionStr = '<option value="' + data.data[key]['menu_id']+'">' + data.data[key]['m_name'] + '</option>';
			$('#m_parent_id').append(optionStr);
		}
	});
}

/* 动态获取动作列表 */
function get_actnList(ctrlr)
{
	$('#actn').html('');
	$.getJSON('{-url:menu/get_actnList-}',{ctrlr:ctrlr},function(data){
		for(key in data.data)
		{
			var optionStr = '<option value="' + data.data[key]+'">' + data.data[key] + '</option>';
			$('#actn').append(optionStr);
		}
	});
}

/* 合成菜单 */
function compose_url()
{
	var ctrlrVal = parse_name($('#ctrlr').val());
	var actnVal = $('#actn').val();
	var paramsVal = $('#params').val();
	if(ctrlrVal && actnVal)
	{
		if(paramsVal)
		{
			var val = 'home@'+ctrlrVal+'/'+actnVal+'?'+paramsVal;
		}
		else
		{
			var val = 'home@'+ctrlrVal+'/'+actnVal;
		}
		$('#m_url').val(val);
	}
	else
	{
		alert('{-:@CTRLR_OR_ACTN_NULL-}');
	}
}

/* 命名风格转AaaBbb -> aaa_bb */
function parse_name(name)
{
	name = name.replace(/([A-Z])/g, "_$1").toLowerCase().replace(/(^_)/g, "");
	return name;
}
</script>
<script type="text/javascript" src="{-:*__THEME__-}/admin/js/c.js"></script>
</body>
</html>