티스토리 뷰


prototype.js

	function menuButtonMouseOver(event) {
	  var menuButton = $('api_menu_button');
	  var target = event.element();
	  if (target === menuButton || target.descendantOf(menuButton)) {
		$('api_menu').show();
	  }
	}

	function menuButtonMouseOut(event) {
	  var menuButton = $('api_menu_button');
	  var menu = $('api_menu');
	  var target = event.element(), related = event.relatedTarget || event.toElement;

	  if (related && (related === menu || related.descendantOf(menu))) return;
	  menu.hide();
	}

	function menuMouseOut(event) {
	  var menu = $('api_menu'), related = event.relatedTarget || event.toElement;
	  if (related && !related.descendantOf(menu)) {
		arguments.callee.timer = Element.hide.delay(0.5, menu);
	  } else {
		window.clearTimeout(arguments.callee.timer);
	  }
	}

	function menuItemMouseOver(event) {
	  var element = event.element();
	  if (element.tagName.toLowerCase() === 'a') {
		element.addClassName('highlighted');
	  }
	}

	function menuItemMouseOut(event) {
	  var element = event.element();
	  if (element.tagName.toLowerCase() === 'a') {
		element.removeClassName('highlighted');
	  }
	}

	var MENU_ITEMS;

	document.observe('dom:loaded', function() {
	  MENU_ITEMS = $$('.api-box .menu-item a');

	  $('api_menu_button').observe('mouseenter', menuButtonMouseOver);
	  $('api_menu_button').observe('mouseleave', menuButtonMouseOut );

	  $('api_menu').observe('mouseleave', menuMouseOut);

	  if (Prototype.Browser.IE) {
		$('api_menu').observe('mouseover', menuItemMouseOver);
		$('api_menu').observe('mouseout',  menuItemMouseOut);
	  }
	});


전체소스:
구현된곳: http://scripty2.com/doc/
댓글