📄 webhtmleditorwindows.js.txt.exclude
字号:
{
document.body.addEventListener("keydown", Document_OnKeyDown, false);
}
}
WebHtmlEditorWindowManager.prototype.ShowModalWindow = function(windowInfo)
{
var wnd = this.CreateWindow(true, windowInfo);
return wnd;
}
WebHtmlEditorWindowManager.prototype.ShowModallessWindow = function(windowInfo)
{
var wnd = this.CreateWindow(false, windowInfo);
return wnd;
}
/////////////////////////////////////////////////
// WINDOWS OPERATIONS
WebHtmlEditorWindowManager.prototype.CreateWindow = function(bIsModal, windowInfo)
{
if (!windowInfo)
return null;
/********* THIS CODE MAKES MOZILLA USE REGULAR WINDOWS INSTEAD OF WHE WINDOW *********/
windowInfo.UseClassicDialogs = (this.IsIE && windowInfo.UseClassicDialogs)|| (!this.IsIE && ((null != windowInfo.Url && "" != windowInfo.Url) || (null != windowInfo.InnerHtml && "" != windowInfo.InnerHtml && windowInfo.UseClassicDialogs)));
var id = "";
if (!windowInfo.ID || windowInfo.ID == "")
{
id = this.ChildWindows.length;
}
else
{
id = windowInfo.ID;
}
var caption = "";
if (null == windowInfo.Caption)
{
caption = "[" + id + "]";
}
else
{
caption = windowInfo.Caption;
}
var tempWebHtmlEditorWindow = this.GetWindow(id);
tempWebHtmlEditorWindow.Argument = windowInfo.Argument;
tempWebHtmlEditorWindow.Width = windowInfo.Width;
tempWebHtmlEditorWindow.Height = windowInfo.Height;
tempWebHtmlEditorWindow.CallbackFunc = windowInfo.CallbackFunc;
tempWebHtmlEditorWindow.Param = windowInfo.Param;
tempWebHtmlEditorWindow.CanResize = windowInfo.Resizable;
tempWebHtmlEditorWindow.CanMove = windowInfo.Movable;
tempWebHtmlEditorWindow.OnLoadFunc = windowInfo.OnLoadFunc;
tempWebHtmlEditorWindow.UseWebHtmlEditorWindow = !windowInfo.UseClassicDialogs;
if (windowInfo.UseClassicDialogs && this.IsIE)
{
var features = "status:no;"
+ "resizable:yes;"
+ "center:yes;"
+ "help:no;"
+ "minimize:no;"
+ "maximize:no;"
+ "scroll:no;"
+ "border:thin;"
+ "statusbar:no;"
+ "dialogWidth:" + windowInfo.Width + "px;"
+ "dialogHeight:" + windowInfo.Height + "px";
if (windowInfo.InnerHtml && windowInfo.InnerHtml != "")
{
tempWebHtmlEditorWindow.InnerHTML = windowInfo.InnerHtml;
}
if (!windowInfo.Url || "" == windowInfo.Url)
windowInfo.Url = "javascript:''";
var dialogArguments = new Object();
dialogArguments.parentWindow = window;
dialogArguments.wheWindow = tempWebHtmlEditorWindow;
window.showModalDialog(windowInfo.Url, dialogArguments, features);
}
else if (windowInfo.UseClassicDialogs && !this.IsIE)
{
if (!windowInfo.Url || windowInfo.Url=="")windowInfo.Url = "javascript:''";
window.childWebHtmlEditorWindow = tempWebHtmlEditorWindow;
tempWebHtmlEditorWindow.Window = window.open(windowInfo.Url
, "_blank"
, "status=no,toolbar=no,location=no,resizable=yes,menubar=no,width=" + windowInfo.Width + ",height=" + windowInfo.Height + ",modal=yes");
}
else if (!windowInfo.UseClassicDialogs)
{
var container = null;
if (this.ContainerPool.length > 0)
{
container = this.ContainerPool.pop();
}
else
{
container = document.createElement("SPAN");
document.body.appendChild(container);
}
container.innerHTML = this.BuildWrapperTableHtml(id, windowInfo.Width, windowInfo.Height, caption, bIsModal, windowInfo.CloseHide, windowInfo.BlankIFrameLocation);
var contentElem = (null != windowInfo.InnerObject) ? windowInfo.InnerObject:document.getElementById("WebHtmlEditorWindowContentFrame" + id);
tempWebHtmlEditorWindow.Init(contentElem, true, container, bIsModal, ++this.TopWindowZIndex);
var frm = document.getElementById("WebHtmlEditorWindowContentFrame" + id);
/*** NS toolbar when toolOnPage = false and content element is DIV ***/
tempWebHtmlEditorWindow.Window = null != frm ? frm.contentWindow : null;
if (windowInfo.InnerHtml && windowInfo.InnerHtml != "")
{
var doc = frm.contentWindow.document;
doc.open();
doc.write(windowInfo.InnerHtml);
doc.close();
}
else if (windowInfo.Url && windowInfo.Url != "")
{
frm.src = windowInfo.Url;
}
if (bIsModal)
{
this.SetCapture(tempWebHtmlEditorWindow, false);
}
var theVisibleWidth = Math.min(window.screen.width, document.body.clientWidth);
var theVisibleHeight = (document.documentElement && document.documentElement.clientHeight)?document.documentElement.clientHeight:Math.min(window.screen["height"], document.body.clientHeight);
var x = GetScrollLeft(document) + (theVisibleWidth - parseInt(windowInfo.Width)) / 2;
var y = GetScrollTop(document) + (theVisibleHeight - parseInt(windowInfo.Height)) / 2;
if (null == windowInfo.IsVisible)
{
windowInfo.IsVisible = false;
}
tempWebHtmlEditorWindow.SetSize(windowInfo.Width, windowInfo.Height);
tempWebHtmlEditorWindow.ShowWindow(windowInfo.IsVisible, x, y);
}
return tempWebHtmlEditorWindow;
}
WebHtmlEditorWindowManager.prototype.DestroyWindow = function(childWindow)
{
var nextWndToActivate = this.GetPrevWindow(childWindow.Id);
this.UnregisterChild(childWindow);
if (nextWndToActivate != childWindow)
{
this.ActivateWindow(nextWndToActivate);
}
eval(this.GetWindowVarName(childWindow.Id) + " = null;");
if (childWindow.Container)
{
this.ContainerPool.push(childWindow.Container);
}
}
WebHtmlEditorWindowManager.prototype.GetPrevWindow = function(id)
{
var bNeedPrev = false;
var retWnd = null;
for (var i = this.ChildWindows.length - 1; i >= 0; i--)
{
var wnd = this.ChildWindows[i];
if (wnd && wnd.Id == id)
{
bNeedPrev = true;
}
else if (wnd && bNeedPrev)
{
return wnd;
}
else if (null == retWnd)
{
retWnd = wnd;
}
}
return retWnd;
}
WebHtmlEditorWindowManager.prototype.CloseWindow = function(id)
{
var wnd = this.LookupWindow(id);
if (wnd)
{
wnd.Close();
}
}
WebHtmlEditorWindowManager.prototype.ActivateWindow = function(doc)
{
if (!doc)
{
doc = this.ActiveWindow;
}
if (doc)
{
if (doc.IsModal)
{
this.SetCapture(doc, false);
}
if (doc != this.ActiveWindow)
{
if (this.ActiveWindow)
{
this.ActiveWindow.SetZIndex(this.TopWindowZIndex - 1);
}
doc.SetZIndex(this.TopWindowZIndex);
this.ActiveWindow = doc;
}
}
}
WebHtmlEditorWindowManager.prototype.RegisterChild = function(childWindow)
{
this.ChildWindows[this.ChildWindows.length] = childWindow;
}
WebHtmlEditorWindowManager.prototype.UnregisterChild = function(childWindow)
{
for (var i = 0; i < this.ChildWindows.length; i++)
{
var wnd = this.ChildWindows[i];
if (wnd == childWindow)
{
this.ChildWindows[i] = null;
return;
}
}
}
WebHtmlEditorWindowManager.prototype.SetCapture = function(childWindow, bContainerCapture)
{
try
{
if (childWindow)
{
childWindow.SetCapture(bContainerCapture);
}
}
catch (ex)
{
}
}
WebHtmlEditorWindowManager.prototype.LookupWindow = function(id)
{
for (var i = 0; i < this.ChildWindows.length; i++)
{
var wnd = this.ChildWindows[i];
if (wnd && id == wnd.Id)
{
return wnd;
}
}
return null; //this.ChildWindows[id];
}
WebHtmlEditorWindowManager.prototype.LookupWindowByBrowserWindowRef = function(browserWindow)
{
for (var i = 0; i < this.ChildWindows.length; i++)
{
var wheWindow = this.ChildWindows[i];
if (null != wheWindow && browserWindow == wheWindow.Window)
{
return wheWindow;
}
}
return null;
}
WebHtmlEditorWindowManager.prototype.GetCurrentWindow = function(browserWindow)
{
if (browserWindow.dialogArguments)
{
return browserWindow.dialogArguments.wheWindow;
}
else if (browserWindow.opener != null && browserWindow.opener.childWebHtmlEditorWindow != null)
{
return browserWindow.opener.childWebHtmlEditorWindow;
}
else
{
return this.LookupWindowByBrowserWindowRef(browserWindow);
}
}
// If already exists a window with same id - returns it;
// Otherwise creates a new window and returns it
WebHtmlEditorWindowManager.prototype.GetWindow = function(id)
{
var wnd = this.LookupWindow(id);
if (!wnd)
{
var varName = this.GetWindowVarName(id);
eval(varName + " = new WebHtmlEditorWindow('" + id + "');");
wnd = eval(varName);
wnd.Parent = this;
this.RegisterChild(wnd);
}
return wnd;
}
WebHtmlEditorWindowManager.prototype.GetWindowVarName = function(id)
{
return "window.wheWindow_" + id;
}
WebHtmlEditorWindowManager.prototype.GetWindowFromPos = function(x, y)
{
var wnd = null;
for (var i = 0; i < this.ChildWindows; i++)
{
var childWnd = this.ChildWindows[i];
if (childWnd && childWnd.HitText(x, y))
{
if (!wnd || wnd.ZIndex < childWnd.ZIndex)
{
wnd = childWnd;
}
}
}
return wnd;
}
WebHtmlEditorWindowManager.prototype.OnShowWindow = function(childWindow, visible)
{
if (visible)
{
this.ActiveWindow = childWindow;
}
else
{
if (this.ActiveWindow == childWindow)
{
this.ActiveWindow = null;
}
}
}
WebHtmlEditorWindowManager.prototype.OnKeyDown = function(evt)
{
switch (evt.keyCode)
{
case 27:
if (this.ActiveWindow)
{
this.ActiveWindow.Close();
}
break;
default:
return;
}
evt.cancelBubble = true;
evt.returnValue = false;
}
WebHtmlEditorWindowManager.prototype.BuildWrapperTableHtml = function(id, width, height, caption, bIsModal, bHide, blankIFrameLocation)
{
var url = ((null != blankIFrameLocation && "" != blankIFrameLocation) ? blankIFrameLocation : "javascript:'';");
var closeFunc = bHide ? "ShowWindow(false)" : "Close()";
var html = "";
html += " <table border='0' id='WebHtmlEditorWindowContentWrapper" + id + "' class='WHETableWrapper' style='display:block; z-index:1000; position:absolute;' cellspacing='0' cellpadding='0' width='" + width + "px' height='" + height + "px'>\n"
+ " <tr>\n"
+ " <td width='1' class='WHETableWrapperHeaderLeft' nowrap></td>\n"
+ " <td width='100%' class='WHETableWrapperHeaderCenter' nowrap='true' ondblclick='wheWindow_" + id + ".ToggleContent();' onmousedown='wheWindow_" + id + ".DragMode=\"move\"; return wheWindow_" + id + ".OnDragStart(event);' onselectstart='return false;'>\n"
+ " <span id='WebHtmlEditorWindowCaption" + id + "' onselectstart='return false;' class='WHEWindowHeader'>" + caption + "</span>\n"
+ " </td>\n";
if (!bIsModal)
{
html += " <td width='1' class='WHETableWrapperHeaderCenter' nowrap>\n"
+ " <span class='WHEWindowButtonPinOff' id='ButtonPin' onclick='wheWindow_" + id + ".ToggleCanMove(this)'> </span>"
+ " </td>\n";
}
html += " <td width='1' class='WHETableWrapperHeaderCenter' nowrap>\n"
+ " <span class='WHEWindowButtonClose' id='ButtonClose' onclick='wheWindow_" + id + "." + closeFunc + "'> </span>\n"
+ " </td>\n"
+ " <td width='1' class='WHETableWrapperHeaderRight' nowrap></td>\n"
+ " </tr>\n"
+ " <tr>\n"
+ " <td id='WebHtmlEditorWindowContentTD" + id + "' colspan='5'>\n"
+ " <table border='0' width='100%' height='100%' cellspacing='0' cellpadding='0'>\n"
+ " <tr>\n"
+ " <td width='1' class='WHETableWrapperBodyLeft' nowrap></td>\n"
+ " <td width='100%' class='WHETableWrapperBodyCenter' align='left' valign='top' onselectstart='return false;'>\n"
+ " <span id='WebHtmlEditorWindowContentWindow" + id + "' align='center' style='width:100%;height:100%;' >\n"
+ " <iframe name='wheWindowContent' frameborder='0px' style='border:0px solid green' id='WebHtmlEditorWindowContentFrame" + id + "' src='" + url + "' scrolling='no' border='no' width='100%' height='100%' ></iframe>\n"
+ " </span>\n"
+ " </td>\n"
+ " <td width='1' class='WHETableWrapperBodyRight' nowrap></td>\n"
+ " </tr>\n"
+ " </table>\n"
+ " </td>\n"
+ " </tr>\n"
+ " <tr>\n"
+ " <td colspan='5' width='100%' height='1' >\n"
+ " <table border='0' width='100%' height='1' cellspacing='0' cellpadding='0'>\n"
+ " <tr>\n"
+ " <td width='1' class='WHETableWrapperFooterLeft' nowrap> </td>\n"
+ " <td colspan='3' id='BorderBottom' width='100%' class='WHETableWrapperFooterCenter' nowrap> </td> \n"
+ " <td width='1' id='CornerBottomRight' class='WHETableWrapperFooterRight' onmousedown='wheWindow_" + id + ".DragMode=\"size\"; return wheWindow_" + id + ".OnDragStart(event);' onselectstart='return false;' nowrap> </td>\n"
+ " </tr>\n"
+ " </table>\n"
+ " </td>\n"
+ " </tr>\n"
+ " </table>\n";
return html;
}
function CloseDlg(returnValue)
{
if (window.wheWindow)
{
window.wheWindow.ReturnValue = returnValue;
window.wheWindow.Close();
}
}
function GetScrollTop(oDocument)
{
if (oDocument.documentElement && oDocument["documentElement"].scrollTop)
{
return oDocument["documentElement"].scrollTop;
}
else
{
return oDocument.body.scrollTop;
}
}
function GetScrollLeft(oDocument)
{
if (oDocument.documentElement && oDocument["documentElement"].scrollLeft)
{
return oDocument["documentElement"].scrollLeft;
}
else
{
return oDocument.body.scrollLeft;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -