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

📄 jscookmenu.js

📁 this the oscommerce 3.0 aplha 4
💻 JS
📖 第 1 页 / 共 3 页
字号:
			{				item[0] = _cmNoAction;				item[1] = getActionHTML (currentItem);				hasAction = true;				break;			}			var tag = currentItem.tagName.toLowerCase ();			if (tag != 'span')				continue;			if (!currentItem.firstChild)				item[0] = null;			else				item[0] = currentItem.innerHTML;			currentItem = currentItem.nextSibling;			break;		}		if (hasAction)		{			items[items.length] = item;			continue;		}		if (!currentItem)			continue;		for (; currentItem; currentItem = currentItem.nextSibling)		{			if (!currentItem.tagName)				continue;			var tag = currentItem.tagName.toLowerCase ();			if (tag == 'a')			{				item[1] = currentItem.innerHTML;				item[2] = currentItem.href;				item[3] = currentItem.target;				item[4] = currentItem.title;				if (item[4] == '')					item[4] = null;			}			else if (tag == 'span' || tag == 'div')			{				item[1] = currentItem.innerHTML;				item[2] = null;				item[3] = null;				item[4] = null;			}			break;		}		for (; currentItem; currentItem = currentItem.nextSibling)		{			// scan for span tag			if (!currentItem.tagName)				continue;			var tag = currentItem.tagName.toLowerCase ();			if (tag != 'ul' && tag != 'ol')				continue;			var subMenuItems = cmDrawFromTextSubMenu (currentItem);			for (i = 0; i < subMenuItems.length; ++i)				item[i + 5] = subMenuItems[i];			break;		}		items[items.length] = item;	}	return items;}//// obtain the actual action item's action, which is inside a// table.  The first row should be it//function getActionHTML (htmlNode){	var returnVal = '<td></td><td></td><td></td>';	var currentDomItem;	// find the table first	for (currentDomItem = htmlNode.firstChild; currentDomItem; currentDomItem = currentDomItem.nextSibling)	{		if (currentDomItem.tagName && currentDomItem.tagName.toLowerCase () == 'table')			break;	}	if (!currentDomItem)		return returnVal;	// skip over tbody	for (currentDomItem = currentDomItem.firstChild; currentDomItem; currentDomItem = currentDomItem.nextSibling)	{		if (currentDomItem.tagName && currentDomItem.tagName.toLowerCase () == 'tbody')			break;	}	if (!currentDomItem)		return returnVal;	// get the first tr	for (currentDomItem = currentDomItem.firstChild; currentDomItem; currentDomItem = currentDomItem.nextSibling)	{		if (currentDomItem.tagName && currentDomItem.tagName.toLowerCase () == 'tr')			break;	}	if (!currentDomItem)		return returnVal;	return currentDomItem.innerHTML;}//// get the DOM object associated with the item//function cmGetMenuItem (item){	if (!item.subMenuID)		return null;	var subMenu = cmGetObject (item.subMenuID);	// we are dealing with a main menu item	if (item.menu)	{		var menu = item.menu;		// skip over table, tbody, tr, reach td		subMenu = subMenu.firstChild.firstChild.firstChild.firstChild;		var i;		for (i = 0; i < menu.length; ++i)		{			if (menu[i] == item)				return subMenu;			subMenu = subMenu.nextSibling;		}	}	else if (item.parentItem) // sub menu item	{		var menu = item.parentItem;		var table = cmGetObject (item.subMenuID + 'Table');		if (!table)			return null;		// skip over table, tbody, reach tr		subMenu = table.firstChild.firstChild;		var i;		for (i = 5; i < menu.length; ++i)		{			if (menu[i] == item)				return subMenu;			subMenu = subMenu.nextSibling;		}	}	return null;}//// disable a menu item//function cmDisableItem (item, prefix){	if (!item)		return;	var menuItem = cmGetMenuItem (item);	if (!menuItem)		return;	if (item.menu)		menuItem.className = prefix + 'MainItemDisabled';	else		menuItem.className = prefix + 'MenuItemDisabled';	item.isDisabled = true;}//// enable a menu item//function cmEnableItem (item, prefix){	if (!item)		return;	var menuItem = cmGetMenuItem (item);	if (!menuItem)		return;	if (item.menu)		menu.className = prefix + 'MainItem';	else		menu.className = prefix + 'MenuItem';	item.isDisabled = true;}////////////////////////////////////////////////////////////////////////// Mouse Event Handling Functions//////////////////////////////////////////////////////////////////////////// action should be taken for mouse moving in to the menu item//// Here we just do things concerning this menu item, w/o opening sub menus.//function cmItemMouseOver (obj, isMain, idSub, menuID, index, calledByOpenSub){	if (!calledByOpenSub && _cmClicked)	{		cmItemMouseOverOpenSub (obj, isMain, idSub, menuID, index);		return;	}	clearTimeout (_cmTimeOut);	if (_cmItemList[index].isDisabled)		return;	var prefix = _cmMenuList[menuID].prefix;	if (!obj.cmMenuID)	{		obj.cmMenuID = menuID;		obj.cmIsMain = isMain;	}	var thisMenu = cmGetThisMenu (obj, prefix);	// insert obj into cmItems if cmItems doesn't have obj	if (!thisMenu.cmItems)		thisMenu.cmItems = new Array ();	var i;	for (i = 0; i < thisMenu.cmItems.length; ++i)	{		if (thisMenu.cmItems[i] == obj)			break;	}	if (i == thisMenu.cmItems.length)	{		//thisMenu.cmItems.push (obj);		thisMenu.cmItems[i] = obj;	}	// hide the previous submenu that is not this branch	if (_cmCurrentItem)	{		// occationally, we get this case when user		// move the mouse slowly to the border		if (_cmCurrentItem == obj || _cmCurrentItem == thisMenu)		{			var item = _cmItemList[index];			cmSetStatus (item);			return;		}		var thatMenuInfo = _cmMenuList[_cmCurrentItem.cmMenuID];		var thatPrefix = thatMenuInfo.prefix;		var thatMenu = cmGetThisMenu (_cmCurrentItem, thatPrefix);		if (thatMenu != thisMenu.cmParentMenu)		{			if (_cmCurrentItem.cmIsMain)				_cmCurrentItem.className = thatPrefix + 'MainItem';			else				_cmCurrentItem.className = thatPrefix + 'MenuItem';			if (thatMenu.id != idSub)				cmHideMenu (thatMenu, thisMenu, thatMenuInfo);		}	}	// okay, set the current menu to this obj	_cmCurrentItem = obj;	// just in case, reset all items in this menu to MenuItem	cmResetMenu (thisMenu, prefix);	var item = _cmItemList[index];	var isDefaultItem = cmIsDefaultItem (item);	if (isDefaultItem)	{		if (isMain)			obj.className = prefix + 'MainItemHover';		else			obj.className = prefix + 'MenuItemHover';	}	cmSetStatus (item);}//// action should be taken for mouse moving in to the menu item//// This function also opens sub menu//function cmItemMouseOverOpenSub (obj, isMain, idSub, menuID, index){	clearTimeout (_cmTimeOut);	if (_cmItemList[index].isDisabled)		return;	cmItemMouseOver (obj, isMain, idSub, menuID, index, true);	if (idSub)	{		var subMenu = cmGetObject (idSub);		var menuInfo = _cmMenuList[menuID];		var orient = menuInfo.orient;		var prefix = menuInfo.prefix;		cmShowSubMenu (obj, isMain, subMenu, menuInfo);	}}//// action should be taken for mouse moving out of the menu item//function cmItemMouseOut (obj, isMain, idSub, menuID, index){	var delayTime = _cmMenuList[menuID].nodeProperties.delay;	_cmTimeOut = window.setTimeout ('cmHideMenuTime ()', delayTime);	window.defaultStatus = '';}//// action should be taken for mouse button down at a menu item//function cmItemMouseDown (obj, isMain, idSub, menuID, index){	if (_cmItemList[index].isDisabled)		return;	if (cmIsDefaultItem (_cmItemList[index]))	{		var prefix = _cmMenuList[menuID].prefix;		if (obj.cmIsMain)			obj.className = prefix + 'MainItemActive';		else			obj.className = prefix + 'MenuItemActive';	}}//// action should be taken for mouse button down at a menu item// this is one also opens submenu if needed//function cmItemMouseDownOpenSub (obj, isMain, idSub, menuID, index){	if (_cmItemList[index].isDisabled)		return;	_cmClicked = true;	cmItemMouseDown (obj, isMain, idSub, menuID, index);	if (idSub)	{		var subMenu = cmGetObject (idSub);		var menuInfo = _cmMenuList[menuID];		cmShowSubMenu (obj, isMain, subMenu, menuInfo);	}}//// action should be taken for mouse button up at a menu item//function cmItemMouseUp (obj, isMain, idSub, menuID, index){	if (_cmItemList[index].isDisabled)		return;	var item = _cmItemList[index];	var link = null, target = '_self';	if (item.length > 2)		link = item[2];	if (item.length > 3 && item[3])		target = item[3];	if (link != null)	{		_cmClicked = false;		window.open (link, target);	}	var menuInfo = _cmMenuList[menuID];	var prefix = menuInfo.prefix;	var thisMenu = cmGetThisMenu (obj, prefix);	var hasChild = (item.length > 5);	if (!hasChild)	{		if (cmIsDefaultItem (item))		{			if (obj.cmIsMain)				obj.className = prefix + 'MainItem';			else				obj.className = prefix + 'MenuItem';		}		cmHideMenu (thisMenu, null, menuInfo);	}	else	{		if (cmIsDefaultItem (item))		{			if (obj.cmIsMain)				obj.className = prefix + 'MainItemHover';			else				obj.className = prefix + 'MenuItemHover';		}	}}////////////////////////////////////////////////////////////////////////// Mouse Event Support Utility Functions//////////////////////////////////////////////////////////////////////////// move submenu to the appropriate location//function cmMoveSubMenu (obj, isMain, subMenu, menuInfo){	var orient = menuInfo.orient;	var offsetAdjust;	if (isMain)	{		if (orient.charAt (0) == 'h')			offsetAdjust = menuInfo.nodeProperties.offsetHMainAdjust;		else			offsetAdjust = menuInfo.nodeProperties.offsetVMainAdjust;	}	else		offsetAdjust = menuInfo.nodeProperties.offsetSubAdjust;	if (!isMain && orient.charAt (0) == 'h')		orient = 'v' + orient.charAt (1) + orient.charAt (2);	var mode = String (orient);	var p = subMenu.offsetParent;	var subMenuWidth = cmGetWidth (subMenu);	var horiz = cmGetHorizontalAlign (obj, mode, p, subMenuWidth);	if (mode.charAt (0) == 'h')	{		if (mode.charAt (1) == 'b')			subMenu.style.top = (cmGetYAt (obj, p) + cmGetHeight (obj) + offsetAdjust[1]) + 'px';		else			subMenu.style.top = (cmGetYAt (obj, p) - cmGetHeight (subMenu) - offsetAdjust[1]) + 'px';		if (horiz == 'r')			subMenu.style.left = (cmGetXAt (obj, p) + offsetAdjust[0]) + 'px';		else			subMenu.style.left = (cmGetXAt (obj, p) + cmGetWidth (obj) - subMenuWidth - offsetAdjust[0]) + 'px';	}	else	{		if (horiz == 'r')			subMenu.style.left = (cmGetXAt (obj, p) + cmGetWidth (obj) + offsetAdjust[0]) + 'px';		else			subMenu.style.left = (cmGetXAt (obj, p) - subMenuWidth - offsetAdjust[0]) + 'px';		if (mode.charAt (1) == 'b')			subMenu.style.top = (cmGetYAt (obj, p) + offsetAdjust[1]) + 'px';		else			subMenu.style.top = (cmGetYAt (obj, p) + cmGetHeight (obj) - cmGetHeight (subMenu) + offsetAdjust[1]) + 'px';	}	// IE specific iframe masking method	/*@cc_on		@if (@_jscript_version >= 5.5)			if (menuInfo.cmFrameMasking)			{				if (!subMenu.cmFrameObj)				{					var frameObj = cmAllocFrame ();					subMenu.cmFrameObj = frameObj;				}				var frameObj = subMenu.cmFrameObj;				frameObj.style.zIndex = subMenu.style.zIndex - 1;				frameObj.style.left = (cmGetX (subMenu) - cmGetX (frameObj.offsetParent)) + 'px';				frameObj.style.top = (cmGetY (subMenu)  - cmGetY (frameObj.offsetParent)) + 'px';				frameObj.style.width = cmGetWidth (subMenu) + 'px';				frameObj.style.height = cmGetHeight (subMenu) + 'px';				frameObj.style.display = 'block';			}		@end	@*/	if (horiz != orient.charAt (2))		orient = orient.charAt (0) + orient.charAt (1) + horiz;	return orient;}//// automatically re-adjust the menu position based on available screen size.//function cmGetHorizontalAlign (obj, mode, p, subMenuWidth){	var horiz = mode.charAt (2);	if (!(document.body))		return horiz;	var body = document.body;	var browserLeft;	var browserRight;	if (window.innerWidth)	{		// DOM window attributes		browserLeft = window.pageXOffset;		browserRight = window.innerWidth + browserLeft;	}	else if (body.clientWidth)	{		// IE attributes		browserLeft = body.clientLeft;		browserRight = body.clientWidth + browserLeft;	}	else		return horiz;	if (mode.charAt (0) == 'h')	{		if (horiz == 'r' && (cmGetXAt (obj) + subMenuWidth) > browserRight)			horiz = 'l';		if (horiz == 'l' && (cmGetXAt (obj) + cmGetWidth (obj) - subMenuWidth) < browserLeft)			horiz = 'r';		return horiz;	}	else	{		if (horiz == 'r' && (cmGetXAt (obj, p) + cmGetWidth (obj) + subMenuWidth) > browserRight)			horiz = 'l';		if (horiz == 'l' && (cmGetXAt (obj, p) - subMenuWidth) < browserLeft)			horiz = 'r';		return horiz;	}}//// show the subMenu w/ specified orientation// also move it to the correct coordinates//function cmShowSubMenu (obj, isMain, subMenu, menuInfo){	var prefix = menuInfo.prefix;	if (!subMenu.cmParentMenu)	{		// establish the tree w/ back edge		var thisMenu = cmGetThisMenu (obj, prefix);		subMenu.cmParentMenu = thisMenu;		if (!thisMenu.cmSubMenu)			thisMenu.cmSubMenu = new Array ();		thisMenu.cmSubMenu[thisMenu.cmSubMenu.length] = subMenu;	}	var effectInstance = subMenu.cmEffect;	if (effectInstance)		effectInstance.showEffect (true);	else	{		// position the sub menu only if we are not already showing the submenu		var orient = cmMoveSubMenu (obj, isMain, subMenu, menuInfo);		subMenu.cmOrient = orient;		var forceShow = false;		if (subMenu.style.visibility != 'visible' && menuInfo.nodeProperties.effect)		{			try			{				effectInstance = menuInfo.nodeProperties.effect.getInstance (subMenu, orient);				effectInstance.showEffect (false);			}

⌨️ 快捷键说明

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