⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spmenu.js

📁 一种Portal的实现源码
💻 JS
📖 第 1 页 / 共 5 页
字号:
		  else
			  sID = "";


  __db(sID + ' getmenuitems');
			sClickAction = spm_getMenuClickAction(oNode, this);


		  if (sParentID == "-1")	//'if top level menu item
		  {
		
			  if (this.display == "vertical")
				  sHTML += "<tr>\n"; //'if vertical display then add rows for each top menuitem
  			
  			if (oNode.nodeName == 'menubreak')
  			{
					if (this.display == "vertical")
						sHTML += "<tr>\n"; //'if vertical display then add rows for each top menuitem

 					sHTML += '   <td style="height: 1px" class="' + spm_fixCSSForMac(this.getIntCSSName('spmicn') + this.cssMenuIcon) + '">' + spm_getMenuImage('spacer.gif', this, true, ' ') + '</td>\n<td colspan="2" class="' + spm_fixCSSForMac(this.getIntCSSName('spmbrk') + this.cssMenuBreak) + '">' + spm_getMenuImage('spacer.gif', this, true, ' ') + '</td>\n';

					if (this.display == "vertical")
						sHTML += "</tr>\n";
  			}
  			else
  			{
					sHTML += '<td>\n<table width="100%" CELLPADDING="0" CELLSPACING="0">\n<tr id="td' + this._m_sNSpace + sID + '" ' + spm_getMenuBarEvents(this._m_sNSpace) + '  class="' + spm_fixCSSForMac(this.getIntCSSName('spmbar spmitm') + this.cssMenuBar + ' ' + this.cssMenuItem + ' ' + spm_getMenuItemCSS(oNode)) + '" savecss="' + spm_getMenuItemCSS(oNode) + '" menuclick="' + sClickAction + '" style="' + spm_getMenuItemStyle('item', oNode) + '">\n';
					var sAlign = this.display=='vertical' ? 'align="' + this.menuAlignment + '"' : '';
					sHTML += '<td NOWRAP="NOWRAP" ' + sAlign + ' TITLE="' + spm_getAttr(oNode, 'tooltip', '') + '">' + spm_getImage(oNode, this) + spm_getItemHTML(oNode, 'left', '&nbsp;') + spm_getAttr(oNode, 'title', '') + spm_getItemHTML(oNode, 'right') + MyIIf(Number(this.rootArrow) && spm_nodeHasChildren(oNode), '</td>\n<td align="right" class="' + spm_fixCSSForMac(this.getIntCSSName('spmrarw') + this.cssMenuRootArrow) + '">' + spm_getArrow(this.rootArrowImage, this) + "", '&nbsp;') + '\n</td>\n</tr>\n</table>\n</td>\n';
				}
				  	    
			  if (this.display == "vertical")
				  sHTML += "</tr>\n";
		  
		 
		  }
		  else                        //'submenu - not top level menu item
		  {
			  switch(oNode.nodeName)
			  {
				  case "menuitem":
				  {
					  sHTML +=		'   <tr ID="tr' + this._m_sNSpace + sID + '" ' + spm_getMenuItemEvents(this._m_sNSpace) + ' parentID="' + sParentID + '" class="' + spm_fixCSSForMac(this.getIntCSSName('spmitm') + this.cssMenuItem + ' ' + spm_getMenuItemCSS(oNode)) + '" savecss="' + spm_getMenuItemCSS(oNode) + '" menuclick="' + sClickAction + '" style="' + spm_getMenuItemStyle('item', oNode) + '">\n';
					  sHTML +=		'       <td id="icon' + this._m_sNSpace + sID + '" class="' + spm_fixCSSForMac(this.getIntCSSName('spmicn') + this.cssMenuIcon) + '" style="' + spm_getMenuItemStyle('image', oNode) + '; ' + spm_getMenuItemStyle('item', oNode) + '">' + spm_getImage(oNode, this) + '</td>\n';
					  sHTML +=		'       <td id="td' + this._m_sNSpace + sID + '" class="' + spm_fixCSSForMac(this.getIntCSSName('spmitm') + this.cssMenuItem + ' ' + spm_getMenuItemCSS(oNode)) + '" savecss="' + spm_getMenuItemCSS(oNode) + '" NOWRAP="NOWRAP" TITLE="' + spm_getAttr(oNode, 'tooltip', '') + '" style="' + spm_getMenuItemStyle('item', oNode) + '">' + spm_getItemHTML(oNode, 'left', '') + spm_getAttr(oNode, 'title', '') + spm_getItemHTML(oNode, 'right', '') + '</td>\n';
					  sHTML +=		'       <td id="arrow' + this._m_sNSpace + sID + '" width="15px" CLASS="' + spm_fixCSSForMac(this.getIntCSSName('spmarw') + this.cssMenuArrow) + '" style="' + spm_getMenuItemStyle('item', oNode) + '">' + MyIIf(spm_nodeHasChildren(oNode), spm_getArrow(this.arrowImage, this), spm_getSpacer(this)) + '</td>\n';
					  sHTML +=		'   </tr>\n';

					  break;
				  }
				  case "menubreak":
				  {
						sHTML += '   <tr>\n<td style="height: 1px" class="' + spm_fixCSSForMac(this.getIntCSSName('spmicn') + this.cssMenuIcon) + '">' + spm_getMenuImage('spacer.gif', this, true, ' ') + '</td>\n<td colspan="2" class="' + spm_fixCSSForMac(this.getIntCSSName('spmbrk') + this.cssMenuBreak) + '">' + spm_getMenuImage('spacer.gif', this, true, ' ') + '</td>\n</tr>\n';

					  break;
				  }
			  }
		  }

		  //'Generate sub menu - note: we are recursively calling ourself
		  //'netscape renders tables with display: block as having cellpadding!!! therefore using div outside table - LAME!
		  if (oNode.childNodes.length > 0)
			  this._m_sOuterTables = '\n<DIV src="" ID="tbl' + this._m_sNSpace + sID + '" CLASS="' + spm_fixCSSForMac(this.getIntCSSName('spmsub') + this.cssSubMenu) + '" STYLE="display:none; position: absolute;' + this.menuTransitionStyle + '">\n<table CELLPADDING="0" CELLSPACING="0">\n' + this.GetMenuItems(oNode) + '\n</table>\n</DIV>\n' + this._m_sOuterTables;

    }
	}
	return sHTML;
}

	//--------------- Event Functions ---------------//
  //--- menubar click event ---//
	SolpartMenu.prototype.onMBC = function (e, evt)
	{
		this.GenerateSubMenus();

		var oCell = e; //event.srcElement;
		var sID = oCell.id.substr(2);

		var oMenu = spm_getById("tbl" + sID);
    //var oMenu = spm_getById("td" + sID);
		
		if (oMenu != null)
		{
			if (oMenu.style.display == '')
			{
				this.hideAllMenus();		
				if (this.useIFrames)
					spm_iFrameIndex(oMenu, false);
				else
					spm_showElement("SELECT|OBJECT");
			}
			else
			{
				spm_positionMenu(this, oMenu, oCell);
				
				this.doTransition(oMenu);
				oMenu.style.display = "";
				this._m_aOpenMenuID[0] = sID;
				if (this.useIFrames)
					spm_iFrameIndex(oMenu, true);
				else
					spm_hideElement("SELECT|OBJECT",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)
	{
		this.GenerateSubMenus();
		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;
				if (this.useIFrames)
					spm_iFrameIndex(oMenu, true);
				else
					spm_hideElement("SELECT|OBJECT",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();

		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&lt;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&lt;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.useIFrames)
					spm_iFrameIndex(spm_getById("tbl" + this._m_aOpenMenuID[i]), false);
			}
			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;
		var oMenu;
		for (i=0; i<this._m_aOpenMenuID.length; i++)
		{		
			oMenu = spm_getById("tbl" + this._m_aOpenMenuID[i]);
			oMenu.style.display = "none";

			if (this.useIFrames)
				spm_iFrameIndex(oMenu, false);
		}
		if (this.useIFrames != true)
			spm_showElement("SELECT|OBJECT");

		this._m_aOpenMenuID.length = 0;
	}		
  
  
  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' || this.supportsTransitions == '0')
      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;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -