📄 spmenu.js
字号:
function spm_applyRowBorder(oRow, iSize, sColor, bSelected, sStyle)
{
if (oRow.cells.length == 0) //(spm_browserType() == 'safari')
return; //safari has issues with accessing cell
var sColor2=sColor;
if (sStyle == null)
sStyle = "solid";
if (sColor == "")
{
//if (bSelected)
// sColor2 = this.selColor;
//else
sColor2 = spm_getCurrentStyle(oRow.cells[0], 'background-Color');
if (sColor2 == null || sColor2 == '')
sColor2 = 'transparent';
}
spm_applyBorders(oRow.cells[0], sStyle, iSize, sColor2, true, true, false, true);
if (sColor == "" && bSelected == false)
{
sColor2 = spm_getCellBackColor(oRow.cells[1]);
if (sColor2 == null || sColor2 == '')
sColor2 = 'transparent';
}
spm_applyBorders(oRow.cells[1], sStyle, iSize, sColor2, true, false, false, true);
spm_applyBorders(oRow.cells[2], sStyle, iSize, sColor2, true, false, true, true);
}
function spm_getCellBackColor(o)
{
var sColor = spm_getCurrentStyle(o, 'background-Color');
if (spm_browserType() == 'ie')
{
//--- fix IE transparent border issue ---//
while (sColor == 'transparent')
{
sColor = spm_getCurrentStyle(o, 'background-Color');
o = o.parentElement;
}
}
return sColor;
}
function spm_applyBorders(o, sStyle, iSize, sColor, t, l, r, b)
{
/*
if (t && sColor=='') o.style.paddingTop = iSize + "px ";
if (b && sColor=='') o.style.paddingBottom = iSize + "px ";
if (r && sColor=='') o.style.paddingRight = iSize + "px ";
if (l && sColor=='') o.style.paddingLeft = iSize + "px ";
if (sColor=='')
iSize = 0;
*/
if (t) o.style.borderTop = sStyle + " " + iSize + "px " + sColor;
if (b) o.style.borderBottom = sStyle + " " + iSize + "px " + sColor;
if (r) o.style.borderRight = sStyle + " " + iSize + "px " + sColor;
if (l) o.style.borderLeft = sStyle + " " + iSize + "px " + sColor;
}
function spm_resetScroll(oMenu)
{
if (oMenu.scrollItems != null)
{
oMenu.scrollPos = 1;
oMenu.scrollItems = 9999;
spm_showScrolledItems(oMenu);
}
}
function spm_handleScrollMenu(me, oMenu)
{
var oTbl = spm_getTags('table', oMenu)[0]; //oMenu.childNodes[1];
oMenu.style.display = '';
if (oMenu.scrollPos == null)
{
oMenu.scrollPos = 1;
var oRow = spm_insertTableRow(oTbl);
var oCell = document.createElement('TD');
oCell.id = 'dn' + oMenu.id.substring(3);
oCell.colSpan = 3;
oCell.align = 'center';
oCell.style.backgroundColor = 'gray'; //can be overridden by MenuScroll style
oCell.innerHTML='<div id="dn' + oMenu.id.substr(3) + '" onclick="return spm_ScrollMenuClick(this, event);" onmouseover="spm_ScrollMenuMO(this, m_oSolpartMenu[\'' + me._m_sNSpace + '\']);" onmouseout="spm_ScrollMenuMOUT(m_oSolpartMenu[\'' + me._m_sNSpace + '\']);" class="' + spm_fixCSSForMac(me.getIntCSSName('spmitmscr')) + ' ' + me.cssMenuScrollItem + '" style="width: 100%; font-size: 6pt;">...</div>';
oRow.appendChild(oCell);
oRow = spm_insertTableRow(oTbl, 0);
oCell = document.createElement('TD');
oCell.id = 'up' + oMenu.id.substring(3);
oCell.colSpan = 3;
oCell.align = 'center';
oCell.style.backgroundColor = 'gray'; //can be overridden by MenuScroll style
oCell.innerHTML='<div id="up' + oMenu.id.substr(3) + '" onclick="return spm_ScrollMenuClick(this, event);" onmouseover="spm_ScrollMenuMO(this, m_oSolpartMenu[\'' + me._m_sNSpace + '\']);" onmouseout="spm_ScrollMenuMOUT(m_oSolpartMenu[\'' + me._m_sNSpace + '\']);" class="' + spm_fixCSSForMac(me.getIntCSSName('spmitmscr')) + ' ' + me.cssMenuScrollItem + '" style="width: 100%; font-size: 6pt;">...</div>';
oRow.style.display = 'none';
oRow.appendChild(oCell);
}
if (oMenu.ScrollRowHeight == null)
{
spm_getTags('tr', oTbl)[0].style.display = '';
oMenu.ScrollItemHeight = (spm_getElementHeight(spm_getTags('tr', oTbl)[0]) * 2);
spm_getTags('tr', oTbl)[0].style.display = 'none';
oMenu.ScrollRowHeight = spm_getElementHeight(spm_getTags('tr', oTbl)[1]);
}
oMenu.scrollItems = parseInt((spm_getViewPortHeight() - spm_elementTop(oMenu) + spm_getBodyScrollTop() - oMenu.ScrollItemHeight) / (oMenu.ScrollRowHeight + 1));
//alert(oMenu.ScrollRowHeight);
//alert(oMenu.ScrollItemHeight);
spm_showScrolledItems(oMenu);
}
function spm_ScrollMenuMO(e, me)
{
me._m_dHideTimer = null;
me._m_oScrollingMenu = e;
if (Number(me.moScroll))
setTimeout('m_oSolpartMenu["' + me._m_sNSpace + '"].scrollMenu()', 500);
}
function spm_ScrollMenuMOUT(me)
{
me._m_oScrollingMenu = null;
me._m_dHideTimer = new Date();
if (me.moutDelay != 0)
setTimeout('m_oSolpartMenu["' + me._m_sNSpace + '"].hideMenuTime()', me.moutDelay);
}
function spm_ScrollMenuClick(e, evt)
{
if (e != null)
{
var oCell = e.parentNode;
var oTbl = oCell.parentNode.parentNode.parentNode;
var oMenu = oTbl.parentNode;
if (oCell.id == 'up' + oMenu.id.substring(3))
{
if (oMenu.scrollPos > 1)
oMenu.scrollPos--;
else
return true;
}
else
{
if (oMenu.scrollPos + oMenu.scrollItems < oTbl.rows.length - 1)
oMenu.scrollPos++;
else
return true;
}
spm_showScrolledItems(oMenu);
if (evt != null)
spm_stopEventBubbling(evt);
}
return false;
}
function spm_showScrolledItems(oMenu)
{
var oTbl = spm_getTags('table', oMenu)[0];
var oRows = spm_getTags('tr', oTbl); //oTbl.rows.length
for (var i=1; i < oRows.length; i++)
{
//if row is not within display "window" then don't display it
if (i < oMenu.scrollPos || i >= oMenu.scrollPos + oMenu.scrollItems)
oRows[i].style.display = 'none';
else
oRows[i].style.display = '';
}
// if we are scrolled down at least one then display up scroll item
if (oMenu.scrollPos > 1)
oRows[0].style.display = '';
else
oRows[0].style.display = 'none';
// if there is at least one item not displayed then show down item
if (oMenu.scrollPos + oMenu.scrollItems < oTbl.rows.length - 1)
oRows[oRows.length-1].style.display = '';
else
oRows[oRows.length-1].style.display = 'none';
}
function spm_insertTableRow(tbl, iPos)
{
var oRow;
var oTB;
oRow = document.createElement('TR');
if (tbl.getElementsByTagName('TBODY').length == 0)
{
oTB = document.createElement('TBODY');
tbl.appendChild(oTB);
}
else
oTB = tbl.getElementsByTagName('TBODY')[0];
if (iPos == null)
oTB.appendChild(oRow);
else
oTB.insertBefore(oRow, tbl.rows[iPos]);
return oRow;
}
function spm_getElementHeight(o)
{
if (o.offsetHeight == null || o.offsetHeight == 0)
{
if (o.offsetParent.offsetHeight == null || o.offsetParent.offsetHeight == 0)
{
if (o.offsetParent.offsetParent != null)
return o.offsetParent.offsetParent.offsetHeight; //needed for Konqueror
else
return 0;
}
else
return o.offsetParent.offsetHeight;
}
else
return o.offsetHeight;
}
function spm_getElementWidth(o)
{
if (o.offsetWidth == null || o.offsetWidth == 0)
{
if (o.offsetParent.offsetWidth == null || o.offsetParent.offsetWidth == 0)
{
if (o.offsetParent.offsetParent != null)
return o.offsetParent.offsetParent.offsetWidth; //needed for Konqueror
else
return 0;
}
else
return o.offsetParent.offsetWidth
}
else
return o.offsetWidth;
}
//viewport logic taken from http://dhtmlkitchen.com/js/measurements/index.jsp
function spm_getViewPortWidth()
{
// supported in Mozilla, Opera, and Safari
if(window.innerWidth)
return window.innerWidth;
// supported in standards mode of IE, but not in any other mode
if(window.document.documentElement.clientWidth)
return document.documentElement.clientWidth;
// supported in quirks mode, older versions of IE, and mac IE (anything else).
return window.document.body.clientWidth;
}
function spm_getBodyScrollTop()
{
if ('|ie|op|mo|ns|'.indexOf('|' + spm_browserType() + '|') != -1)
{
if (document.body.scrollTop != null)
return document.body.scrollTop;
}
return 0;
}
function spm_getBodyScrollLeft(bOverride)
{
if ('|op|'.indexOf('|' + spm_browserType() + '|') != -1 || bOverride == true)
{
if (document.body.scrollLeft != null)
{
return document.body.scrollLeft;
}
}
return 0;
}
function spm_getViewPortHeight()
{
// supported in Mozilla, Opera, and Safari
if(window.innerHeight)
return window.innerHeight;
// supported in standards mode of IE, but not in any other mode
if(window.document.documentElement.clientHeight)
return document.documentElement.clientHeight;
// supported in quirks mode, older versions of IE, and mac IE (anything else).
return window.document.body.clientHeight;
}
function spm_elementTop(eSrc, includeBody)
{
var iTop = 0;
var eParent;
eParent = eSrc;
while (eParent.tagName.toUpperCase() != "BODY")
{
// alert(eParent.outerHTML);
//if (confirm(eParent.offsetTop))
iTop += eParent.offsetTop;
eParent = eParent.offsetParent;
if (eParent == null)
break;
}
if (includeBody != null && eParent != null && (spm_browserType() == 'safari' || spm_browserType() == 'kq'))
iTop += eParent.offsetTop;
return iTop;
}
function spm_elementLeft(eSrc, includeBody)
{
var iLeft = 0;
var eParent;
eParent = eSrc;
while (eParent.tagName.toUpperCase() != "BODY")
{
//if (spm_isMac() && spm_browserType() == 'ie')
// iLeft += eParent.clientLeft;
//else
iLeft += eParent.offsetLeft;
eParent = eParent.offsetParent;
if (eParent == null)
break;
}
if (includeBody != null && eParent != null && (spm_browserType() == 'safari' || spm_browserType() == 'kq'))
iLeft += eParent.offsetLeft;
return iLeft;
}
function spm_getElement(e, sID)
{
var o=e;
var i=0;
while (o.id != sID)
{
o=o.parentNode;
i++;
}
return o;
}
function spm_getSourceTR(e, ns)
{
while (e.id == "")
{
e= e.parentElement;
}
if (e.id.indexOf("arrow") != -1)
{
var sID = e.id.substr(5);
return spm_getById("tr" + sID);
}
else if (e.id.indexOf("td") != -1)
{
var sID = e.id.substr(2);
return spm_getById("tr" + sID);
}
else if (e.id.indexOf("icon") != -1)
{
var sID = e.id.substr(4);
return spm_getById("tr" + sID);
}
else if (e.id.indexOf("img") != -1)
{
var sID = e.id.substr(3);
return spm_getById("tr" + sID);
}
else
{
return e;
}
}
function spm_itemHasChildren(sID, ns)
{
objTable = spm_getById(ns + "tbl" + sID);
if (objTable != null)
{
if (objTable.rows != null)
{
if (objTable.rows.length > 0)
return true;
else
return false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -