<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Admin_News.aspx.vb" Inherits="TourEx.Web.Admin_News" %>
<%@ Import Namespace="TourEx.BLL" %>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题页</title>
<link rel="stylesheet" type="text/css" href="Css/Style.css"/>
<link href="../sys/css/jquery-ui-1.7.2.custom.css" rel="Stylesheet" type="text/css" /> 
<link href="../sys/css/jquery.cropzoom.css" rel="Stylesheet" type="text/css" /> 
<script type="text/javascript" src="../Sys/Js/jquery.js"></script>
<script type="text/javascript" src="../sys/js/AlertWindow.js"></script>
<script type="text/javascript" src="../Sys/Js/CreateSelect.js"></script>
<script type="text/javascript" src="../Sys/Js/jquery.validate.js"></script>
<script type="text/javascript" src="../Sys/Js/jquery.validate.check.js"></script>
<script type="text/javascript" src="../Sys/WebEdit/xheditor-zh-cn.min.js"></script>
<script type="text/javascript" src="../Sys/WebEdit/xheditor_plugins/ubb.js"></script>
<script type="text/javascript" src="../sys/js/jquery-ui-1.8.2.custom.js"></script>
<script type="text/javascript" src="../sys/js/jquery.cropzoom.js"></script>
<style type="text/css">
.Page {
	background:transparent url(http://xheditor.com/demos/img/plugin.gif) no-repeat 16px 16px;
	background-position:2px 2px;
}
</style>
</head>
<body>
<ul class="navLocation">
	<li>您当前位置：<a href="Admin_Main.aspx">首页</a> > <a href="Admin_NewsList.aspx">新闻列表</a> > <asp:Label ID="navIgation" runat="server" Text=""></asp:Label></li>
</ul>
<form runat="server" id="TourExForm">
<asp:HiddenField ID="RanNum" runat="server" />
<div class="infoBox">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td class="infoBoxTd" width="120px">标题：</td>
		<td><asp:TextBox ID="N_Title" runat="server" Width="300px" CssClass="formTitle"></asp:TextBox></td>
	</tr>
	<tr>
		<td class="infoBoxTd">类型：</td>
		<td>
			<span id="CategoryList">
				<asp:HiddenField ID="N_CategoryID" runat="server" Value="0" />
			</span>
			<label for="N_CategoryID"></label>
		</td>
	</tr>
	<tr>
		<td class="infoBoxTd">略缩图：</td>
		<td>
			<asp:HiddenField ID="N_PreviewPic" runat="server" />
			<iframe src="" id="UpIframe" width="300" height="25" scrolling="no" frameborder="0"></iframe>
			<span id="Preview"></span>
			<asp:HiddenField ID="CropZoom" runat="server" Value="1" />
		</td>
	</tr>
	<tr>
		<td class="infoBoxTd">Url跳转：</td>
		<td><asp:TextBox ID="N_Url" runat="server" onkeyup="$('#N_Text').valid();" Width="400px" CssClass="formTitle"></asp:TextBox></td>
	</tr>
	<tr>
		<td class="infoBoxTd">内容：</td>
		<td><asp:TextBox ID="N_Text" runat="server" TextMode="MultiLine"></asp:TextBox></td>
	</tr>
	<tr>
		<td class="infoBoxTd">&nbsp;</td>
		<td>
			<ul class="status">
				<li><span>来源：</span><asp:TextBox ID="N_Source" runat="server" Width="100px" CssClass="formTitle"></asp:TextBox></li>
				<li><span>作者：</span><asp:TextBox ID="N_Author" runat="server" Width="100px" CssClass="formTitle"></asp:TextBox></li>
			</ul>
		</td>
	</tr>
	<tr>
		<td class="infoBoxTd">&nbsp;</td>
		<td>
			<ul class="virtue">
				<li>推荐<asp:CheckBox ID="N_Tj" runat="server" /></li>
				<li>固顶<asp:CheckBox ID="N_Top" runat="server" /></li>
				<li class="sort">排序 <asp:TextBox ID="N_OrderID" runat="server" onkeyup="this.value=this.value.replace(/\D/g,'');" CssClass="inputs"></asp:TextBox></li>
			</ul>
		</td>
	</tr>
	<tr>
		<td class="infoBoxTd">&nbsp;</td>
		<td>
			<asp:Button ID="Button1" runat="server" Text="确定" CssClass="formInput01" />
		</td>
	</tr>
</table>
</div>
</form>
<div id="promptWindow" style="display:none;">
    <div id="crop_container" style="width:500px"></div>
	<div style="background:#fff;padding:8px 0;text-align:center;"><input name="crop" type="button" id="crop" class="formInput03" value="确定" /> <input name="restore" class="formInput04" type="button" id="restore" value="还原" /> <input type="button" class="formInput04" value="关闭" onclick="HideWindow()"/></div>
</div>
<script language="javascript" type="text/javascript">
	<!--    //
	$.validator.methods.equal = function(value, element, param) {
		return value == param;
	};
	
	var UpFolder='<%=UpFolder%>';
	var MaxW,MaxH,M='?'+Math.random();
	MaxW = <%=WebCache.Sys.Read("WebSet")(27)%>;
	MaxH = <%=WebCache.Sys.Read("WebSet")(28)%>;
    function ShowCropZoom()
    {
        var pic=UpFolder+$('#N_PreviewPic').val()+M;
        var Img = new Image();
        Img.onreadystatechange  = function ()
        {
            ShowWindow();
            cropzoom=null;
            var H,W,P,SZ;
            W=MaxW/Img.width==MaxH/Img.height?MaxW:MaxW+100;//如果比率相同
            P=MaxW/W;
            H=MaxH/P;
            SZ=W/Img.width*100;
            var cropzoom = $('#crop_container').cropzoom({
                width:W,height:H,bgColor: '#CCC',enableRotation:true,enableZoom:true,zoomSteps:1,rotationSteps:1,
                selector:{centered:true,borderColor:'blue',borderColorHover:'yellow',startWithOverlay:false,hideOverlayOnDragAndResize:true,
	              showPositionsOnDrag:false,w:MaxW,h:MaxH,maxWidth:MaxW,maxHeight:MaxH
                },
                image:{
                    source:pic,width:Img.width,height:Img.height,minZoom:10,maxZoom:200,startZoom:SZ,snapToContainer:false
                }
            });
            $('#crop').unbind("click").click(function(){ 
                cropzoom.send('ProcessImage.ashx','POST',{'t':'News'},function(rta){
                    if(rta.substring(0,4)=='Err:')
                    {
                        alert(rta.substring(3));HideWindow();
                    }else{
                        $('#CropZoom').val(1);
                        M='?'+Math.random()
                        $('#N_Img').attr('src',UpFolder+rta+M);
                        HideWindow();
                    }
                });
            });
            $('#restore').unbind("click").click(function(){
                cropzoom.restore();
            });
            $('div[id$="_selector"]').unbind("dblclick").dblclick(function(){$('#crop').click();});
        }
        Img.src = pic;
    }
	CreateSelect("CategoryList","N_CategoryID",$('#N_CategoryID').val() ,0,"选择分类",function(){$('#N_CategoryID').valid();},"NewsCategory","../");
	var editor;
	$(function(){
		$('#UpIframe').attr('src','../sys/Upload.aspx?t=news&r='+$('#RanNum').val())
	    $('#N_Text').val(html2ubb($('#N_Text').val()));
        editor = $('#N_Text').xheditor({plugins:{Page:{c:'Page',t:'分页',e:function(){this.pasteHTML('<hr />');}}},tools:'Cut,Copy,Paste,Pastetext,Separator,Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,SelectAll,Removeformat,Separator,Align,List,Outdent,Indent,Separator,Link,Unlink,Img,Flash,Media,Emot,Table,Page,Separator,Source,Print,Fullscreen,About',width:'90%',height:'300',forcePtag:false,internalScript:true,inlineScript:true,linkTag:true,localUrl:'root',showBlocktag:true,beforeSetSource:ubb2html,beforeGetSource:html2ubb,upImgUrl:'Admin_Upload.ashx?r='+$('#RanNum').val(),upFlashUrl:'Admin_Upload.ashx?r='+$('#RanNum').val(),upMediaUrl:'Admin_Upload.ashx?r='+$('#RanNum').val()});
		UpReturn('',$('#N_PreviewPic').val());
		$("#TourExForm").validate({
			rules:{
				N_Title: {required: true},
				N_CategoryID: {min:1},
				N_Url:{required: function(){return $('#N_Text').val()=='';},url:true},
                CropZoom:{equal:1},
				N_Text:{required:function(){return $('#N_Url').val()=='';}},
				N_OrderID:{digits:true}
			},
			messages: {
				N_Title: {required: '请填写标题'},
				N_CategoryID: {min:'请选择类型'},
				N_Url:{required: 'Url跳转和内容必填一项',url:'请填写合法的Url链接'},
                CropZoom:{equal:'请裁剪图片'},
				N_Text: {required: 'Url跳转和内容必填一项'},
        		N_OrderID:{digits:'必须是正整数!'}
			}
		}); 
	});
	function UpReturn(err,msg)
	{
        DelPic();
		if(err!=""){alert(err);return;}
        if(msg==''){return;}
        $('#CropZoom').val('0');
		$("#N_PreviewPic").val(msg);
		$("#Preview").html('<ul class="reviews"><li><img src="'+UpFolder+msg+M+'" width="100" id="N_Img"/><span><a href="javascript:;" onClick="DelPic();">删除</a> | <a href="javascript:;" onclick="ShowCropZoom();">裁剪</a></span></li></ul>');
        var img = new Image();
        img.onreadystatechange = function (){if(MaxW/img.width==MaxH/img.height)$('#CropZoom').val('1');}
        img.src = UpFolder+msg+M;
	}
    function DelPic()
    {
        $('#CropZoom').val('1');
        $("#Preview").html('');
		$("#N_PreviewPic").val('');
    }
	//-->
</script>
</body>
</html>
