📄 spmenu.js
字号:
var oMenu = spm_getById("tbl" + sID);
//var oMenu = spm_getById("td" + sID);
if (oMenu != null)
{
if (oMenu.style.display == '')
{
this.hideAllMenus();
spm_showElement("SELECT");
}
else
{
spm_positionMenu(this, oMenu, oCell);
this.doTransition(oMenu);
oMenu.style.display = "";
this._m_aOpenMenuID[0] = sID;
spm_hideElement("SELECT",oMenu);
}
}
this.fireEvent('onMenuBarClick', oCell);
oMenu = spm_getById("td" + sID);
if (spm_getAttr(oMenu, "menuclick", '').length)
{
eval(spm_getAttr(oMenu, "menuclick", ''));
this.hideAllMenus();
}
spm_stopEventBubbling(evt);
}
//--- menubar mousedown event ---//
SolpartMenu.prototype.onMBMD = function (e)
{
var oCell = e; //event.srcElement;
this.applyBorder(oCell, 1, this.shColor, this.hlColor);
}
//--- menubar mouseup event ---//
SolpartMenu.prototype.onMBMU = function (e)
{
var oCell = e; //event.srcElement;
this.applyBorder(oCell, 1, this.hlColor, this.shColor);
}
//--- menubar mouseover event ---//
SolpartMenu.prototype.onMBMO = function (e)
{
var oCell = e; //event.srcElement;
if (oCell.id.length == 0) //cancelBubble
return;
var sID = oCell.id.substr(2);
var oMenu = spm_getById("tbl" + sID);
if (this._m_aOpenMenuID.length || this.moExpand != '0')
{
//--- if menu is shown then mouseover triggers the showing of all menus ---//
this.hideAllMenus();
if (oMenu != null)
{
spm_positionMenu(this, oMenu, oCell);
this.doTransition(oMenu);
oMenu.style.display = "";
this._m_aOpenMenuID[0] = sID;
spm_hideElement("SELECT",oMenu);
}
this.applyBorder(oCell, 1, this.shColor, this.hlColor);
}
else
{
this.applyBorder(oCell, 1, this.hlColor, this.shColor);
}
oCell.className = spm_fixCSSForMac(this.getIntCSSName('spmitmsel spmbar') + this.cssMenuBar + ' ' + this.cssMenuItemSel);
this._m_dHideTimer = null;
this.fireEvent('onMenuBarMouseOver', oCell);
}
//--- menubar mouseout event ---//
SolpartMenu.prototype.onMBMOUT = function (e)
{
var oCell = e; //event.srcElement;
var sID = oCell.id.substr(2);
this.applyBorder(oCell, 1, spm_getCellBackColor(oCell), spm_getCellBackColor(oCell), "none");
this._m_dHideTimer = new Date();
//setTimeout(this.hideMenuTime, this.moutDelay);
if (this.moutDelay != 0)
setTimeout('m_oSolpartMenu["' + this._m_sNSpace + '"].hideMenuTime()', this.moutDelay);
oCell.className = spm_fixCSSForMac(this.getIntCSSName('spmbar spmitm') + this.cssMenuBar + ' ' + this.cssMenuItem + spm_getAttr(e, 'savecss', ''));
this.stopTransition();
this.fireEvent('onMenuBarMouseOut', oCell);
}
//--- menuitem click ---//
SolpartMenu.prototype.onMBIC = function (e, evt)
{
var oRow = spm_getSourceTR(e, this._m_sNSpace); //event.srcElement
var sID = oRow.id.substr(2);
if (spm_itemHasChildren(sID, this._m_sNSpace) == false)
this.hideAllMenus();
this.fireEvent('onMenuItemClick', oRow);
if (spm_getAttr(oRow, "menuclick", '').length)
{
eval(spm_getAttr(oRow, "menuclick", ''));
this.hideAllMenus();
}
//window.event.cancelBubble = true;
spm_stopEventBubbling(evt);
}
//--- menuitem mouseover event ---//
SolpartMenu.prototype.onMBIMO = function (e)
{
this.handlembi_mo(spm_getSourceTR(e, this._m_sNSpace)); //event.srcElement
this._m_dHideTimer = null;
}
//--- menuitem mouseout event ---//
SolpartMenu.prototype.onMBIMOUT = function (e)
{
this.handlembi_mout(spm_getSourceTR(e, this._m_sNSpace)); //event.srcElement
this._m_dHideTimer = new Date;
//setTimeout(this.hideMenuTime, this.moutDelay);
if (this.moutDelay != 0)
setTimeout('m_oSolpartMenu["' + this._m_sNSpace + '"].hideMenuTime()', this.moutDelay);
}
/*
function menuhook_KeyPress()
{
//not yet
}
function menuhook_KeyDown()
{
//not yet
}
function menuhook_MenuFocus()
{
var tbl = event.srcElement;
mb_c(tbl.rows[0].cells[0]);
}
*/
/*
function __menuhook_MouseMove(e)
{
var iNewLeft=0, iNewTop = 0
if (this._m_bMoving)
{
if (spm_browserType() == 'ie')
{
// if ((event.button==1))
// {
this.hideAllMenus();
if (this._m_oTblMenuBar.startLeft == null)
this._m_oTblMenuBar.startLeft = this._m_oTblMenuBar.offsetLeft;
iNewLeft=event.clientX - this._m_oTblMenuBar.startLeft - 3;
this._m_oTblMenuBar.style.pixelLeft= iNewLeft;
if (this._m_oTblMenuBar.startTop == null)
this._m_oTblMenuBar.startTop = this._m_oTblMenuBar.offsetTop;
iNewTop=event.clientY - this._m_oTblMenuBar.startTop;
this._m_oTblMenuBar.style.pixelTop = iNewTop - 10;
event.returnValue = false
event.cancelBubble = true
// }
}
else
{
this.hideAllMenus();
if (this._m_oTblMenuBar.startLeft == null)
this._m_oTblMenuBar.startLeft = this._m_oTblMenuBar.offsetLeft;
iNewLeft=e.clientX - this._m_oTblMenuBar.startLeft - 3;
//if (iNewLeft<0)
// iNewLeft=0;
this._m_oTblMenuBar.style.left = iNewLeft;
if (this._m_oTblMenuBar.startTop == null)
this._m_oTblMenuBar.startTop = this._m_oTblMenuBar.offsetTop;
iNewTop=e.clientY - this._m_oTblMenuBar.startTop;
//if (iNewTop<0)
// iNewTop=0;
this._m_oTblMenuBar.style.top = iNewTop - 10;
}
}
}
function __menuhook_MouseDown()
{
this._m_bMoving = true;
}
function __menuhook_MouseUp()
{
this._m_bMoving = false;
}
function __document_MouseMove(e)
{
if (this._m_bMoving)
{
this.menuhook_MouseMove(e);
}
}
function __document_MouseDown()
{
//this._m_bMoving = null;
}
function __document_MouseUp()
{
this._m_bMoving=false;
}
*/
SolpartMenu.prototype.bodyclick = function()
{
this.hideAllMenus();
}
//--- handles display of newly opened menu ---//
SolpartMenu.prototype.handleNewItemSelect = function (sID)
{
var i;
var iNewLength=-1;
var bDeleteRest=false;
for (i=0; i<this._m_aOpenMenuID.length; i++)
{
if (bDeleteRest)
spm_getById("tbl" + this._m_aOpenMenuID[i]).style.display = "none";
if (this._m_aOpenMenuID[i] == this._m_sNSpace + sID)
{
bDeleteRest=true;
iNewLength = i;
}
}
if (iNewLength != -1)
this._m_aOpenMenuID.length = iNewLength+1;
}
//--- hides all menus that are currently displayed ---//
SolpartMenu.prototype.hideAllMenus = function ()
{
var i;
for (i=0; i<this._m_aOpenMenuID.length; i++)
{
spm_getById("tbl" + this._m_aOpenMenuID[i]).style.display = "none";
}
this._m_aOpenMenuID.length = 0;
spm_showElement("SELECT");
}
function SolpartMenuTransitionObject()
{
this.id=null;
this.stop = false;
}
//--- stops menu transition effect ---//
SolpartMenu.prototype.stopTransition = function ()
{
this.SolpartMenuTransitionObject.stop = true;
this.doFilter();
this.SolpartMenuTransitionObject = new SolpartMenuTransitionObject();
}
//--- starts menu transition effect ---//
SolpartMenu.prototype.doTransition = function (oMenu)
{
if (this.menuTransition == 'None' || spm_browserType() != 'ie')
return;
var sID = this.SolpartMenuTransitionObject.id;
switch (this.menuTransition)
{
case 'AlphaFade':
{
if (this.SolpartMenuTransitionObject.id != oMenu.id)
{
this.SolpartMenuTransitionObject.id = oMenu.id;
this.SolpartMenuTransitionObject.opacity = 0;
this.doFilter();
}
break;
}
case 'Wave':
{
if (this.SolpartMenuTransitionObject.id != oMenu.id)
{
this.SolpartMenuTransitionObject.id = oMenu.id;
this.SolpartMenuTransitionObject.phase = 0;
this.doFilter();
}
break;
}
case 'ConstantWave':
{
if (sID != oMenu.id)
{
this.SolpartMenuTransitionObject.id = oMenu.id;
this.SolpartMenuTransitionObject.phase = 0;
this.SolpartMenuTransitionObject.constant=true;
this.doFilter();
}
break;
}
case 'Inset': case 'RadialWipe': case 'Slide': case 'Spiral': case 'Stretch': case 'Strips': case 'Wheel': case 'GradientWipe': case 'Zigzag': case 'Barn': case 'Blinds': case 'Checkerboard': case 'Fade': case 'Iris': case 'RandomBars':
{
oMenu.filters('DXImageTransform.Microsoft.' + this.menuTransition).apply();
oMenu.filters('DXImageTransform.Microsoft.' + this.menuTransition).duration = this.menuTransitionLength;
oMenu.filters('DXImageTransform.Microsoft.' + this.menuTransition).play();
break;
}
}
}
//--- applys transition filter ---//
SolpartMenu.prototype.doFilter = function (bStop)
{
if (this.SolpartMenuTransitionObject.id == null)
return;
var o = spm_getById(this.SolpartMenuTransitionObject.id);
window.status = new Date();
switch (this.menuTransition)
{
case 'AlphaFade':
{
if (this.SolpartMenuTransitionObject.stop)
{
o.filters('DXImageTransform.Microsoft.Alpha').opacity = 100;
}
else
{
o.filters('DXImageTransform.Microsoft.Alpha').opacity = this.SolpartMenuTransitionObject.opacity;
if (this.SolpartMenuTransitionObject.opacity < 100)
{
setTimeout('m_oSolpartMenu["' + this._m_sNSpace + '"].doFilter()', 50);
this.SolpartMenuTransitionObject.opacity += (100/20* this.menuTransitionLength);
}
}
break;
}
case 'Wave': case 'ConstantWave':
{
if (this.SolpartMenuTransitionObject.stop)
{
o.filters("DXImageTransform.Microsoft.Wave").freq = 0;
o.filters("DXImageTransform.Microsoft.Wave").lightstrength = 0;
o.filters("DXImageTransform.Microsoft.Wave").strength = 0;
o.filters("DXImageTransform.Microsoft.Wave").phase = 0;
}
else
{
o.filters("DXImageTransform.Microsoft.Wave").freq = 1;
o.filters("DXImageTransform.Microsoft.Wave").lightstrength = 20;
o.filters("DXImageTransform.Microsoft.Wave").strength = 5;
o.filters("DXImageTransform.Microsoft.Wave").phase = this.SolpartMenuTransitionObject.phase;
if (this.SolpartMenuTransitionObject.phase < 100 * this.menuTransitionLength || this.SolpartMenuTransitionObject.constant == true)
{
setTimeout('m_oSolpartMenu["' + this._m_sNSpace + '"].doFilter()', 50);
this.SolpartMenuTransitionObject.phase += 5;
}
else
{
o.filters("DXImageTransform.Microsoft.Wave").freq = 0;
o.filters("DXImageTransform.Microsoft.Wave").lightstrength = 0;
o.filters("DXImageTransform.Microsoft.Wave").strength = 0;
o.filters("DXImageTransform.Microsoft.Wave").phase = 0;
}
}
break;
}
}
}
//--- handles mouseover for menu item ---//
SolpartMenu.prototype.handlembi_mo = function (oRow)
{
var sID = oRow.id.substr(2);
//oRow.className = 'spmitmsel';
spm_getById("icon" + sID).className = spm_fixCSSForMac(this.getIntCSSName('spmitmsel spmicn') + this.cssMenuIcon + ' ' + this.cssMenuItemSel);
spm_getById("td" + sID).className = spm_fixCSSForMac(this.getIntCSSName('spmitmsel') + this.cssMenuItemSel);
spm_getById("arrow" + sID).className = spm_fixCSSForMac(this.getIntCSSName('spmitmsel spmarw') + this.cssMenuItemSel + ' ' + this.cssMenuArrow);
//oRow.style.backgroundColor = this.selColor;
//oRow.style.color = this.selForeColor;
//oRow.style.color = this.selForeColor;
//setClassColor(oRow, 'spmitm', this.selForeColor);
//spm_getById("icon" + sID).style.backgroundColor = this.selColor;
spm_applyRowBorder(oRow, 1, this.selBorderColor, true);
//if (this._m_aOpenMenuID.join(',').indexOf(oRow.id.replace('tr', '')) == -1)
if (this._m_aOpenMenuID[this._m_aOpenMenuID.length - 1] != oRow.id.replace('tr', ''))
{
this.handleNewItemSelect(spm_getAttr(oRow, "parentID", ""));
if (spm_getById("tbl" + sID) != null)
{
oMenu = spm_getById("tbl" + sID);
//oMenu.style.position = "absolute"; //CSS FIX!
oMenu.style.left = spm_elementLeft(oRow) + oRow.offsetWidth;
oMenu.style.top = spm_elementTop(oRow);
this.doTransition(oMenu);
oMenu.style.display = "";
if (spm_elementLeft(oRow) + oRow.offsetWidth + oMenu.offsetWidth > document.body.clientWidth)
{
oMenu.style.left = spm_elementLeft(oRow) - oMenu.offsetWidth;
//oMenu.style.top = spm_elementTop(oRow);
}
if (spm_elementTop(oMenu) + oMenu.offsetHeight > document.body.clientHeight)
{
oMenu.style.top = document.body.clientHeight - oMenu.offsetHeight;
}
this._m_aOpenMenuID[this._m_aOpenMenuID.length] = sID;
spm_hideElement("SELECT",oMenu);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -