📄 spmenu.js
字号:
}
}
this.fireEvent('onMenuItemMouseOver', oRow);
}
//--- handles mouseout for menu item ---//
SolpartMenu.prototype.handlembi_mout = function (oRow)
{
var sID = oRow.id.substr(2);
//oRow.style.backgroundColor = this.backColor;
//oRow.style.color = this.foreColor;
//oRow.style.color = '';
//setClassColor(oRow, 'spmitm', '');
oRow.className = spm_fixCSSForMac(this.getIntCSSName('spmitm') + this.cssMenuItem + spm_getAttr(oRow, 'savecss', ''));
spm_getById("icon" + sID).className = spm_fixCSSForMac(this.getIntCSSName('spmicn') + this.cssMenuIcon);
spm_getById("td" + sID).className = spm_fixCSSForMac(this.getIntCSSName('spmitm') + this.cssMenuItem + spm_getAttr(oRow, 'savecss', ''));
spm_getById("arrow" + sID).className = spm_fixCSSForMac(this.getIntCSSName('spmarw') + this.cssMenuArrow);
//spm_getById("icon" + sID).style.backgroundColor = this.iconBackColor;
spm_applyRowBorder(oRow, 1, "", false);
this.stopTransition();
}
//used for raising events to client javascript
SolpartMenu.prototype.fireEvent = function (sEvent, src)
{
return; //disabled for now
if (eval('this.' + sEvent + ' != null'))
{
var e = new Object();
if (src != null)
e.srcElement = src;
else
e.srcElement = this._m_oMenu;
eval('this.' + sEvent + '(e)');
}
}
//--- called by setTimeOut to check mouseout hide delay ---//
SolpartMenu.prototype.hideMenuTime = function ()
{
if (this._m_dHideTimer != null && this.moutDelay > 0)
{
if (new Date() - this._m_dHideTimer >= this.moutDelay)
{
this.hideAllMenus();
this._m_dHideTimer = null;
}
else
setTimeout(this.hideMenuTime, this.moutDelay);
}
}
/*
function setClassColor(oCtl, sClass, sColor)
{
var o;
for (var i=0; i<oCtl.childNodes.length; i++)
{
o = oCtl.childNodes[i];
if (o.className == sClass)
o.style.color = sColor;
if (o.childNodes.length)
setClassColor(o, sClass, sColor)
}
}
*/
//global
function spm_showElement(elmID)
{
// Display any element that was hidden
for (i = 0; i < spm_getTags(elmID).length; i++)
{
obj = spm_getTags(elmID)[i];
if (! obj || ! obj.offsetParent)
continue;
obj.style.visibility = "";
}
}
function spm_hideElement(elmID, eMenu)
{
var obj;
// Hide any element that overlaps with the dropdown menu
for (i = 0; i < spm_getTags(elmID).length; i++)
{
obj = spm_getTags(elmID)[i];
if (spm_elementTop(obj) > parseInt(eMenu.style.top) + eMenu.offsetHeight)
{
//if element is below bottom of menu then do nothing
}
else if (spm_elementLeft(obj) > parseInt(eMenu.style.left) + eMenu.offsetWidth)
{
//if element is to the right of menu then do nothing
}
else if (spm_elementLeft(obj) + obj.offsetWidth < parseInt(eMenu.style.left))
{
//if element is to the left of menu then do nothing
}
else if (spm_elementTop(obj) + obj.offsetHeight < parseInt(eMenu.style.top))
{
//if element is to the top of menu then do nothing
}
else
{
obj.style.visibility = "hidden";
}
}
}
function spm_positionMenu(me, oMenu, oCell)
{
if (me.display == 'vertical')
{
oMenu.style.left = spm_elementLeft(oCell) + oCell.offsetWidth;
oMenu.style.top = spm_elementTop(oCell);
oMenu.style.display = "";
}
else
{
oMenu.style.left = spm_elementLeft(oCell);
oMenu.style.top = spm_elementTop(oCell) + oCell.offsetHeight;
oMenu.style.display = "";
if (spm_elementLeft(oMenu) + oMenu.offsetWidth > document.body.clientWidth)
{
if (document.body.clientWidth - oMenu.offsetWidth > 0) //only do this if it fits
oMenu.style.left = document.body.clientWidth - oMenu.offsetWidth;
// oMenu.style.top = spm_elementTop(oCell) + oCell.offsetHeight;
}
if (spm_elementTop(oMenu) + oMenu.offsetHeight > document.body.clientHeight)
{
if (spm_elementTop(oCell) - oMenu.offsetHeight > 0) //only do this if it fits
oMenu.style.top = spm_elementTop(oCell) - oMenu.offsetHeight;
}
oMenu.style.display = "none";
}
}
//--------- Internal (private) Functions --------//
//--- Applies border to cell ---//
SolpartMenu.prototype.applyBorder = function (oCell, iSize, sTopLeftColor, sBottomRightColor, sStyle)
{
if (this.moDisplay == 'Outset')
{
if (sStyle == null)
sStyle = "solid";
if (sTopLeftColor.length > 0 && sBottomRightColor.length > 0)
{
if (oCell.tagName == 'TR')
oCell = oCell.childNodes(0);
oCell.style.borderTop = sStyle + " " + iSize + "px " + sTopLeftColor;
oCell.style.borderLeft = sStyle + " " + iSize + "px " + sTopLeftColor;
oCell.style.borderRight = sStyle + " " + iSize + "px " + sBottomRightColor;
oCell.style.borderBottom = sStyle + " " + iSize + "px " + sBottomRightColor;
}
}
if (this.moDisplay == 'HighLight')
{
if (sTopLeftColor == this.backColor)
{
//oCell.style.backgroundColor = '';
//setClassColor(oCell, 'spmitm', '');
oCell.className = spm_fixCSSForMac(this.getIntCSSName('spmbar spmitm') + this.cssMenuItem + spm_getAttr(oCell, 'savecss', ''));
}
else
{
//oCell.style.backgroundColor = this.selColor;
//setClassColor(oCell, 'spmitm', this.selForeColor);
oCell.className = spm_fixCSSForMac(this.getIntCSSName('spmbar spmitmsel') + this.cssMenuItemSel);
}
}
}
function spm_applyRowBorder(oRow, iSize, sColor, bSelected, sStyle)
{
var sColor2=sColor;
if (sStyle == null)
sStyle = "solid";
if (sColor == "")
{
//if (bSelected)
// sColor2 = this.selColor;
//else
sColor2 = spm_getCurrentStyle(oRow.cells[0], 'background-Color');
}
spm_applyBorders(oRow.cells[0], sStyle, iSize, sColor2, true, true, false, true);
if (sColor == "" && bSelected == false)
sColor2 = spm_getCellBackColor(oRow.cells[1]);
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_elementTop(eSrc)
{
if (isMac())
return spm_elementTopMac(eSrc);
var iTop = 0;
var eParent;
eParent = eSrc;
while (eParent.tagName.toUpperCase() != "BODY")
{
iTop += eParent.offsetTop;
eParent = eParent.offsetParent;
if (eParent == null)
break;
}
return iTop;
}
function spm_elementTopMac(eSrc)
{
var iTop = 0;
var eParent;
var sDebug = new Array();
eParent = eSrc;
while (eParent.tagName.toUpperCase() != "BODY")
{
if ((eParent.tagName=="TABLE") && (eParent.offsetParent.tagName=="TD"))
{
iTop += eParent.clientTop;
sDebug[sDebug.length] = eParent.tagName + ' clientTop: ' + eParent.clientTop + ' offsetTop: ' + eParent.offsetTop + ' total: ' + iTop;
}
else//else if (eParent.tagName == 'TD') // iTop += eParent.parentElement.offsetTop;
{
iTop += eParent.offsetTop;
sDebug[sDebug.length] = eParent.tagName + ' offsetTop: ' + eParent.offsetTop + ' clientTop: ' + eParent.clientTop + ' total: ' + iTop;
}
eParent = eParent.offsetParent;
if (eParent == null)
break;
}
displayDebug(sDebug);
return iTop;
}
function spm_elementLeft(eSrc)
{
if (isMac())
return spm_elementLeftMac(eSrc);
var iLeft = 0;
var eParent;
eParent = eSrc;
while (eParent.tagName.toUpperCase() != "BODY")
{
iLeft += eParent.offsetLeft;
eParent = eParent.offsetParent;
if (eParent == null)
break;
}
return iLeft;
}
function spm_elementLeftMac(eSrc)
{
var iLeft = 0;
var eParent;
var sDebug = new Array();
eParent = eSrc;
while (eParent.tagName.toUpperCase() != "BODY")
{
if ((eParent.tagName=="TABLE") && (eParent.offsetParent.tagName=="TD"))
{
iLeft += eParent.clientLeft;
sDebug[sDebug.length] = eParent.tagName + ' clientLeft: ' + eParent.clientLeft + ' offsetLeft: ' + eParent.offsetLeft + ' total: ' + iLeft;
}
else
{
iLeft += eParent.offsetLeft;
sDebug[sDebug.length] = eParent.tagName + ' offsetLeft: ' + eParent.offsetLeft + ' clientLeft: ' + eParent.clientLeft + ' total: ' + iLeft;
}
eParent = eParent.offsetParent;
}
displayDebug(sDebug);
return iLeft;
}
function displayDebug(sDebug)
{
var sDebugDisp=''
var sIndent='-----------------------------------------';
for (var i=sDebug.length-1; i>=0; i--)
{
sDebugDisp += sIndent.substr(0, sDebug.length - i) + sDebug[i] + '\n';
}
alert(sDebugDisp);
}
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;
}
}
}
function spm_getMenuItemStyle(sType, oNode)
{
return spm_getAttr(oNode, sType + "style", '');
}
function spm_getMenuItemCSS(oNode)
{
return spm_getAttr(oNode, "css", '');
}
SolpartMenu.prototype.getIntCSSName = function(sClass)
{
var ary = sClass.split(' ');
var s='';
for (var i=0; i<ary.length; i++)
s += this._m_sNSpace.toLowerCase() + '_' + ary[i] + ' ';
return s;
}
function spm_fixCSSForMac(s)
{
var ary = s.split(' ');
var sRet='';
for (var i=0; i<ary.length; i++)
{
if (ary[i].rtrim().length > 0)
{
if (sRet.length)
sRet += ' ' + ary[i];
else
sRet = ary[i];
}
}
//alert("'" + s + "'\n'" + sRet + "'");
return sRet;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -