📄 toolbar.htc
字号:
if (oCell._type == "emptygroup")
return;
var oContent = oCell.children[0];
var len = oContent.children.length;
for (nIndex = 0; nIndex < len; nIndex++)
{
var oObj = oContent.children[nIndex];
if (oObj.tagName == "IMG")
{
oObj.align = (bTurnContent) ? "middle" : "absmiddle";
}
}
}
//+----------------------------------------------------------------------------
// Function: f_CreateGripper
// Description: Creates a gripper toolbar item for graggin the toolbar.
// Parameter: oNode The toolbaritem to convert
// Returns: The gripper item
//-----------------------------------------------------------------------------
function f_CreateGripper(oNode)
{
var oCell = element.document.createElement("td");
var oDiv = element.document.createElement("div");
oCell.appendChild(oDiv);
var szStyle = "";
if ((element.style.writingMode != null) && (element.style.writingMode == "tb-rl"))
szStyle = (orientation == "vertical") ? _szGripperHorizStyle : _szGripperVertStyle;
else
szStyle = (orientation == "vertical") ? _szGripperVertStyle : _szGripperHorizStyle;
oDiv._origStyle = oNode.style.cssText;
oDiv.style.cssText = szStyle + ";" + oDiv._origStyle;
oCell.mergeAttributes(oNode);
oCell.id = oNode.getAttribute("id");
oCell._type = "gripper";
return oCell;
}
//+----------------------------------------------------------------------------
// Function: f_CreateSeparator
// Description: Creates a separator toolbar item.
// Parameter: oNode The toolbaritem to convert
// Returns: The separator item
//-----------------------------------------------------------------------------
function f_CreateSeparator(oNode)
{
var oCell = element.document.createElement("TD");
var oDiv = element.document.createElement("DIV");
oCell.appendChild(oDiv);
var szStyle;
if ((element.style.writingMode != null) && (element.style.writingMode == "tb-rl"))
szStyle = (orientation == "vertical") ? _szSeparatorHorizStyle : _szSeparatorVertStyle;
else
szStyle = (orientation == "vertical") ? _szSeparatorVertStyle : _szSeparatorHorizStyle;
oDiv._origStyle = oNode.style.cssText;
oDiv.style.cssText = szStyle + ";" + oDiv._origStyle;
oCell.mergeAttributes(oNode);
oCell.id = oNode.getAttribute("id");
oCell._type = "separator";
return oCell;
}
//+----------------------------------------------------------------------------
// Function: f_CreateButton
// Description: Creates a toolbar button.
// Parameter: oNode The toolbaritem to convert
// Returns: The button item
//-----------------------------------------------------------------------------
function f_CreateButton(oNode)
{
var oCell = f_CreateLabel(oNode, true);
if (oCell.children[0].tabIndex == 0)
oCell.children[0].tabIndex = 1;
oCell._type = "button";
oCell.attachEvent("onkeyup", f_OnKeyUp);
return oCell;
}
//+----------------------------------------------------------------------------
// Function: f_CreateCheckbutton
// Description: Creates a checkbutton type item
// Parameter: oNode The toolbaritem to convert
// Returns: The checkbutton item
//-----------------------------------------------------------------------------
function f_CreateCheckbutton(oNode)
{
var oCell = f_CreateButton(oNode);
oCell._type = "checkbutton";
if (oCell.getAttribute("selected") == null)
oCell.setAttribute("selected", "false", 0);
return oCell;
}
//+----------------------------------------------------------------------------
// Function: f_CreateCheckGroup
// Description: Creates a group of checkbuttons
// Parameter: oNode The toolbaritem to convert
// Returns: An array of checkbuttons
//-----------------------------------------------------------------------------
function f_CreateCheckGroup(oNode)
{
var aTempNodes = f_CreateNodesFromHtml(oNode.innerHTML);
var aNodes = new Array();
var oGroup = new Object();
// Setup the group object
var forceSel = oNode.getAttribute("forceselection");
oGroup.bForceSel = (forceSel != null) && (String(forceSel).toLowerCase() == "true");
oGroup.oSelected = null;
oGroup.szDefaultStyle = oNode.getAttribute("defaultstyle");
oGroup.szHoverStyle = oNode.getAttribute("hoverstyle");
oGroup.szSelectedStyle = oNode.getAttribute("selectedstyle");
var nFirstCheckBtn = -1;
var bDisabled = oNode.disabled;
for (var nIndex = 0; nIndex < aTempNodes.length; nIndex++)
{
var oCell = aTempNodes[nIndex];
if (oCell._type == "checkbutton")
{
if (nFirstCheckBtn == -1)
nFirstCheckBtn = nIndex;
aNodes = aNodes.concat(new Array(oCell));
if ((oCell.id == null) || (oCell.id == ""))
{
oCell.id = oCell.uniqueID;
}
oCell._group = oGroup;
if (f_IsSelected(oCell))
{
if (oGroup.oSelected == null)
{
oGroup.oSelected = oCell.uniqueID;
}
else
{
f_SetSelected(oCell, false);
}
}
}
oCell.disabled = (bDisabled || oCell.isDisabled);
}
// If nothing selected, and force selection is on, then select the first node
if (oGroup.bForceSel && (oGroup.oSelected == null) && (nFirstCheckBtn != -1))
{
var oCell = aNodes[nFirstCheckBtn];
oGroup.oSelected = oCell.uniqueID;
f_SetSelected(oCell, true);
}
// If no buttons were created, then put in a hidden cell to represent the group
if (aNodes.length == 0)
aNodes = new Array(f_CreateEmptyGroup(oGroup));
return aNodes;
}
//
// Creates an empty CheckGroup object
//
function f_CreateEmptyGroup(group)
{
var empty = element.document.createElement("TD");
empty._type = "emptygroup";
empty._group = group;
empty.style.display = "none";
return empty;
}
//+----------------------------------------------------------------------------
// Function: f_CreateLabel
// Description: Creates a toolbar label.
// Parameter: oNode The toolbaritem to convert
// Returns: The label item
//-----------------------------------------------------------------------------
function f_CreateLabel(oNode, useLink)
{
var oCell = element.document.createElement("TD");
var oContent = element.document.createElement((useLink) ? "A" : "SPAN");
oCell.appendChild(oContent);
var szText = oNode.getAttribute("text");
var szImageUrl = oNode.getAttribute("imageUrl");
if (szText == null)
{
// Use the content of the node as content
while (oNode.childNodes.length > 0)
oContent.appendChild(oNode.childNodes[0].removeNode(true));
}
else
{
// Use the text attribute's value as content
var oText = element.document.createElement("SPAN");
oText.innerText = szText;
oContent.appendChild(oText);
}
// If an image was specified, insert it before any content
if (szImageUrl != null)
{
var cacheImage = new Image();
cacheImage.src = szImageUrl;
var oImg = element.document.createElement("IMG");
oImg.src = cacheImage.src;
if (oContent.hasChildNodes())
oContent.insertBefore(oImg, oContent.childNodes[0]);
else
oContent.insertBefore(oImg);
oContent.setAttribute("_imageAdded", "true", 0);
}
if (oContent.childNodes.length == 0)
oContent.innerHTML = " ";
// Copy and set specific attributes
oCell.mergeAttributes(oNode);
if (oCell.tabIndex > 0)
{
oContent.tabIndex = oCell.tabIndex;
oCell.tabIndex = -1;
}
if (oCell.title != "")
{
oContent.title = oCell.title;
oCell.title = "";
}
oCell.id = oNode.getAttribute("id");
oCell.noWrap = "true";
oCell._type = "label";
oContent.style.cssText = oNode.style.cssText;
return oCell;
}
//+----------------------------------------------------------------------------
// Function: f_CreateTextBox
// Description: Creates a toolbar text box.
// Parameter: oNode The toolbaritem to convert
// Returns: The textbox
//-----------------------------------------------------------------------------
function f_CreateTextBox(oNode)
{
var oCell = element.document.createElement("td");
var szType = oNode.getAttribute("type");
var szValue = oNode.getAttribute("value");
var szSize = oNode.getAttribute("size");
var szMaxLength = oNode.getAttribute("maxlength");
var szReadOnly = oNode.getAttribute("readonly");
// Only allow password or text
if ((szType == null) || (szType.toLowerCase() != "password"))
szType = "text";
var szTabIndex = "1";
if (oNode.tabIndex != 0)
szTabIndex = oNode.getAttribute("tabindex");
oCell.innerHTML = "<input type=\"" + szType + "\">";
var textbox = oCell.children[0];
textbox.mergeAttributes(oNode);
if ((szSize != null) && (szSize != ""))
textbox.size = szSize;
if ((szMaxLength != null) && (szMaxLength != ""))
textbox.maxLength = szMaxLength;
if ((szTabIndex != null) && (szTabIndex != ""))
textbox.tabIndex = szTabIndex;
if ((szValue != null) && (szValue != ""))
textbox.value = szValue;
if ((szReadOnly != null) && (szReadOnly != ""))
textbox.readOnly = szReadOnly;
var changeScript = oNode.getAttribute("onchange");
if (changeScript != null)
textbox.onchange = function() { eval(changeScript) };
oCell.id = oNode.getAttribute("id");
oCell._type = "textbox";
oCell.noWrap = "true";
var szDefaultStyle = oNode.getAttribute("defaultStyle");
var fontStr = f_CreateFontString(oNode);
szDefaultStyle = (szDefaultStyle == null) ? fontStr : fontStr + szDefaultStyle;
if (szDefaultStyle != null)
{
oCell.setAttribute("defaultStyle", szDefaultStyle, 0);
oCell.children[0].removeAttribute("defaultStyle", 0);
}
return oCell;
}
//
// Creats a font string to allow inheritance to go correctly with textboxes and drop downs
//
function f_CreateFontString(oNode)
{
var fontStr = "";
if (oNode.style.fontFamily)
fontStr += "font-family:" + oNode.style.fontFamily + ";";
if (oNode.style.fontSize)
fontStr += "font-size:" + oNode.style.fontSize + ";";
if (oNode.style.fontStyle)
fontStr += "font-style:" + oNode.style.fontStyle + ";";
if (oNode.style.fontVariant)
fontStr += "font-variant:" + oNode.style.fontVariant + ";";
if (oNode.style.fontWeight)
fontStr += "font-weight:" + oNode.style.fontWeight + ";";
return fontStr;
}
//+----------------------------------------------------------------------------
// Function: f_InheritCellFont
// Description: For dropdownlists and textboxes, makes the control inherit
// the parent's font.
// Parameter: oCell The cell that contains control
//-----------------------------------------------------------------------------
function f_InheritCellFont(oCell)
{
oCell.children[0].style.fontFamily = oCell.style.fontFamily;
oCell.children[0].style.fontSize = oCell.style.fontSize;
oCell.children[0].style.fontStyle = oCell.style.fontStyle;
oCell.children[0].style.fontVariant = oCell.style.fontVariant;
oCell.children[0].style.fontWeight = oCell.style.fontWeight;
}
//+----------------------------------------------------------------------------
// Function: f_CreateDropDownList
// Description: Creates a toolbar drop down list.
// Parameter: oNode The toolbaritem to convert
// Returns: The drop down list.
//-----------------------------------------------------------------------------
function f_CreateDropDownList(oNode)
{
var oCell = element.document.createElement("td");
var szTabIndex = "1";
if (oNode.tabIndex != 0)
szTabIndex = oNode.getAttribute("tabindex");
var szHtml = "<select"
if ((szTabIndex != null) && (szTabIndex != ""))
szHtml += " tabindex=\"" + szTabIndex + "\"";
szHtml += ">";
szHtml += oNode.innerHTML;
szHtml += "</select>";
oCell.innerHTML = szHtml;
oCell.children[0].mergeAttributes(oNode);
// SELECTs don't seem to inherit this property
oCell.children[0].disabled = oNode.isDisabled || element.isDisabled;
oCell.id = oNode.getAttribute("id");
oCell._type = "dropdownlist";
oCell.noWrap = "true";
var changeScript = oNode.getAttribute("onchange");
if (changeScript != null)
oCell.children[0].onchange = function() { eval(changeScript) };
var szDefaultStyle = oNode.getAttribute("defaultStyle");
var fontStr = f_CreateFontString(oNode);
szDefaultStyle = (szDefaultStyle == null) ? fontStr : fontStr + szDefaultStyle;
if (szDefaultStyle != null)
{
oCell.setAttribute("defaultStyle",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -