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

📄 webhtmleditorwindows.js.txt.exclude

📁 小孔子全站管理系统网站内容管理。相当于一个文章发布系统一个样
💻 EXCLUDE
📖 第 1 页 / 共 3 页
字号:

function WebHtmlEditorWindow(id)
{
	this.IsIE = (null != document.all) && (window.opera == null);	
	this.Id = id;
	this.Width = 0;
	this.Height = 0;  
	this.OnClientClose = null;
	this.ContentWindow = null;
	this.ContentTD = null;
	this.ContentWrapperTable = null;
	this.Caption = null;
	this.X = 0;
	this.Y = 0;
	this.ShowContentWhenMoving = true;
	this.borderWidth = 0;	
	this.CanMove = true;
	this.CanResize = true;	
	this.DragMode = "";
	this.IsModal = false;
	this.Container = null;
	this.Parent = null;
	this.Argument = null;
	this.ReturnValue = null;
	this.ExitCode = null;
	this.ZIndex = 0;
	this.AdjustPosInterval = -1;
	this.CallbackFunc = null;
	this.OnLoadFunc = null;
	this.Param = null;	
	this.ModalSetCapture = false;	
	this.UseWebHtmlEditorWindow = true;
	this.Window = null;
	this.InnerHTML = null;
}

WebHtmlEditorWindow.prototype.OnLoad = function()
{
	if (this.Window && "" != this.Window.document.title)
	{
		this.SetCaption(this.Window.document.title);
	}

	if (this.OnLoadFunc)
	{
		this.OnLoadFunc();
	}
}

WebHtmlEditorWindow.prototype.SetCapture = function(bContainerCapture)
{
	if (this.UseWebHtmlEditorWindow)
	{
		if (null != bContainerCapture)
		{
			this.bContainerCapture = bContainerCapture;
		}
		else if (null != this.bContainerCapture)
		{
			bContainerCapture = this.bContainerCapture;
		}
		else
		{
			bContainerCapture = false;
		}

		if (this.ModalSetCapture && this.IsIE)
		{
			this.ContentWrapperTable.setCapture(bContainerCapture);
		}
	}	
}

WebHtmlEditorWindow.prototype.ReleaseCapture = function()
{
	if (this.UseWebHtmlEditorWindow)
	{
		if (this.ModalSetCapture && this.IsIE)
		{
			if (this.ContentWrapperTable)
				this.ContentWrapperTable.releaseCapture();
		}
	}
}

WebHtmlEditorWindow.prototype.SetZIndex = function(zIndex)
{
	this.ZIndex = zIndex;
	if (this.ContentWrapperTable)
	{
		this.ContentWrapperTable.style.zIndex = this.ZIndex;
	}
}

WebHtmlEditorWindow.prototype.ToggleContent = function()
{
	return;	
	if (this.UseWebHtmlEditorWindow && this.IsIE)
	{	
		var displayStyle = "";	
		if (parseInt(this.Height) == parseInt(this.ContentWrapperTable.style["height"]))
		{
			this.SetHeight(0);
			displayStyle = "none";
		}
		else
		{
			this.SetHeight(this.Height);
			displayStyle = "inline";
		}
		
		this.ContentWindow.style.display = displayStyle;
	}
}

WebHtmlEditorWindow.prototype.IsVisible = function()
{
	if (this.ContentWrapperTable)
	{
		return this.ContentWrapperTable.style.display == "block";
	}	
	return false;
}

WebHtmlEditorWindow.prototype.ShowWindow = function(show, x, y)
{
	if (null == show)
	{
		show = true;
	}	
	var displayStyle = show ? "block" : "none";
	
	if (this.ContentWrapperTable)
	{
		this.ContentWrapperTable.style.display = displayStyle;
	}	
	
	if (null != this.ContentWindow && show)
	{
		this.ContentWindow.style.display = displayStyle;
		if (null != x && null != y)
		{
			x += 10;
			if (this.ContentWrapperTable)
			{
				this.ContentWrapperTable.style.left = x + 'px';
				this.ContentWrapperTable.style.top = y + 'px';		
			}
		}								
		for (var i = 0; i < this.ContentWindow.childNodes.length; i++)
		{			
			try
			{
				this.ContentWindow.childNodes[i].style.display = displayStyle;												
			}
			catch (ex)
			{			
			}
		}
	}
	if (this.Parent)
	{
		this.Parent.OnShowWindow(this, show);
	}
}

WebHtmlEditorWindow.prototype.Init =  function(contentElem, show, containerElem, modal, zIndex)
{
	this.Initialize(contentElem, show);	
	this.IsModal = modal;
	this.Container = containerElem;	
	this.SetZIndex(zIndex);
}

WebHtmlEditorWindow.prototype.Initialize =  function(contentElem, show)
{
	if (this.Id) 
	{
		var editorId = "WebHtmlEditor";
		this.ContentWrapperTable = document.getElementById(editorId + "WindowContentWrapper" + this.Id);	 
		this.ContentWindow = document.getElementById(editorId + "WindowContentWindow" + this.Id);	 
		this.ContentTD = document.getElementById(editorId + "WindowContentTD" + this.Id);
		this.Caption = document.getElementById(editorId + "WindowCaption" + this.Id);
		this.borderWidth = this.GetTableBorder(this.ContentWrapperTable);
		if (contentElem) 
		{
			this.SetContentElement(contentElem);	 	 	 	 	 
		}
		
		if (null == show)
		{
			var show = true;
		}
		
		this.ShowWindow(show);
	}
	else 
	{
		alert ("No window Id provided");
	}
};

WebHtmlEditorWindow.prototype.SetContentElement = function (contentElem)
{
	var parentNode = contentElem.parentNode;
	if (parentNode) 
	{
		parentNode.removeChild(contentElem);		
	}
	while (this.ContentWindow && this.ContentWindow.childNodes.length > 0)
	{
		this.ContentWindow.removeChild(this.ContentWindow.childNodes.item(0));		
	}
	
	if (this.ContentWindow)
	{
		this.ContentWindow.appendChild(contentElem);
		this.SetContentWindowSize(contentElem.style.width, null);	
	}
}

WebHtmlEditorWindow.prototype.SetContentWindowSize = function (width, height)
{
	this.Width = width;	
	this.Height = height;
	
	if (!document.all)
	{	    
		if (this.ContentWrapperTable)
		{
			this.ContentWrapperTable.getElementsByTagName("TABLE").item(0).style.width = width + "px";	  
		}
	}	
};

WebHtmlEditorWindow.prototype.SetContentVisible = function (visible)
{
	if (this.ContentWindow)
	{
	    this.ContentWindow.style.visibility = visible ? "visible" : "hidden";
	}
};

WebHtmlEditorWindow.prototype.Close =  function(exitCode)
{	
	if (null != this.OnClientClosing && (this.OnClientClosing(exitCode) == false))
	{
		return;
	}

	this.ShowWindow(false);	
		
	this.ExitCode = exitCode;
	
	if (this.AdjustPosInterval > -1)
	{
		window.clearInterval(this.AdjustPosInterval);
		this.AdjustPosInterval = -1;
	}	
	if (this.IsModal)this.ReleaseCapture();			
	try
	{
		if (this.CallbackFunc)this.CallbackFunc(this.ReturnValue, this.Param);
	}
	catch (ex){}
	
	if (this.Parent)this.Parent.DestroyWindow(this);
		
	if (!this.UseWebHtmlEditorWindow && this.Window)this.Window.close();
};
			
WebHtmlEditorWindow.prototype.ToggleCanMove =  function(oDiv)
{
	if (!this.UseWebHtmlEditorWindow)return;
	
	this.CanMove = !this.CanMove;
	
	oDiv.className = this.CanMove ? "WHEWindowButtonPinOff" : "WHEWindowButtonPinOn";
	
	if (!this.CanMove)
	{
		if (this.IsIE)
		{
			this.TopOffset = parseInt(this.ContentWrapperTable.style.top) - GetScrollTop(document);
			this.StartUpdatePosTimer(100);
		}
		else
		{		
			this.ContentWrapperTable.style.position = "fixed";			
		}
	}
	else
	{
		if (this.IsIE)
		{
			window.clearInterval(this.AdjustPosInterval);		
			this.TopOffset = null;
		}
		else
		{
			this.ContentWrapperTable.style.position = "absolute";
		}
	}
}

WebHtmlEditorWindow.prototype.StartUpdatePosTimer = function(iInterval)
{
	if (!this.UseWebHtmlEditorWindow)return;		
	this.AdjustPosInterval = window.setInterval("UpdateWindowPos('" + this.Id + "')", iInterval);
}

function UpdateWindowPos(wndId)
{
	var wnd = GetWebHtmlEditorWindowManager().LookupWindow(wndId);
	if (wnd)wnd.SetPosition();
}

WebHtmlEditorWindow.prototype.CanDrag = function()
{
	if (!this.UseWebHtmlEditorWindow)return true;		
	return ("move" == this.DragMode && this.CanMove)|| ("size" == this.DragMode && this.CanResize);
}

WebHtmlEditorWindow.prototype.OnMouseOver = function(e)
{	
	switch (e.srcElement.id)
	{
		case "BorderBottom":
			break;			
		case "CornerBottomRight":
			e.srcElement.style.cursor = "se-resize";			
			break;			
		default:
			return;
	}
}

WebHtmlEditorWindow.prototype.OnMouseOut = function(e)
{	
	switch (e.srcElement.id)
	{
		case "BorderBottom":
			break;			
		case "CornerBottomRight":
			e.srcElement.className="WHETableWrapperFooterRight";
			break;			
		default:
			return;
	}
}

WebHtmlEditorWindow.prototype.OnDragStart = function(e)
{   
	this.SetActive(true);	
	if (!this.CanDrag())return;	
	this.X = (e.offsetX == null) ? e.layerX : e.offsetX;
	this.Y = (e.offsetY == null) ? e.layerY : e.offsetY;	
	MousePosX = e.clientX;
	MousePosY = e.clientY;	
	this.SetContentVisible(this.ShowContentWhenMoving);
	WebHtmlEditorWindowDragStart();
};

WebHtmlEditorWindow.prototype.SetActive = function(activate)
{		
	if (!this.UseWebHtmlEditorWindow)return;
			
	if (activate)
	{
		if (null != State_ActiveWindow && State_ActiveWindow != this)State_ActiveWindow.SetActive(false);	
		State_ActiveWindow = this;		
		if (this.Parent)this.Parent.ActivateWindow(this);
	}
	else
	{
		if (this == State_ActiveWindow)	State_ActiveWindow = null;
	}
}

WebHtmlEditorWindow.prototype.HitTest = function(x, y)
{
	var left = parseInt(this.ContentWrapperTable.style.left);
	if (isNaN(left))return false;
		
	var top = parseInt(this.ContentWrapperTable.style.top);
	if (isNaN(top))	return false;		
	return	left <= x && x <= (left + this.Width) && top <= y && y <= (top + this.Height);
}

WebHtmlEditorWindow.prototype.SetPosition = function(left, top)
{
	if (!this.UseWebHtmlEditorWindow)
	{
		if (this.Window)
		{
			this.Window.dialogLeft = left;
			this.Window.dialogTop = top;
		}
	}
	else
	{
		if (!left)left = this.ContentWrapperTable.style.left;			
		if (!top)
		{
			if (this.TopOffset != null)	top = parseInt(this.TopOffset) + GetScrollTop(document);
			else top = this.ContentWrapperTable.style.top;
		}			
		left = parseInt(left);
		top = parseInt(top);		
		if (!isNaN(left) && !isNaN(top))
		{		
			if (left <= 0)left = 0;			
			if (top <= 0)top = 0;			
			this.ContentWrapperTable.style.left = left + 'px';
			this.ContentWrapperTable.style.top = top + 'px';
		}
	}
}

WebHtmlEditorWindow.prototype.GetTableBorder = function(table)
{
	var borderWidth = 0;	
	if (null != table)
	{
		var strBorderWidth = table.style.borderWidth;
		borderWidth = parseInt(strBorderWidth);
		if (isNaN(borderWidth))
		{		
			borderWidth = 0;		
			if ("" != table.className)
			{
				var rule = this.GetCssClass(table.className);
				if (null != rule)
				{
					strBorderWidth = rule.style.borderWidth;
					borderWidth = parseInt(strBorderWidth);
					if (isNaN(borderWidth))
					{		
						borderWidth = 0;
					}
				}
			}
		}
	}
	return borderWidth;
}

WebHtmlEditorWindow.prototype.GetCssClass = function(className)
{
	try
	{
		for (var i = 0; i < document.styleSheets.length; i++)
		{
			try
			{
				var cssHref = document.styleSheets[i].href;		

⌨️ 快捷键说明

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