📄 mpc.htc
字号:
// Arguments: none
//
// Returns: nothing
//
//-----------------------------------------------------------------------------
function SelectContent()
{
var oContainer = null;
if(tagName=="container") oContainer = element;
if(tagName=="page") oContainer = parentElement;
if(oContainer.selectedIndex > oContainer.children.length)
{
var TempClass = oContainer.children(0).children(0).className;
TempClass = "ActiveContent" + TempClass.substring(TempClass.indexOf("_"), TempClass.length);
oContainer.children(0).children(0).className = TempClass;
return;
}
var TempClass = oContainer.children(oContainer.selectedIndex-1).children(0).className;
TempClass = "ActiveContent" + TempClass.substring(TempClass.indexOf("_"), TempClass.length);
oContainer.children(oContainer.selectedIndex-1).children(0).className = TempClass;
}
//+----------------------------------------------------------------------------
//
// Function: DeselectContent
//
// Description: Deselects the selected tab
//
// Arguments: none
//
// Returns: nothing
//
//-----------------------------------------------------------------------------
function DeselectContent()
{
var oContainer = null;
if(tagName=="container") oContainer = element;
if(tagName=="page") oContainer = parentElement;
for(i=0; i<oContainer.children.length; i++)
{
var TempClass = oContainer.children(i).children(0).className;
TempClass = "DormantContent" + TempClass.substring(TempClass.indexOf("_"), TempClass.length);
oContainer.children(i).children(0).className = TempClass;
}
}
//+----------------------------------------------------------------------------
//
// Function: SetTabTop
//
// Description: Sets the top position of the tabs, based on container.tdTabOrientation
//
// Arguments: none
//
// Returns: nothing
//
//-----------------------------------------------------------------------------
function SetTabTop()
{
var sOrient = null;
var iTop = null;
var iHeight = null;
if(tagName=="container") sOrient = style.tdTabOrientation.toUpperCase();
if(tagName=="page") sOrient = parentElement.style.tdTabOrientation.toUpperCase();
var Tabs = window.document.all("Tab");
if(sOrient == "TOP") iTop = -21;
if(sOrient == "BOTTOM" && tagName=="container") iTop = style.posHeight - 1;
if(sOrient == "BOTTOM" && tagName=="page")
{
if(isNaN(parentElement.ContainerHeight)) parentElement.ContainerHeight = 0;
iTop = parentElement.style.posHeight - 1;
for(i=0; i<parentElement.children.length; i++)
{
if(parentElement.children(i).children(0).offsetHeight>parentElement.ContainerHeight)
{
parentElement.ContainerHeight = parentElement.children(i).children(0).offsetHeight;
parentElement.style.height = parentElement.ContainerHeight;
}
}
iTop = parentElement.ContainerHeight-1;
}
//if there are no tabs
if(Tabs==null) return;
//if there is only one tab
if(Tabs.length==null)
{
Tabs.style.top = iTop;
return;
}
//if there are more than 1 tab
for(i=0; i<Tabs.length; i++)
{
Tabs(i).style.top = iTop;
}
}
function SetContainerHeight()
{
if(isNaN(parentElement.style.posHeight)) parentElement.style.height = 0;
parentElement.ContainerHeight = 0;
for(i=0; i<parentElement.children.length; i++)
{
if(parentElement.children(i).children(0).offsetHeight > parentElement.ContainerHeight)
{
parentElement.ContainerHeight = parentElement.children(i).children(0).offsetHeight;
parentElement.style.height = parentElement.ContainerHeight;
}
}
}
//+----------------------------------------------------------------------------
//
// Function: SetTabFormat
//
// Description: Formats the tab for display at top or bottom orientation
//
// Arguments: none
//
// Returns: nothing
//
//-----------------------------------------------------------------------------
function SetTabFormat()
{
var sOrient = null;
if(tagName=="container")
{
sOrient = style.tdTabOrientation.toUpperCase();
}
if(tagName=="page")
{
sOrient = parentElement.style.tdTabOrientation.toUpperCase();
}
var Tabs = window.document.all("Tab");
//if there are no tabs
if(Tabs==null) return;
//if there is only one tab
if(Tabs.length==null)
{
if(sOrient=="TOP")
{
Tabs.rows(0).style.display = "inline";
Tabs.rows(1).style.display = "inline";
Tabs.rows(3).style.display = "none";
Tabs.rows(4).style.display = "none";
}
if(sOrient=="BOTTOM")
{
Tabs.rows(0).style.display = "none";
Tabs.rows(1).style.display = "none";
Tabs.rows(3).style.display = "inline";
Tabs.rows(4).style.display = "inline";
}
return;
}
//if there are more than 1 tab
for(i=0; i<Tabs.length; i++)
{
if(sOrient=="TOP")
{
Tabs(i).rows(0).style.display = "block";
Tabs(i).rows(1).style.display = "block";
Tabs(i).rows(3).style.display = "none";
Tabs(i).rows(4).style.display = "none";
}
if(sOrient=="BOTTOM")
{
Tabs(i).rows(0).style.display = "none";
Tabs(i).rows(4).style.display = "block";
Tabs(i).rows(1).style.display = "none";
Tabs(i).rows(3).style.display = "block";
}
}
}
//+----------------------------------------------------------------------------
//
// Function: PositionTabs
//
// Description: Positions all tabs. Called after resetting the label in a tab
//
// Arguments: none
//
// Returns: nothing
//
//-----------------------------------------------------------------------------
function PositionTabs()
{
var iIndex = parseInt(children(1).index);
iCurrentLeft = children(1).style.posLeft + children(1).offsetWidth;
for(i=iIndex; i<parentElement.children.length; i++)
{
var CurrentTab = parentElement.children(i).children(1);
CurrentTab.style.left = iCurrentLeft;
iCurrentLeft = CurrentTab.style.posLeft + CurrentTab.offsetWidth;
}
parentElement.CumulativeTabWidth = 0;
for(i=0; i<parentElement.children.length; i++)
{
parentElement.CumulativeTabWidth = parentElement.CumulativeTabWidth + parentElement.children(i).children(1).offsetWidth;
}
}
//+----------------------------------------------------------------------------
//
// Function: DoPropChange
//
// Description: Handles property changes on CSS and regular property
// attributes.
//
// Arguments: none
//
// Returns: nothing
//
//-----------------------------------------------------------------------------
function DoPropChange()
{
var propertyName = window.event.propertyName;
detachEvent("onpropertychange", DoPropChange);
if (propertyName.substring(0,5) == "style")
{
switch (propertyName)
{
case "style.tdTabOrientation" :
SetTabTop();
SetTabFormat();
break;
case "style.backgroundColor" :
SetBackgroundColor();
break;
case "style.color" :
SetColor();
break;
case "style.width" :
ConfirmContainerWidth();
break;
case "style.height" :
if(ContainerHeight>style.posHeight) style.height = ContainerHeight;
SetTabTop();
break;
default :
break;
}
}
else
{
switch(propertyName)
{
case "selectedIndex" :
DeselectTab();
SelectTab();
DeselectContent();
SelectContent();
change.fire();
children(selectedIndex-1).FireFocus();
break;
case "TABTITLE" :
children(1).rows(2).cells(2).title = TABTITLE;
break;
case "TABTEXT" :
children(1).rows(2).cells(2).innerText = TABTEXT;
children(1).rows(2).cells(2).style.width = parseInt((TABTEXT.length*6)+8);
PositionTabs();
ConfirmContainerWidth();
break;
default :
break;
}
}
attachEvent("onpropertychange", DoPropChange);
}
//+----------------------------------------------------------------------------
//
// Function: ConfirmContainerWidth
//
// Description: Sets container width to Cumulative width of tabs + 10 if
// container is not wide enough to accommodate tab widths
//
// Arguments: none
//
// Returns: nothing
//
//-----------------------------------------------------------------------------
function ConfirmContainerWidth()
{
if(tagName=="container")
{
if(style.posWidth<CumulativeTabWidth+10)
{
style.width = CumulativeTabWidth + 10;
}
}
if(tagName=="page")
{
//skip if the container is automatically determining width
if(parentElement.style.width == 'auto') return;
if(parentElement.style.posWidth<parentElement.CumulativeTabWidth+10)
{
parentElement.style.width = parentElement.CumulativeTabWidth + 10;
}
}
}
//+----------------------------------------------------------------------------
//
// Function: SetBackgroundColor
//
// Description: Sets the background color for the control
//
// Arguments: none
//
// Returns: nothing
//
//-----------------------------------------------------------------------------
function SetBackgroundColor()
{
if(tagName!="container") return;
var Tabs = element.children;
//alert(Tabs.length);
if(Tabs==null) return;
if(Tabs.length==null)
{
Tabs.children(0).style.background = style.background;
Tabs.children(1).rows(2).cells(1).style.background = style.background;
Tabs.children(1).rows(2).cells(2).style.background = style.background;
return;
}
for(i=0; i<Tabs.length; i++)
{
Tabs(i).children(0).style.background = style.background;
Tabs(i).children(1).rows(2).cells(1).style.background = style.background;
Tabs(i).children(1).rows(2).cells(2).style.background = style.background;
}
}
//+----------------------------------------------------------------------------
//
// Function: SetColor
//
// Description: Sets the foreground color for the control
//
// Arguments: none
//
// Returns: nothing
//
//-----------------------------------------------------------------------------
function SetColor()
{
if(tagName!="container") return;
var Tabs = element.children;
//alert(Tabs.length);
if(Tabs==null) return;
if(Tabs.length==null)
{
Tabs.children(0).style.color = style.color;
Tabs.children(1).rows(2).cells(1).style.color = style.color;
Tabs.children(1).rows(2).cells(2).style.color = style.color;
return;
}
for(i=0; i<Tabs.length; i++)
{
Tabs(i).children(0).style.color = style.color;
Tabs(i).children(1).rows(2).cells(1).style.color = style.color;
Tabs(i).children(1).rows(2).cells(2).style.color = style.color;
}
}
//+----------------------------------------------------------------------------
//
// Function: FireFocus
//
// Description: Fires the onfocus event
//
// Arguments: none
//
// Returns: nothing
//
//-----------------------------------------------------------------------------
function FireFocus()
{
focus.fire();
}
</SCRIPT>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -