<%@ Page CodeBehind="allfolder.aspx.cs" Language="c#" AutoEventWireup="True" Inherits="Webdisk.allfolder" %>
<% @ Import Namespace="Webdisk" %>
<%@ Import Namespace="Global" %>
        <link href="<%=xml.GetStyle()%>" type="text/css" rel="Stylesheet"/>
			
			<style type="text/css">.STYLE1 { COLOR: #0000ff }
	</style>
		<form id="Form1" method="post" runat="server">
			<div class="menuBlock">
				<div class="menuHead" style="overflow:hidden;border-bottom: 1px dashed #cfcfcf;">
				<a id="but" class="floatR" onclick="getSearch();" href="javascript:void(0);">↓高级查找↓</a>
				<h2 style="font-size: 18px;color: #1EA7DF;"><img src="pics/menu_file_cut.gif" align="absMiddle"> 共享给我的目录</h2>
				</div>
				<div id="search" class="clear search-con" style="DISPLAY: none;">
				<table class="form-table">
					<tr>
						<td class="label">
							目录名：
						</td>
						<td colspan="3"><input class="input3 " id=key   name=key> （可模糊输入，不填为不限）
						<input class="but1 floatR" id="submit2" type="button" value=" 查 找 " name="submit22"></td>
						</tr>
						<tr>
						<td class="label">用户名：
						</td><td  colspan="3">
						<input class=input3 id=user  name=user> （精确输入，不填为不限）</td>
						</tr>
						<tr>
							<td  class="label">目录注释：
							</td>
							<td colspan="3"><input class=input3 id=txtnote name=txtnote>（不填为不限）</td>
							</tr>
							<tr>
								<td class="label">所属学校：
								</td><td>
								<select name="school" id="school" class="input4" runat="server">
									<option value="" selected>全部学校</option>
								</select></td><td class="label">所属部门：</td>
								<td>
									<select name="dept" id="dept" class="input4" runat="server" style="width:180px;">
										<option value="" selected>全部部门</option>
									</select>
								</td>
							</tr>
						</table>
					</div>
				<div class="clear" style="margin:10px;">
					<div class="mListT">    
						<span class="l5"><a id="dirname" data-sort = "desc" data-type="dirname" href="javascript:void(0);" >目录名
						<img class="sortImg" src="images/up01.gif"  style="display:none"/></a>
						</span>
						<span class="l5">
						<a id="username" data-sort="desc" data-type="username" href="javascript:void(0);">所属用户
						<img class="sortImg" src="images/up01.gif" style="display:none"/></a>
						</span>
						<span class="l6">
						<a id="lasttime" data-sort="asc" data-type="lasttime" href="javascript:void(0);">更新时间
						<img class="sortImg" src="images/down01.gif"/></a>
						</span>
					</div>
					<div id="content" style="">
					</div>
					<input id="type" type="hidden" runat="server" value="lasttime"/>
					<input id="asc" type="hidden" runat="server" value="desc"/>
					<div class="pageList" id="page"> 
				    </div>	
			    </div>
            <INPUT type="hidden" name="hidschool" id="hidschool" runat="server">
			<INPUT type="hidden" name="hiddept" id="hiddept" runat="server">
		</form>
<script type="text/javascript">
var FolderShare = {};
FolderShare.iframeDialog = null;
FolderShare.init = function(){
	this.addEvent();
	this.page();
}
FolderShare.addEvent = function(){
	var that = this ;
	//排序
	$("#dirname").click(function(){
		var tag = $(this);
		var sort = tag.data("sort");
		tag.data("sort",sort == "asc" ? "desc" : "asc");
		$("#asc").val(sort);
		$("#type").val(tag.data("type"));
		$(".sortImg").hide();
		tag.find(".sortImg").show().attr("src",sort == "asc" ? "images/up01.gif":"images/down01.gif");
		that.page();
	});
	$("#username").click(function(){
		var tag = $(this);
		var sort = tag.data("sort");
		tag.data("sort",sort == "asc" ? "desc" : "asc");
		$("#asc").val(sort);
		$("#type").val(tag.data("type"))
		$(".sortImg").hide();
		tag.find(".sortImg").show().attr("src",sort == "asc" ? "images/up01.gif":"images/down01.gif");
		that.page();
	});
	$("#lasttime").click(function(){
		var tag = $(this);
		var sort = tag.data("sort");
		tag.data("sort",sort == "asc" ? "desc" : "asc");
		$("#asc").val(sort);
		$("#type").val(tag.data("type"));
		$(".sortImg").hide();
		tag.find(".sortImg").show().attr("src",sort == "asc" ? "images/up01.gif":"images/down01.gif");
		that.page();
	});
	//级联学校
	$("#school").change(function () {
		var school = $("#school").val();
		$.ajax({
			type: "post",
			url: "FileSpaceHandler.ashx?cmd=getClassBySchoolId",
			data:{ "schoolId" :school},
			cache:false,
			error: function () { alert("服务器异常！") },
			dataType : "json",
			success: function (data) {
				var _dept = $("#dept").empty()[0] ;
				_dept.options[0] = new Option("全部部门",0);
				for(var index = 0 ;index<data.length ; index ++ ){
					_dept.options[index +1 ] = new Option(data[index].kname,data[index].id)
				}
			}
		});
	});
	$("#submit2").click(function(){
		that.search();
	});
}
FolderShare.addListEvent = function(){
	var that = this ;
	$(".showUser").click(function(){
		that.dialogShow($(this).data("href"),"查看用户信息");
	});
	$(".getDir").click(function(){
		getHtml('ContentPane.aspx?filepath='+$(this).data("href"));
	});
}
FolderShare.page = function (currentPage) {
	var that = this ;
	currentPage = currentPage ? currentPage : 0;
	var type = "", asc = "";
	type = $("#type").val();
	asc = $("#asc").val();
	
	
	function ajax(page, callback) {
		//var d = dialog();
		$.ajax({
			url: "allfolderList.aspx",
			data: { pageindex: page , type: type, asc: asc },
			cache: false,
			beforeSend: function () {
				//d.showModal();
			},
			success: function (data) {
				//d.close().remove();
				$("#content").empty().append(data);
				that.addListEvent();
				typeof callback == "function" && callback(data);
			}
		});
	}
	ajax(currentPage, function (data) {
		var maxlength = parseInt($("#H_itemtCount").val());
		$("#page").pagination(maxlength, {
			prev_text: '< 上一页',
			next_text: '下一页 >',
			items_per_page: parseInt($("#H_pageSize").val()),
			num_display_entries: <%=Session["username"] == null ? 10 : Convert.ToInt32(Common.GetListCount(Session["username"].ToString())) %>,
			current_page: 0,
			num_edge_entries: 2,
			link_to: "javascript:void(0);",
			callback: function (page_id, panel) {
				var self = this;
				ajax(page_id, function (vdata) {
					self.maxentries = parseInt($("#H_itemtCount").val());
				});
			}
		});
	})
}
FolderShare.dialogShow = function(href,title){
	var that = this ;
	var d = this.iframeDialog = dialog({
		content: "<iframe src='" +href + "' style='border:none;width:500px;height:350px;'></iframe>",
		title: title
	});
	d.showModal();
}
/***
**刷新窗口 
***/
FolderShare.refreshDialog = function(href ,title){
	this.iframeDialog.content( "<iframe src='" +href + "' style='border:none;width:500px;height:350px;'></iframe>");
	this.iframeDialog.title(title );
}
/**
*关闭模态窗口
*/
FolderShare.closeWindow = function(flag){
	if(this.iframeDialog){
		this.iframeDialog.close().remove();
		this.iframeDialog = null ;
	}
}
FolderShare.search = function (currentPage) {
	var that = this ;
	currentPage = currentPage ? currentPage : 0;
	var key, type, asc, txtnote, company, dept, user;
	key = $("#key").val();
	user = $("#user").val();
	type = $("#type").val();
	asc = $("#asc").val();
	txtnote = $("#txtnote").val();
	company = $("#school").val();
	dept = $("#dept").val();
	var d = dialog();
	function ajax(page, callback) {
		$.ajax({
			url: "allFolderList.aspx",
			data: { pageindex: page, key: key, user: user, type: type, txtnote: txtnote, company: company, dept: dept, asc: asc },
			cache: false,
			beforeSend: function () {
				d.showModal();
			},
			success: function (data) {
				d.close().remove();
				$("#content").empty().append(data);
				that.addListEvent();
				typeof callback == "function" && callback(data);
			}
		});
	}
	ajax(currentPage, function (data) {
		var maxlength = parseInt($("#H_itemtCount").val());
		$("#page").pagination(maxlength, {
			prev_text: '< 上一页',
			next_text: '下一页 >',
			items_per_page: parseInt($("#H_pageSize").val()),
			num_display_entries: <%=Session["username"] == null ? 10 : Convert.ToInt32(Common.GetListCount(Session["username"].ToString())) %>,
			current_page: 0,
			num_edge_entries: 2,
			link_to: "javascript:void(0);",
			callback: function (page_id, panel) {
				var self = this;
				ajax(page_id, function (vdata) {
					self.maxentries = parseInt($("#H_itemtCount").val());
				});
			}
		});
	});
}
FolderShare.init();
  
var refreshWindow = function(href,title){
	FolderShare.refreshDialog(href ,title);
}
var closeWindow = function(flag){
	FolderShare.closeWindow(flag);
}
function getSearch(){
	var tag = $('#search');
	var bTag = $("#but");
	if(bTag.text() == "↓高级查找↓"){
		bTag.text("↑高级查找↑");
		tag.slideDown(500);
	}else{
		bTag.text("↓高级查找↓");
		tag.slideUp(500);
	}
}
			</script>
