?? tabstrip.htc
字號:
content.appendChild(span);
}
function f_RemoveTextNodes(item)
{
var content = getContent(item);
if (content.hasChildNodes())
{
if (item.getAttribute("_spadded"))
item.removeAttribute("_spadded");
var index = (item.getAttribute("_imgadded") == null) ? 0 : 1;
while (index < content.childNodes.length)
content.childNodes[index].removeNode(true);
}
}
function f_TabClick()
{
if (_IsSubmitting)
return;
if (event.button > 1)
return;
f_SetIndexByEvent();
}
function f_TabOver()
{
if (_IsSubmitting)
return;
var oNode = f_FindSurroundingCell(event.srcElement);
if ((oNode == null) || oNode.contains(event.fromElement))
return;
if (oNode.isDisabled)
return;
var nIndex = oNode.getAttribute("index");
if ((nIndex != null) && (nIndex != _nSelectedIndex))
{
if (oNode.getAttribute("_hover") == null)
{
if (_HoverIndex >= 0)
{
var oldTab = f_GetTab(_HoverIndex);
if (oldTab != null)
{
if (_HoverIndex != _nSelectedIndex)
f_SetTabInactive(oldTab);
oldTab.removeAttribute("_hover");
}
}
f_SetTabHover(oNode);
oNode.setAttribute("_hover", "true");
_HoverIndex = nIndex;
}
}
}
function f_TabOut()
{
if (_IsSubmitting)
return;
var oNode = f_FindSurroundingCell(event.srcElement);
if ((oNode == null) || oNode.contains(event.toElement))
return;
if (oNode.isDisabled)
return;
var nIndex = oNode.getAttribute("index");
if ((nIndex != null) && (nIndex != _nSelectedIndex))
{
f_SetTabInactive(oNode);
oNode.removeAttribute("_hover");
if ((_HoverIndex >= 0) && (_HoverIndex != nIndex))
{
var oldTab = f_GetTab(_HoverIndex);
if (oldTab != null)
{
if (_HoverIndex != _nSelectedIndex)
f_SetTabInactive(oNode);
oNode.removeAttribute("_hover");
}
}
_HoverIndex = -1;
}
}
function f_CancelEvent()
{
event.returnValue = false;
}
function f_FindSurroundingCell(oNode)
{
while (oNode != null)
{
if (oNode.getAttribute("_type") != null)
return oNode;
oNode = oNode.offsetParent;
}
return null;
}
function f_GetTab(index)
{
var nIndex = f_ConvertIndexToNodeIndex(index);
if (nIndex >= 0)
{
var oTab = _Tabs.children[nIndex];
return _bHorizontal ? oTab : oTab.childNodes[0];
}
return null;
}
function f_Redraw()
{
for (var nIndex = 0; nIndex < _Tabs.children.length; nIndex++)
{
var oNode = _Tabs.children[nIndex];
if (!_bHorizontal)
oNode = oNode.childNodes[0];
f_ApplyState(oNode, "redraw");
}
}
function f_GetTabNodeIndex(tab)
{
return f_ConvertIndexToNodeIndex(tab.getAttribute("index"));
}
function f_ConvertIndexToNodeIndex(index)
{
if ((index == null) || (index < 0) || (_Tabs == null) || (index >= _Tabs.children.length))
return -1;
for (var nIndex = 0; nIndex < _Tabs.children.length; nIndex++)
{
var oNode = _Tabs.children[nIndex];
if (!_bHorizontal)
oNode = oNode.childNodes[0];
var attrIndex = oNode.getAttribute("index");
if ((attrIndex != null) && (attrIndex == index))
return nIndex;
}
return -1;
}
function f_CreateStyleString(tab, szState)
{
var state = _StateVals[szState];
var isTab = (tab.getAttribute("_type") == "tab");
var localDefault = tab.getAttribute("defaultStyle");
var local = tab.getAttribute(szState + "Style");
var calcDefault;
var builtInColor = element.style.color;
if ((builtInColor == null) || (builtInColor == ""))
builtInColor = ";color:buttontext";
else
builtInColor = "";
if (isTab)
calcDefault = _BuiltInTabDefaultStyle + builtInColor + ";" + tabDefaultStyle + ";" + localDefault + ";";
else
calcDefault = _BuiltInSepDefaultStyle + ";" + sepDefaultStyle + ";" + localDefault + ";";
if (tab.isDisabled || element.isDisabled)
calcDefault += "cursor:default" + ";";
if (szState == "default")
return calcDefault;
var isHover = (szState == "hover");
if (isTab && isHover)
{
return calcDefault + _BuiltInTabHoverStyle + ";" + tabHoverStyle + ";" + local;
}
else if (isTab)
{
return calcDefault + _BuiltInTabSelectedStyle + ";" + tabSelectedStyle + ";" + local;
}
else if (isHover)
{
return calcDefault + _BuiltInSepHoverStyle + ";" + sepHoverStyle + ";" + local;
}
else
{
return calcDefault + _BuiltInSepSelectedStyle + ";" + sepSelectedStyle + ";" + local;
}
}
function f_CreateImageUrl(tab, szState)
{
var state = _StateVals[szState];
var szLocal = tab.getAttribute(szState + "ImageUrl");
if (szLocal != null)
return szLocal;
szLocal = tab.getAttribute("defaultImageUrl");
if (szLocal != null)
return szLocal;
if (tab.getAttribute("_type") == "tab")
return null;
if ((state == _StateHover) && (sepHoverImageUrl != null) && (sepHoverImageUrl != ""))
{
return sepHoverImageUrl;
}
else if ((state == _StateSelected) && (sepSelectedImageUrl != null) && (sepSelectedImageUrl != ""))
{
return sepSelectedImageUrl;
}
else if ((sepDefaultImageUrl != null) && (sepDefaultImageUrl != ""))
{
return sepDefaultImageUrl;
}
return null;
}
function f_ApplyState(tab, state)
{
var content = getContent(tab);
var curState = tab.getAttribute("state");
if (curState == state)
return;
if (state == "redraw")
state = curState;
var szImageUrl = f_CreateImageUrl(tab, state);
if (szImageUrl != null)
{
if (tab.getAttribute("_spadded") != null)
{
content.childNodes[0].removeNode(true);
tab.removeAttribute("_spadded", 0);
}
var oImg = element.document.createElement("IMG");
oImg.src = szImageUrl;
oImg.align = "absmiddle";
if (tab.getAttribute("_imgadded") == null)
tab.setAttribute("_imgadded", "true", 0);
else
content.children[0].removeNode(true);
if (content.hasChildNodes())
content.insertBefore(oImg, content.childNodes[0]);
else
content.insertBefore(oImg);
}
else if (tab.getAttribute("_imgadded") != null)
{
content.children[0].removeNode(true);
tab.removeAttribute("_imgadded", 0);
}
if (!content.hasChildNodes())
{
content.innerHTML = " ";
tab.setAttribute("_spadded", "true", 0);
}
var szStyle = f_CreateStyleString(tab, state);
if (szStyle != "")
tab.style.cssText = ";" + szStyle;
tab.setAttribute("state", state, 0);
}
function f_SetSeparatorState(sep, nIndex, state)
{
if (state == "selected")
{
f_ApplyState(sep, state);
return;
}
var oPrev = (nIndex >= 1) ? _Tabs.children[nIndex - 1] : null;
var oNext = ((nIndex + 1) < _Tabs.children.length) ? _Tabs.children[nIndex + 1] : null;
if (!_bHorizontal && (oPrev != null))
oPrev = oPrev.childNodes[0];
if (!_bHorizontal && (oNext != null))
oNext = oNext.childNodes[0];
var szPrevState = null;
var szNextState = null;
if ((oPrev != null) && (oPrev.getAttribute("index") != null))
szPrevState = oPrev.getAttribute("state");
if ((oNext != null) && (oNext.getAttribute("index") != null))
szNextState = oNext.getAttribute("state");
var stateVal = _StateVals[state];
if (szPrevState != null)
{
if (_StateVals[szPrevState] > stateVal)
return;
}
if (szNextState != null)
{
if (_StateVals[szNextState] > stateVal)
return;
}
f_ApplyState(sep, state);
}
function f_SetTabState(tab, state)
{
f_ApplyState(tab, state);
var nIndex = f_GetTabNodeIndex(tab);
var oPrev = (nIndex >= 1) ? _Tabs.children[nIndex - 1] : null;
var oNext = ((nIndex + 1) < _Tabs.children.length) ? _Tabs.children[nIndex + 1] : null;
if (!_bHorizontal && (oPrev != null))
oPrev = oPrev.childNodes[0];
if (!_bHorizontal && (oNext != null))
oNext = oNext.childNodes[0];
if ((oPrev != null) && (oPrev.getAttribute("index") == null))
f_SetSeparatorState(oPrev, nIndex - 1, state);
if ((oNext != null) && (oNext.getAttribute("index") == null))
f_SetSeparatorState(oNext, nIndex + 1, state);
}
function f_SetTabActive(tab)
{
f_SetTabState(tab, "selected");
tab.children[0].tabIndex = 0;
tab.children[0].focus();
}
function f_SetTabInactive(tab)
{
f_SetTabState(tab, "default");
tab.children[0].tabIndex = -1;
}
function f_SetTabHover(tab)
{
f_SetTabState(tab, "hover");
}
function f_NumTabs()
{
return _NumTabs;
}
function f_NumItems()
{
return _Tabs.children.length;
}
function f_GetSelectedIndex()
{
if (_nSelectedIndex < 0)
return -1;
return _nSelectedIndex;
}
function f_NavigateMultiPage(oTab)
{
var oTargetID = (oTab == null) ? null : oTab.getAttribute("targetid");
if (oTargetID != null)
{
var oTarget = element.document.all[oTargetID];
if (oTarget != null)
{
oTarget.setAttribute("activate", "true", 0);
}
}
else if (targetID != null)
{
var oTarget = element.document.all[targetID];
if (oTarget != null)
{
oTarget.selectedIndex = _nSelectedIndex;
}
}
}
function f_SetSelectedIndex(value)
{
if (_nSelectedIndex == value)
return;
if (value == -1)
{
var oPrevTab = f_GetTab(_nSelectedIndex);
if (oPrevTab != null)
f_SetTabInactive(oPrevTab);
_nSelectedIndex = -1;
if (!_InInit)
{
if (!_DelayEvent)
f_FireIndexChangeEvent();
}
return;
}
var oTab = f_GetTab(value);
if (oTab != null)
{
var oPrevTab = f_GetTab(_nSelectedIndex);
if (oPrevTab != null)
f_SetTabInactive(oPrevTab);
f_SetTabActive(oTab);
_nSelectedIndex = value;
if (!_InInit)
{
f_NavigateMultiPage(oTab);
if (!_DelayEvent)
f_FireIndexChangeEvent();
}
}
else if (_InInit)
{
_nSelectedIndex = value;
}
}
function f_FireIndexChangeEvent()
{
var oEvent = createEventObject();
oEvent.index = _nSelectedIndex;
evtIndexChangeEvent.fire(oEvent);
if (!_InInit)
propSelectedIndex.fireChange();
}
function f_GetDirection()
{
return _bHorizontal ? "horizontal" : "vertical";
}
function f_SetDirection(value)
{
if (value == null)
return;
value = value.toLowerCase();
if (value == "")
return;
if (!_bHorizontal && (value == "horizontal"))
{
_bHorizontal = true;
if (!_InInit)
{
f_RearrangeHorizontal();
propOrientation.fireChange();
}
}
else if (_bHorizontal && (value == "vertical"))
{
_bHorizontal = false;
if (!_InInit)
{
f_RearrangeVertical();
propOrientation.fireChange();
}
}
}
function f_RearrangeHorizontal()
{
while (_Tabs.children.length > 1)
{
_Tabs.children[0].appendChild(_Tabs.children[1].children[0]);
_Tabs.children[1].removeNode(true);
}
_Tabs = _Tabs.children[0];
}
function f_RearrangeVertical()
{
_Tabs = _Tabs.parentElement;
while (_Tabs.children[0].children.length > 1)
{
var row = element.document.createElement("TR");
_Tabs.appendChild(row);
row.appendChild(_Tabs.children[0].children[1]);
}
}
function f_OnKeyDown()
{
if (_IsSubmitting)
return;
if ((_bHorizontal && ((event.keyCode == 37) || (event.keyCode == 39))) ||
(!_bHorizontal && ((event.keyCode == 38) || (event.keyCode == 40))))
{
var dir = (event.keyCode <= 38) ? -1 : 1;
if ((element.dir != null) && (element.dir == "rtl") &&
((event.keyCode == 37) || (event.keyCode == 39)))
dir *= -1;
if (!_DelayEvent)
_FirstIndex = _nSelectedIndex;
var newIndex = _nSelectedIndex;
var oTab = null;
var oStopTab = f_GetTab(_nSelectedIndex);
do
{
newIndex = Number(newIndex) + Number(dir);
if (newIndex < 0)
newIndex = _NumTabs - 1;
else if (newIndex >= _NumTabs)
newIndex = 0;
oTab = f_GetTab(newIndex);
}
while ((oTab != null) && (oTab.isDisabled) && (oTab != oStopTab));
_DelayEvent = true;
f_SetSelectedIndex(newIndex);
}
}
function f_OnKeyUp()
{
if (_IsSubmitting)
return;
if (_DelayEvent)
{
_DelayEvent = false;
if (_FirstIndex != _nSelectedIndex)
f_SetEventTimeout();
_FirstIndex = -1;
}
}
function f_OnTabKeyUp()
{
if (_IsSubmitting)
return;
if ((event.srcElement.accessKey != null) && event.altKey &&
(event.srcElement.accessKey.toUpperCase().charCodeAt() == event.keyCode))
{
f_SetIndexByEvent();
}
}
function f_SetIndexByEvent()
{
var oNode = f_FindSurroundingCell(event.srcElement);
if (oNode == null)
return;
if (oNode.isDisabled)
return;
var nIndex = oNode.getAttribute("index");
if ((nIndex != null) && (nIndex != _nSelectedIndex))
f_SetSelectedIndex(nIndex);
}
function f_ClearEventTimeout()
{
if (_TimerSet)
{
window.clearTimeout(_TimerID);
_TimerSet = false;
}
}
function f_SetEventTimeout()
{
f_ClearEventTimeout();
_TimerID = window.setTimeout(f_FireIndexChangeEvent, 500, "JScript");
_TimerSet = true;
}
function f_OnStop()
{
if (!_IsSubmitting || (_OnStopCount > 0))
{
_IsSubmitting = false;
element.removeAttribute("_submitting");
}
_OnStopCount++;
}
</script>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -