PageSourceSearch

https://www.ima.or.jp/en/usr-data/template/ima-top-en_13/js/ddsmoothmenu/ddsmoothmenu.js

js ima.or.jp collected 2026-09-25 04:07:43 UTC 10,904 bytes, 203 lines download raw bytes

1//** Smooth Navigational Menu- By Dynamic Drive DHTML code library: http://www.dynamicdrive.com
2//** Script Download/ instructions page: http://www.dynamicdrive.com/dynamicindex1/ddlevelsmenu/
3//** Menu created: Nov 12, 2008
4
5//** Dec 12th, 08" (v1.01): Fixed Shadow issue when multiple LIs within the same UL (level) contain sub menus: http://www.dynamicdrive.com/forums/showthread.php?t=39177&highlight=smooth
6
7//** Feb 11th, 09" (v1.02): The currently active main menu item (LI A) now gets a CSS class of ".selected", including sub menu items.
8
9//** May 1st, 09" (v1.3):
10//** 1) Now supports vertical (side bar) menu mode- set "orientation" to 'v'
11//** 2) In IE6, shadows are now always disabled
12
13//** July 27th, 09" (v1.31): Fixed bug so shadows can be disabled if desired.
14//** Feb 2nd, 10" (v1.4): Adds ability to specify delay before sub menus appear and disappear, respectively. See showhidedelay variable below
15
16//** Dec 17th, 10" (v1.5): Updated menu shadow to use CSS3 box shadows when the browser is FF3.5+, IE9+, Opera9.5+, or Safari3+/Chrome. Only .js file changed.
17
18var ddsmoothmenu={
19
20//Specify full URL to down and right arrow images (23 is padding-right added to top level LIs with drop downs):
21arrowimages: {down:['downarrowclass', 'down.gif', 23], right:['rightarrowclass', 'right.gif']},
22transition: {overtime:300, outtime:300}, //duration of slide in/ out animation, in milliseconds
23shadow: {enable:false, offsetx:5, offsety:5}, //enable shadow?
24showhidedelay: {showdelay: 100, hidedelay: 200}, //set delay in milliseconds before sub menus appear and disappear, respectively
25
26///////Stop configuring beyond here///////////////////////////
27
28detectwebkit: navigator.userAgent.toLowerCase().indexOf("applewebkit")!=-1, //detect WebKit browsers (Safari, Chrome etc)
29detectie6: document.all && !window.XMLHttpRequest,
30css3support: false, //window.msPerformance || (!document.all && document.querySelector), //detect browsers that support CSS3 box shadows (ie9+ or FF3.5+, Safari3+, Chrome etc)
31
32getajaxmenu:function($, setting){ //function to fetch external page containing the panel DIVs
33	var $menucontainer=$('#'+setting.contentsource[0]) //reference empty div on page that will hold menu
34	$menucontainer.html("Loading Menu...")
35	$.ajax({
36		url: setting.contentsource[1], //path to external menu file
37		async: true,
38		error:function(ajaxrequest){
39			$menucontainer.html('Error fetching content. Server Response: '+ajaxrequest.responseText)
40		},
41		success:function(content){
42			$menucontainer.html(content)
43			ddsmoothmenu.buildmenu($, setting)
44		}
45	})
46},
47
48
49buildmenu:function($, setting){
50	var smoothmenu=ddsmoothmenu
51	var $mainmenu=$("#"+setting.mainmenuid+">ul") //reference main menu UL
52	$mainmenu.parent().get(0).className=setting.classname || "ddsmoothmenu"
53	var $headers=$mainmenu.find("ul").parent()
54	$headers.hover(
55		function(e){
56			$(this).children('a:eq(0)').addClass('selected')
57		},
58		function(e){
59			$(this).children('a:eq(0)').removeClass('selected')
60		}
61	)
62	$headers.each(function(i){ //loop through each LI header
63		var $curobj=$(this).css({zIndex: 100-i}) //reference current LI header
64		var $subul=$(this).find('ul:eq(0)').css({display:'block'})
65		$subul.data('timers', {})
66		this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()}
67		this.istopheader=$curobj.parents("ul").length==1? true : false //is top level header?
68		$subul.css({top:this.istopheader && setting.orientation!='v'? this._dimensions.h+"px" : 0})
69		/*
70		$curobj.children("a:eq(0)").css(this.istopheader? {paddingRight: smoothmenu.arrowimages.down[2]} : {}).append( //add arrow images
71			'<img src="'+ (this.istopheader && setting.orientation!='v'? smoothmenu.arrowimages.down[1] : smoothmenu.arrowimages.right[1])
72			+'" class="' + (this.istopheader && setting.orientation!='v'? smoothmenu.arrowimages.down[0] : smoothmenu.arrowimages.right[0])
73			+ '" style="border:0;" />'
74		)*/
75		if (smoothmenu.shadow.enable && !smoothmenu.css3support){ //if shadows enabled and browser doesn't support CSS3 box shadows
76			this._shadowoffset={x:(this.istopheader?$subul.offset().left+smoothmenu.shadow.offsetx : this._dimensions.w), y:(this.istopheader? $subul.offset().top+smoothmenu.shadow.offsety : $curobj.position().top)} //store this shadow's offsets
77			if (this.istopheader)
78				$parentshadow=$(document.body)
79			else{
80				var $parentLi=$curobj.parents("li:eq(0)")
81				$parentshadow=$parentLi.get(0).$shadow
82			}
83			this.$shadow=$('<div class="ddshadow'+(this.istopheader? ' toplevelshadow' : '')+'"></div>').prependTo($parentshadow).css({left:this._shadowoffset.x+'px', top:this._shadowoffset.y+'px'})  //insert shadow DIV and set it to parent node for the next shadow div
84		}
85		$curobj.hover(
86			function(e){
87				var $targetul=$subul //reference UL to reveal
88				var header=$curobj.get(0) //reference header LI as DOM object
89
90	//li
91	var lleft = $($targetul.children().get(0)).css("padding-left").replace("px","");
92	var lright = $($targetul.children().get(0)).css("padding-right").replace("px","");
93	var lleftb = $($targetul.children().get(0)).css("margin-left").replace("px","");
94	var lrightb = $($targetul.children().get(0)).css("margin-right").replace("px","");
95	var lleftm = $($targetul.children().get(0)).css("border-left-width").replace("px","");
96	var lrightm = $($targetul.children().get(0)).css("border-right-width").replace("px","");
97	//li>a
98	var left = $($targetul.children().children().get(0)).css("padding-left").replace("px","");
99	var right = $($targetul.children().children().get(0)).css("padding-right").replace("px","");
100	var leftb = $($targetul.children().children().get(0)).css("margin-left").replace("px","");
101	var rightb = $($targetul.children().children().get(0)).css("margin-right").replace("px","");
102	var leftm = $($targetul.children().children().get(0)).css("border-left-width").replace("px","");
103	var rightm = $($targetul.children().children().get(0)).css("border-right-width").replace("px","");
104	var max = 0;
105	var maxWidth = 0;
106	if (typeof document.documentElement.style.maxHeight != "undefined") {
107		$targetul.css({display:'block', opacity: 0, width:"1000"});
108	}else{
109		$targetul.css({display:'block', opacity: 0});
110	}
111
112	$targetul.children().children().each(function(){
113       if(max < $(this).width()){
114            max = $(this).width();
115        }
116    });
117	if(lleft=="") lleft = 0;
118	if(lright=="") lright = 0;
119	if(lleftb=="") lleftb = 0;
120	if(lrightb=="") lrightb = 0;
121	if(lleftm=="") lleftm = 0;
122	if(lrightm=="") lrightm = 0;
123	if(left=="") left = 0;
124	if(right=="") right = 0;
125	if(leftb=="") leftb = 0;
126	if(rightb=="") rightb = 0;
127	if(leftm=="") leftm = 0;
128	if(rightm=="") rightm = 0;
129	maxWidth= max+~~lleft+~~lright+~~lleftb+~~lrightb+~~lleftm+~~lrightm+~~left+~~right+~~leftb+~~rightb+~~leftm+~~rightm;
130	$targetul.css({display:'none', opacity: 1});
131
132				clearTimeout($targetul.data('timers').hidetimer)
133				$targetul.data('timers').showtimer=setTimeout(function(){
134					header._offsets={left:$curobj.offset().left, top:$curobj.offset().top}
135					var menuleft=header.istopheader && setting.orientation!='v'? 0 : header._dimensions.w
136					menuleft=(header._offsets.left+menuleft+header._dimensions.subulw>$(window).width())? (header.istopheader && setting.orientation!='v'? -header._dimensions.subulw+header._dimensions.w : -header._dimensions.w) : menuleft //calculate this sub menu's offsets from its parent
137					if ($targetul.queue().length<=1){ //if 1 or less queued animations
138						$targetul.css({left:menuleft+"px", width:header._dimensions.subulw+'px'}).animate({height:'show',opacity:'show'}, ddsmoothmenu.transition.overtime)
139//$targetul.children().css({width:header._dimensions.subulw+'px'});
140						$targetul.css({left:menuleft+"px", width:maxWidth+'px'}).animate({height:'show',opacity:'show'}, ddsmoothmenu.transition.overtime)
141$targetul.children().css({width:maxWidth+'px'});
142$targetul.children().children().css({width:max+'px'});
143
144
145						if (smoothmenu.shadow.enable && !smoothmenu.css3support){
146							var shadowleft=header.istopheader? $targetul.offset().left+ddsmoothmenu.shadow.offsetx : menuleft
147							var shadowtop=header.istopheader?$targetul.offset().top+smoothmenu.shadow.offsety : header._shadowoffset.y
148							if (!header.istopheader && ddsmoothmenu.detectwebkit){ //in WebKit browsers, restore shadow's opacity to full
149								header.$shadow.css({opacity:1})
150							}
151							header.$shadow.css({overflow:'', width:header._dimensions.subulw+'px', left:shadowleft+'px', top:shadowtop+'px'}).animate({height:header._dimensions.subulh+'px'}, ddsmoothmenu.transition.overtime)
152						}
153					}
154				}, ddsmoothmenu.showhidedelay.showdelay)
155			},
156			function(e){
157				var $targetul=$subul
158				var header=$curobj.get(0)
159				clearTimeout($targetul.data('timers').showtimer)
160				$targetul.data('timers').hidetimer=setTimeout(function(){
161					$targetul.animate({height:'hide', opacity:'hide'}, ddsmoothmenu.transition.outtime)
162					if (smoothmenu.shadow.enable && !smoothmenu.css3support){
163						if (ddsmoothmenu.detectwebkit){ //in WebKit browsers, set first child shadow's opacity to 0, as "overflow:hidden" doesn't work in them
164							header.$shadow.children('div:eq(0)').css({opacity:0})
165						}
166						header.$shadow.css({overflow:'hidden'}).animate({height:0}, ddsmoothmenu.transition.outtime)
167					}
168				}, ddsmoothmenu.showhidedelay.hidedelay)
169			}
170		) //end hover
171	}) //end $headers.each()
172	if (smoothmenu.shadow.enable && smoothmenu.css3support){ //if shadows enabled and browser supports CSS3 shadows
173		var $toplevelul=$('#'+setting.mainmenuid+' ul li ul')
174		var css3shadow=parseInt(smoothmenu.shadow.offsetx)+"px "+parseInt(smoothmenu.shadow.offsety)+"px 5px #aaa" //construct CSS3 box-shadow value
175		var shadowprop=["boxShadow", "MozBoxShadow", "WebkitBoxShadow", "MsBoxShadow"] //possible vendor specific CSS3 shadow properties
176		for (var i=0; i<shadowprop.length; i++){
177			$toplevelul.css(shadowprop[i], css3shadow)
178		}
179	}
180	$mainmenu.find("ul").css({display:'none', visibility:'visible'})
181},
182
183init:function(setting){
184	if (typeof setting.customtheme=="object" && setting.customtheme.length==2){ //override default menu colors (default/hover) with custom set?
185		var mainmenuid='#'+setting.mainmenuid
186		var mainselector=(setting.orientation=="v")? mainmenuid : mainmenuid+', '+mainmenuid
187		document.write('<style type="text/css">\n'
188			+mainselector+' ul li a {background:'+setting.customtheme[0]+';}\n'
189			+mainmenuid+' ul li a:hover {background:'+setting.customtheme[1]+';}\n'
190		+'</style>')
191	}
192	this.shadow.enable=(document.all && !window.XMLHttpRequest)? false : this.shadow.enable //in IE6, always disable shadow
193	jQuery(document).ready(function($){ //ajax menu?
194		if (typeof setting.contentsource=="object"){ //if external ajax menu
195			ddsmoothmenu.getajaxmenu($, setting)
196		}
197		else{ //else if markup menu
198			ddsmoothmenu.buildmenu($, setting)
199		}
200	})
201}
202
203} //end ddsmoothmenu variable

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.