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

📄 radwindow.js

📁 Telerik是很大的第三方软件制造商
💻 JS
📖 第 1 页 / 共 3 页
字号:
RadWindow.prototype.GetHeight = function()
{
	var height = 0;
	if (!this.UseRadWindow)
	{
		if (this.Window)
			height = this.Window.dialogHeight;
	}
	else
	{
		if (this.IsIE)
		{
			height = parseInt(this.ContentWrapperTable.clientHeight);
			if (isNaN(height)) height = 0;			
		}
		else
		{
			height = this.ContentWrapperTable.scrollHeight;
		}
	}
	return height;
}

RadWindow.prototype.SetHeight = function(height)
{
	height = parseInt(height);
	if (isNaN(height))
		return;

	if (!this.UseRadWindow)
	{
		if (this.Window)
		{
			if (this.Window.dialogWidth)
			{
				this.Window.dialogTop = this.Window.screenTop - 30;
				this.Window.dialogLeft = this.Window.screenLeft - 4;
				this.Window.dialogHeight = height + "px";
			}
			else
			{
				this.Window.outerHeight = height;
			}
		}
	}
	else
	{
		this.ContentWrapperTable.style.height = height + "px";
		var iframes = this.ContentWrapperTable.getElementsByTagName("IFRAME");
		if (iframes && iframes.length > 0)
		{
			var dlgHeight = (height - 50);
			if (dlgHeight > 0)
			{
				iframes.item(0).style.height = dlgHeight + "px";
			}
		}		
	}
}

RadWindow.prototype.SetSize = function(width, height)
{
	this.SetWidth(width);
	this.SetHeight(height);

	if (width > 0)
		this.Width = width;

	if (height > 0)
		this.Height = height;
}

RadWindow.prototype.SetCaption = function(caption)
{
	if (this.Caption)
	{
		this.Caption.innerHTML = caption;
	}
}

//-------------------------------------MOVEMENT RELATED---------------------------------//
var RadWindowActiveWindow = null; //Points to the active window
var RadWindowActiveWindowSpan = null;
var MousePosX = 0;
var MousePosY = 0;

/* Attach Event Handlers */
function RadWindowDragStart()
{
	if (!RadWindowActiveWindow.CanDrag())
		return;

	if (document.all && document.body.attachEvent)
	{
		document.body.setCapture();
		document.body.attachEvent ("onmousemove", RadWindowDrag);
		document.body.attachEvent ("onmouseup", RadWindowDragEnd);
	}
	else if (document.addEventListener)
	{
		document.addEventListener("mousemove", RadWindowDrag, false);
		document.addEventListener("mouseup", RadWindowDragEnd, false);
	}

	RadWindowInitializeDrag(RadWindowActiveWindow);
}

/*Detach Event Handlers*/
function RadWindowDragEnd()
{
	if (document.all && document.body.detachEvent)
	{
		document.body.detachEvent("onmousemove", RadWindowDrag);
		document.body.detachEvent("onmouseup", RadWindowDragEnd);
		document.body.releaseCapture();
	}
	else if (document.removeEventListener)
	{
		document.removeEventListener("mousemove", RadWindowDrag, false);
		document.removeEventListener("mouseup", RadWindowDragEnd, false);
	}

	if (RadWindowActiveWindow.IsModal)
		RadWindowActiveWindow.SetCapture();

	RadWindowUnInitializeDrag(RadWindowActiveWindow);
	RadWindowActiveWindow.SetContentVisible(true);
}

function RadWindowDrag(e)
{
	if (RadWindowActiveWindow.CanDrag())
	{
		switch (RadWindowActiveWindow.DragMode)
		{
			case "move":
				RadWindowMove(e);
				break;

			case "size":
				RadWindowSize(e);
				break;
		}
	}
	e.cancelBubble = true;
	e.returnValue = false; 
	if (e.preventDefault) e.preventDefault();

	MousePosX = e.clientX;
	MousePosY = e.clientY;

	return false;
}

function RadWindowInitializeDrag(targetWindow)
{
	if (!targetWindow) return;

	if (!RadWindowActiveWindowSpan)
	{
		RadWindowActiveWindowSpan = document.createElement("DIV");		
		RadWindowActiveWindowSpan.className = "RadETableWrapperResizeSpan";		
		RadWindowActiveWindowSpan.style.position = "absolute";
		RadWindowActiveWindowSpan.style.zIndex = 50000;
		document.body.appendChild(RadWindowActiveWindowSpan);
	}

	RadWindowActiveWindowSpan.style.visibility = "visible";
	RadWindowActiveWindowSpan.style.top = targetWindow.ContentWrapperTable.style.top;
	RadWindowActiveWindowSpan.style.left = targetWindow.ContentWrapperTable.style.left;
	RadWindowActiveWindowSpan.style.width = parseInt(targetWindow.GetWidth()) + "px";
	RadWindowActiveWindowSpan.style.height = parseInt(targetWindow.GetHeight()) + "px";

	switch (targetWindow.DragMode)
	{
		case "move":
			RadWindowActiveWindowSpan.style.cursor = "default";
			break;

		case "size":
			RadWindowActiveWindowSpan.style.cursor = "se-resize";
			break;
	}
}

function RadWindowUnInitializeDrag(targetWindow)
{
	if (RadWindowActiveWindowSpan)
		RadWindowActiveWindowSpan.style.visibility = "hidden";

	targetWindow.SetPosition(RadWindowActiveWindowSpan.style.left, RadWindowActiveWindowSpan.style.top);
	targetWindow.SetSize(RadWindowActiveWindowSpan.style.width, RadWindowActiveWindowSpan.style.height);
}

function RadWindowMove(e)
{
	var RadWindowX = RadWindowActiveWindow.X;
	var RadWindowY = RadWindowActiveWindow.Y;

	var el = RadWindowActiveWindowSpan;	//RadWindowActiveWindow.ContentWrapperTable;

	var left = 0;
	var top = 0;

	if (document.all)
	{
		left = e.clientX * 1 + RadGetScrollLeft(document) - RadWindowX;
		top = e.clientY * 1 + RadGetScrollTop(document) - RadWindowY;
	}
	else
	{
		left = e.pageX * 1 - RadWindowX;
		top = e.pageY * 1 - RadWindowY;
	}

	if (left < 0)
	{
		left = 0;
	}

	if (top < 0)
	{
		top = 0;
	}

	el.style.left = left + "px";
	el.style.top = top + "px";
}

var minWidth = 155;
var minHeight = 43;

function RadWindowSize(e)
{
	var offsetX = e.clientX - MousePosX;
	var offsetY = e.clientY - MousePosY;

	var width = parseInt(RadWindowActiveWindowSpan.style.width);
	var height = parseInt(RadWindowActiveWindowSpan.style.height);

	width += offsetX;
	height += offsetY;

	if (width < minWidth)
		width = minWidth;

	if (height < minHeight)
		height = minHeight;

	RadWindowActiveWindowSpan.style.width = width + "px";
	RadWindowActiveWindowSpan.style.height = height + "px";
}


/***********************************************
 *
 *	RadWindowManager
 *
 ***********************************************/
function GetEditorRadWindowManager()
{
	/* SINGLETON */
	var topWindow = GetTopWindow();
	if (!topWindow.radWindowManager)
	{
		topWindow.radWindowManager = new RadWindowManager();
	}
	return topWindow.radWindowManager;
}

function GetTopWindow()
{
	var topWindow = null;

	var argumentsContainParentWindow = false;
	try
	{
		if (window.dialogArguments.parentWindow && argumentsContainParentWindow)
		{
			argumentsContainParentWindow = true;
		}
	}
	catch(ex)
	{
		argumentsContainParentWindow = false;
	}
	if (window.dialogArguments != null && argumentsContainParentWindow)
	{
		topWindow = window.dialogArguments.parentWindow;
	}
	else if (window.opener && !document.all && window.isRadWindow)
	{	// NS
		topWindow = opener;
	}
	else
	{
		topWindow = window;
	}

	var stopLoop = false;
	while (topWindow.parent && !stopLoop)
	{
		try
		{
			topWindowTagName = topWindow.parent.tagName.toUpperCase()
		}
		catch (exception)
		{
			topWindowTagName = "";
		}

		if (topWindow.parent == topWindow)
		{
			break;
		}

		try
		{
			/*This check is needed because of the Access denied error when cross-site scripting*/
			if (topWindow.parent.document.domain != window.document.domain)
			{
				break;
			}
		}
		catch(exc)
		{
			stopLoop = true;
			continue;
		}

		try
		{
			if (topWindow.frameElement != null
				&& (topWindow.frameElement.tagName != "IFRAME"
					|| topWindow.frameElement.name != "RadWindowContent"))
			{
				break;
			}
		}
		catch(exc)
		{
			alert('in the Exception!');
			stopLoop = true;
		}

		topWindow = topWindow.parent;
	}
	return topWindow;
}

function RadWindowManager()
{
	this.ChildWindows = new Array();
	this.ActiveWindow = null;
	this.TopWindowZIndex = 10001;

	this.ContainerPool = new Array();
	this.IsIE = (null != document.all) && (window.opera == null);

	this.OverImage = null;

	document.body.onfocus = Document_OnFocus;

	if (this.IsIE && document.body.attachEvent)
	{
		document.body.attachEvent("onkeydown", Document_OnKeyDown);
	}
	else if (document.body.addEventListener)
	{
		document.body.addEventListener("keydown", Document_OnKeyDown, false);
	}

	if (this.IsIE && !this.OverImage)
	{
		this.OverImage = document.getElementById("OVER_IMG");
	}
}

function Document_OnFocus(e)
{
	if (!e)
	{
		e = window.event;
	}
	GetEditorRadWindowManager().ActivateWindow();
}

function Document_OnKeyDown(e)
{
	if (!e)
	{
		e = window.event;
	}
	return GetEditorRadWindowManager().OnKeyDown(e);
}

function RadWindowInfo()
{
	this.IsIE = (null != document.all);
	this.ID = null;
	this.Url = "";
	this.InnerHtml = "";
	this.InnerObject = null;
	this.Width = 300;
	this.Height = 200;
	this.Caption = "";
	this.IsVisible = true;
	this.Argument = null;
	this.CallbackFunc = null;
	this.OnLoadFunc = null;
	this.Param = null; // callback func param
	this.Resizable = true;
	this.Movable = true;
	this.CloseHide = false; // true - close X hides the window; otherwise close it
	this.UseClassicDialogs = true;
	this.BlankIFrameLocation = "";
}

RadWindowManager.prototype.ShowModalWindow = function(radWindowInfo)
{
	var wnd = this.CreateWindow(true, radWindowInfo);
	return wnd;
}

RadWindowManager.prototype.ShowModallessWindow = function(radWindowInfo)
{
	var wnd = this.CreateWindow(false, radWindowInfo);
	return wnd;
}

/////////////////////////////////////////////////
// WINDOWS OPERATIONS
RadWindowManager.prototype.CreateWindow = function(bIsModal, radWindowInfo)
{
	if (!radWindowInfo)
		return null;

	/********* THIS CODE MAKES MOZILLA USE REGULAR WINDOWS INSTEAD OF RAD WINDOW *********/
	/*
	radWindowInfo.UseClassicDialogs = (this.IsIE && radWindowInfo.UseClassicDialogs)
										|| (!this.IsIE && ((null != radWindowInfo.Url && "" != radWindowInfo.Url)
														|| (null != radWindowInfo.InnerHtml && "" != radWindowInfo.InnerHtml && radWindowInfo.UseClassicDialogs)));
	*/

	var id = "";
	if (!radWindowInfo.ID || radWindowInfo.ID == "")
	{
		id = this.ChildWindows.length;
	}
	else
	{
		id = radWindowInfo.ID;
	}

	var caption = "";
	if (null == radWindowInfo.Caption)
	{
		caption = "[" + id + "]";
	}
	else
	{
		caption = radWindowInfo.Caption;
	}

	var radWindow = this.GetWindow(id);

	radWindow.Argument = radWindowInfo.Argument;
	radWindow.Width = radWindowInfo.Width;
	radWindow.Height = radWindowInfo.Height;
	radWindow.CallbackFunc = radWindowInfo.CallbackFunc;
	radWindow.Param = radWindowInfo.Param;
	radWindow.CanResize = radWindowInfo.Resizable;
	radWindow.CanMove = radWindowInfo.Movable;
	radWindow.OnLoadFunc = radWindowInfo.OnLoadFunc;
	radWindow.UseRadWindow = !radWindowInfo.UseClassicDialogs;

⌨️ 快捷键说明

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