<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Admin_LabelList.aspx.vb"
    Inherits="TourEx.Web.Admin_LabelList" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题页</title>
<link rel="stylesheet" type="text/css" href="Css/Style.css"/>
<script language="javascript" src="../Sys/Js/jquery.js"></script>
<script language="javascript" src="../Sys/Js/AlertWindow.js"></script>
</head>
<body>
	<ul class="tools">
		<li class="add"><span><a href="javascript:void(0);" onclick="ShowWindow()">添加</a></span></li>
		<li class="save"><span><a href="javascript:void(0);" onclick="Save(0);return false;">保存</a></span></li>
		<li class="del"><span><a href="javascript:void(0);" onclick="Del(0);return false;">删除</a></span></li>
		<li class="search">关键词：<input id="Key" name="Key" type="text" value="<%=Key %>" class="searchTitle"/>
            <input type="button" value="" onclick="location='?Key='+$('#Key').val();" class="searchInput"/></li>
	</ul>
        <asp:Repeater ID="Repeater" runat="server">
            <HeaderTemplate>
                <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabBox">
                    <tr class="tabTitleMain">
                        <td width="35" class="selectAll">
                            <a href="javascript:void(0);" onclick="All();">全选</a>
                        </td>
                        <td width="350">标签名</td>
                        <td>说明</td>
                        <td width="100">操作</td>
                    </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr class="tabTextMain" id="From_<%#Eval("L_ID")%>" onmouseout="this.style.background='#FFFFFF';"
                    onmouseover="this.style.background='#F4F7FA';">
                    <td>
                        <input name="L_ID" type="checkbox" id="L_ID_<%#Eval("L_ID")%>" value="<%#Eval("L_ID")%>" />
                    </td>
                    <td>
                        <input name="L_Name_<%#Eval("L_ID")%>" type="text" id="L_Name_<%#Eval("L_ID")%>"
                            onkeyup="this.value=this.value.replace(/\W/g,'');" value="<%#Eval("L_Name")%>"
                            size="40" maxlength="45" ovalue="<%#Eval("L_Name")%>" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/\W/g,''))" class="formTitle"/>
                    </td>
                    <td>
                        <input name="L_Title_<%#Eval("L_ID")%>" type="text" id="L_Title_<%#Eval("L_ID")%>"
                            value="<%#Eval("L_Title")%>" size="40" maxlength="50" ovalue="<%#Eval("L_Title")%>" class="formTitle"/>
                    </td>
                    <td>
                        <a href="javascript:void(0);" onclick="Save(<%#Eval("L_ID")%>);">保存</a> 
                        <a href="Admin_LabelEdit.aspx?ID=<%#Eval("L_ID")%>">编辑</a> 
                        <a href="javascript:void(0);" onclick="Del(<%#Eval("L_ID")%>);return false;">删除</a>
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </table>
                <asp:Label ID="lblEmpty" Text="暂无" runat="server" Visible="<%#Boolean.Parse((Repeater.Items.Count = 0).ToString())%>"
                    Width="100%" Style="text-align: center">     
                </asp:Label>
            </FooterTemplate>
        </asp:Repeater>
    <webdiyer:AspNetPager ID="TourExPage" runat="server" UrlPaging="true" ShowPageIndexBox="Never"
        PageIndexBoxType="DropDownList" TextBeforePageIndexBox=""
        PageSize="20" OnPageChanged="BindData" EnableTheming="true" FirstPageText="首页"
        LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页" CssClass="page" 
            PagingButtonSpacing="" CurrentPageButtonClass="current" 
        CurrentPageButtonStyle="">
    </webdiyer:AspNetPager>
    <form id="BatchSubmit" name="BatchSubmit" method="post" action="?act=edit" style="display: none">
    </form>
    <div id="messWindow" class="messWindow">
    </div>
    <div id="promptWindow" class="promptWindow" align="center">
        <div class="titleBar">
            <span>添加自定义标签</span><span onclick="HideWindow()" style="float: right;"><img src="Images/popclose.gif" /></span></div>
        <div class="mainContent">
            <form name="form1" method="post" action="?act=add" onsubmit="return CheckForm();">
            <table width="96%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#BCCFE6">
                <tr>
                    <td class="subMainLeft" width="20%">标签名：</td>
                    <td class="subMainRight">
                        <input name="L_Name" id="L_Name" type="text" size="40" maxlength="50" onkeyup="this.value=this.value.replace(/\W/g,'');"
                            onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/\W/g,''))" class="formTitle">
                    </td>
                </tr>
                <tr>
                    <td class="subMainLeft">标签说明：</td>
                    <td class="subMainRight">
                        <input name="L_Title" type="text" id="L_Title" value="" size="40"  class="formTextarea"/>
                    </td>
                </tr>
                <tr>
                    <td class="subMainLeft">标签内容：</td>
                    <td class="subMainRight">
                        <textarea name="L_Text" cols="40" rows="10" id="L_Text" class="formTextarea"></textarea>
                    </td>
                </tr>
            </table>
			<div class="subMainFoot"><input name="submit" type="submit" class="formInput01" value="添加" /> <input type="button" class="formInput02" value="取消" onclick="HideWindow()"/></div>
            </form>
        </div>
    </div>

    <script type="text/javascript">
        	<!--        //
            $('.tabTextMain').each(function () { 
                $(this).find('td:lt(3)').bind("click", function (event) {
                    if ('TD' != event.target.tagName) return false;
                    var a = $(this).parent().find("a:contains('编辑')");
                    if (a.length == 0) return false;
                    location = $(a).attr('href'); return false;
                }); 
            });
        	function CheckForm()
        	{
        		$("#L_Name").val($.trim($("#L_Name").val().toLowerCase()));
        		if($("#L_Name").val()==""){alert("请填写标签名！");$("#L_Name").focus();return false;};
        	}
        	 function Save(ID)
        	 {
        	 	var L_IDs=ID==0?$('input[name="L_ID"]'):$('#L_ID_'+ID);
        		var L_Name,R;
        		$('#BatchSubmit').html('');
        		for(var i=0;i<L_IDs.length;i++)
        		{
        			L_Name = $.trim($('#L_Name_'+L_IDs[i].value).val());
        			$('#L_Name_'+L_IDs[i].value).val(L_Name);
        			if(L_Name==''){alert('请填写标签名！');return;}
        			R = $('#L_Title_'+L_IDs[i].value).val();
        			if(L_Name!=$('#L_Name_'+L_IDs[i].value).attr('ovalue') || R!=$('#L_Title_'+L_IDs[i].value).attr('ovalue'))
        			{
        				L_IDs[i].checked=true;
        				$('#From_'+L_IDs[i].value).clone().prependTo("#BatchSubmit");
        				$('#L_Name_'+L_IDs[i].value,'#BatchSubmit').val(L_Name);
        				$('#L_Title_'+L_IDs[i].value,'#BatchSubmit').val(R);
        			}
        		}
        	 	if($('#BatchSubmit').html()==''){alert('数据没有改动过，无需保存！');return;}
        		$('input[name="L_ID"]','#BatchSubmit').attr('checked',true);
        		$('#BatchSubmit').submit();
        	 }
        	 var Alls=true;
        	 function All(){$('input[name="L_ID"]').attr('checked',Alls);Alls=!Alls;}
        	 function Del(ID)
        	 {
        	 	var Url='?Act=del&';
        		var L_IDs;
        		if(ID>0)
        		{
        			Url +='L_ID='+ID;
        		}else{
        	 		L_IDs = $("input[name='L_ID']").serialize().replace(/&L_ID=/g,',');
        			if(L_IDs==''){alert('请选择您要删除的标签！');return;}
        			Url +=L_IDs;
        		}
        		if(confirm('您确定删除吗！')){location=Url;}
        	 }
        	 //-->
    </script>

</body>
</html>
