⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forumtreeviewcontrol.ascx

📁 community server 源码
💻 ASCX
📖 第 1 页 / 共 2 页
字号:
<%@ Control Language="c#" AutoEventWireup="false" enableviewstate="false" Codebehind="ForumTreeViewControl.ascx.cs" Inherits="CommunityServer.ControlPanel.Forums.ForumTreeViewControl" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<%@ Register TagPrefix="CS" Namespace="CommunityServer.Controls" Assembly="CommunityServer.Controls" %>
<%@ Register TagPrefix="CP" Namespace="CommunityServer.ControlPanel.Controls" Assembly="CommunityServer.Web" %>
<%@ Register TagPrefix="CA" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %>
<%@ Import Namespace="CommunityServer.Components" %>
<script language="javascript">
<!--
var nodeMoved = null;
var nodeNeedsResorted = false;
var newNodeSeq = 0;
var newNodeGroupID = 0;

// Splits the node's value and returns the GroupID part
function getGroupID(node)
{
	splits = node.GetProperty('Value').split(":");
	return splits[0];
}

// Splits the node's value and returns the SectionID part
function getSectionID(node)
{
	splits = node.GetProperty('Value').split(":");
	return splits[1];
}

// Splits the PARENT node's value and returns the SectionID part
function getParentSectionID(node)
{
	splits = node.ParentNode.Value.split(":");
	return splits[1];
}

function treeContextMenu(treeNode, e)
{
	groupID = getGroupID(treeNode);
	sectionID = getSectionID(treeNode);
	
	// Determine whether to call Group or Section context menu
	if (sectionID > 0)
	{
		if(treeNode.Checked == 1) //used for enabled
			window.<%=this.SectionContextMenu.ClientID%>.ShowContextMenu(treeNode, e, groupID, sectionID);
		else
			window.<%=this.SectionDisabledContextMenu.ClientID%>.ShowContextMenu(treeNode, e, groupID, sectionID);
	}
	else
		window.<%=this.GroupContextMenu.ClientID%>.ShowContextMenu(treeNode, e, groupID, sectionID);
		
	return true;
}

function nodeSelect(node)
{
	if (getSectionID(node) < 0)
	{
		window.frames["sectionEditFrame"].location.href = "IFrameHost.aspx?SectionID=0&GroupID=" + getGroupID(node);
	}
	else
	{
		window.frames["sectionEditFrame"].location.href = "IFrameHost.aspx?SectionID=" + getSectionID(node) + "&GroupID=" + getGroupID(node);
	}
	node.Expand();
	node.ParentTreeView.Render();
}

function checkNodeIndex(node)
{
	if (nodeNeedsResorted == true && nodeMoved != null)
	{
		nodeNeedsResorted = false;
		index = nodeMoved.GetCurrentIndex();
		groupID = getGroupID(nodeMoved);
		sectionID = getSectionID(nodeMoved);
		nodeMoved = null;
		
		ReorderForumOrGroup(groupID, sectionID, index);
	}
}

function updateGroupNode(groupID, newName)
{
	var updateNode = window.<%=this.Tree.ClientObjectId%>.FindNodeById(groupID + ":-1");
	if(updateNode == null)
		window.location = window.location;
		
	updateNode.SetProperty('Text',newName);
	window.<%=this.Tree.ClientObjectId%>.Render();
}

function updateSectionNode(groupID, sectionID, newName, isActive)
{
	var updateNode = window.<%=this.Tree.ClientObjectId%>.FindNodeById(groupID + ":" + sectionID);
	if(updateNode == null)
		window.location = window.location;
	
	if(isActive == 'True') //used for enabled
	{
		updateNode.SetProperty('ImageUrl', "notes.gif");
		updateNode.SetProperty('Checked', 1);
	}
	else
	{
		updateNode.SetProperty('ImageUrl', "notesdisabled.gif");
		updateNode.SetProperty('Checked', null);
	}
	
	updateNode.SetProperty('Text',newName);
	window.<%=this.Tree.ClientObjectId%>.Render();
}



//## MOVE / REORDER ##

//## MOVE ##
function nodeMove(sourceNode, targetNode)
{
	nodeMoved = sourceNode;
	nodeNeedsResorted = false;

	sourceSectionID = getSectionID(sourceNode);
	sourceGroupID = getGroupID(sourceNode);
	targetGroupID = getGroupID(targetNode);
	targetSectionID = getSectionID(targetNode);
	if (sourceNode.ParentNode != null)
		parentSectionID = getParentSectionID(sourceNode);
	else
		parentSectionID = -1;
		
	// alert(sourceGroupID + ':' + sourceSectionID + ':' + targetGroupID + ':' + targetSectionID);
	
	// Check if user is trying to drop a group inside a group or forum
	if (sourceSectionID < 0)
	{
		if (targetGroupID > 0)
		{
			//dragging a group into a group or section
			alert("<%= CommunityServer.ControlPanel.Components.ResourceManager.GetString("CP_Forums_TreeView_NoDropGroup") %>");
			return false;
		}
		nodeNeedsResorted = true;
	}


	// Determine if the user moved the Forum to another group and/or parent forum...
	//	or if this move was just a change in sort order in the same group & parent forum
	var isReSort = false;
	if (sourceGroupID == targetGroupID)
	{
		if (parentSectionID > 0)
		{
			if (parentSectionID == targetSectionID)
			{
				// This is just a change in sort order. We can't do anything until we know
				//	the new index that the node was dropped in. So let client-side function know this...
				isReSort = true;
			}
		}
		else
		{
			if (targetSectionID < 0)
			{
				// This is just a change in sort order. We can't do anything until we know
				//	the new index that the node was dropped in. So let client-side function know this...
				isReSort = true;
			}
		}
	}

	if (isReSort)
	{
		nodeNeedsResorted = true;
	}
	else
	{
		if (sourceSectionID > 0)
		{
			if (targetNode == null || targetNode.ID == "RootNode")
			{
				alert('<%= CommunityServer.ControlPanel.Components.ResourceManager.GetString("CP_Forums_TreeView_NodeMoveError") %>');
				return false;
			}

			window.frames["sectionEditFrame"].location.href = "<%= SiteUrls.Instance().ControlPanelLoading(CommunityServer.ControlPanel.Components.ResourceManager.GetString("CP_Forums_TreeView_MoveNodeWait")) %>";
			MoveSection(sourceGroupID, sourceSectionID, targetGroupID, targetSectionID);
		}
	}
	
	return true; 
}

function MoveSection(groupID ,sectionID, targetGroupID, targetSectionID)
{
	ForumTreeViewControl.MoveForum('<%= this.ClientID %>',groupID ,sectionID, targetGroupID, targetSectionID, MoveSectionCallBack);
}

function MoveSectionCallBack(res)
{
	window.frames["sectionEditFrame"].location.href = "<%= SiteUrls.Instance().BlankPage %>";

	if (res == null)
		return;

	// Check if this was now alloed
	if (res.value == "0")
	{
		//dragging a group into a group or section
		alert("<%= CommunityServer.ControlPanel.Components.ResourceManager.GetString("CP_Forums_TreeView_NoMoveSpecialForum") %>");
		return false;
	}
	else
	{
		var retVals = res.value.split("^");
		var groupID = retVals[0];
		var newGroupID = retVals[1];
		var sectionID = retVals[2];
		var newSectionID = retVals[3];
		
		nodeMoved = window.<%=this.Tree.ClientObjectId%>.FindNodeById(groupID + ":" + sectionID);
		nodeMoved.SetProperty('Value', newGroupID + ":" + sectionID);
		nodeMoved.SetProperty('ID', newGroupID + ":" + sectionID);
		window.<%=this.Tree.ClientObjectId%>.Render();
		
		var selectedNode = window.<%=this.Tree.ClientObjectId%>.SelectedNode;
		if (selectedNode != null && getSectionID(selectedNode) == sectionID)
		{
			nodeSelect(nodeMoved);
		}
	}
}
//## END MOVE ##

//## REORDER ##
function ReorderForumOrGroup(groupID, sectionID, index)
{
	window.frames["sectionEditFrame"].location.href = "<%= SiteUrls.Instance().ControlPanelLoading(CommunityServer.ControlPanel.Components.ResourceManager.GetString("CP_Forums_TreeView_MoveNodeWait")) %>";
	ForumTreeViewControl.ReorderForumOrGroup('<%= this.ClientID %>', groupID, sectionID, index, ReOrderCallBack);
}
function ReOrderCallBack(res)
{
	window.frames["sectionEditFrame"].location.href = "<%= SiteUrls.Instance().BlankPage %>";
}
//## END REORDER ##

//## END MOVE / REORDER ##


//## RENAME ##
function nodeRename(sourceNode, newName)
{ 
	newName = newName.replace(/^\s*|\s*$/g,"");
	if(newName.length == 0)
	{
		alert('<%= CommunityServer.ControlPanel.Components.ResourceManager.GetString("CP_Forums_TreeView_BlankGroupName") %>');
		return false;
	}

	window.<%=this.Tree.ClientObjectId%>.SelectedNode.SetProperty('Text', newName);
	
	// Determine whether this is a new node (doesn't exist server-side yet) or an existing one
	var groupID = getGroupID(sourceNode);
	var sectionID = getSectionID(sourceNode);
	var parentSectionID = getParentSectionID(sourceNode);
	
	if (sectionID > 0)
	{
		window.location = window.location;
	}
	if (sectionID == 0)
	{
		window.<%=this.Tree.ClientObjectId%>.Render();
		window.frames["sectionEditFrame"].location.href = "<%= SiteUrls.Instance().ControlPanelLoading(CommunityServer.ControlPanel.Components.ResourceManager.GetString("CP_Forums_TreeView_AddSectionWait")) %>";
		ForumTreeViewControl.AddSection('<%= this.ClientID %>', groupID, parentSectionID, newName, AddSectionCallBack);
		return false;
	}
	if (groupID > 0)
	{
		// Existing Node - just rename
		RenameGroup(groupID, newName);
	}
	return true; 
}

function RenameGroup(groupID, newName)
{
	ForumTreeViewControl.RenameGroup('<%= this.ClientID %>', groupID, newName, RenameGroupCallBack);
}

function RenameGroupCallBack(res)
{
	if (res == null)
		window.location = window.location;

	// Reload group edit control
	groupID = res.value;
	if (groupID > 0)
	{
		window.frames["sectionEditFrame"].location.href = "IFrameHost.aspx?SectionID=0&GroupID=" + groupID;
	}
	else
	{
		alert('<%= CommunityServer.ControlPanel.Components.ResourceManager.GetString("CP_Forums_TreeView_DuplicateGroupName") %>');
		window.location = window.location;
	}
}

//## END RENAME ##


//## ADD ##

//## ADD GROUP ##
function AddGroup()
{
	toggleButtons();
	window.frames["sectionEditFrame"].location.href = "<%= SiteUrls.Instance().ControlPanelLoading(CommunityServer.ControlPanel.Components.ResourceManager.GetString("CP_Forums_TreeView_AddGroupWait")) %>";
	ForumTreeViewControl.AddGroup('<%= this.ClientID %>', AddGroupCallBack);
}
       
function AddGroupCallBack(res)
{
	if (res == null)
		window.location = window.location;

	var retVals = res.value.split("^");
	var groupID = retVals[0];
	var groupName = retVals[1];

	if (groupID == '-1')
	{
		alert('<%= CommunityServer.ControlPanel.Components.ResourceManager.GetString("CP_Forums_TreeView_DuplicateGroupName") %>');
		window.frames["sectionEditFrame"].location.href = "<%= SiteUrls.Instance().BlankPage %>";
	}
	else
	{
		AddGroupNode(groupID, groupName)
		window.frames["sectionEditFrame"].location.href = "IFrameHost.aspx?SectionID=0&GroupID=" + groupID;
	}
	toggleButtons();
	return;
}

function AddGroupNode(groupID, groupName)
{
	window.<%=this.Tree.ClientObjectId%>.SelectedNode = null;
	var newGroupNode = new ComponentArt_TreeViewNode();

	newGroupNode.SetProperty('Text', groupName);
	newGroupNode.SetProperty('ImageUrl', "folders.gif");
	newGroupNode.SetProperty('EditingEnabled', true);
	newGroupNode.SetProperty('DraggingEnabled', true);
	newGroupNode.SetProperty('DroppingEnabled', true);
	newGroupNode.SetProperty('ClientSideOnNodeSelect', "nodeSelect");
	newGroupNode.SetProperty('Selectable', true);
	newGroupNode.SetProperty('Value', groupID + ":-1");
	newGroupNode.SetProperty('ID', groupID + ":-1");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -