1/* CUSTOMIZED */ 2//** All Levels Navigational Menu- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com 3//** Script Download/ instructions page: http://www.dynamicdrive.com/dynamicindex1/ddlevelsmenu/ 4//** Usage Terms: http://www.dynamicdrive.com/notice.htm 5 6//** Current version: 3.02 See changelog.txt for details 7 8if (typeof dd_domreadycheck=="undefined") //global variable to detect if DOM is ready 9 var dd_domreadycheck=false; 10 11var ddlevelsmenu={ 12enableshim: true, //enable IFRAME shim to prevent drop down menus from being hidden below SELECT or FLASH elements? (tip: disable if not in use, for efficiency) 13 14arrowpointers:{ 15 downarrow: ["ddlevelsfiles/arrow-down.gif", 11,7], //[path_to_down_arrow, arrowwidth, arrowheight] 16 rightarrow: ["ddlevelsfiles/arrow-right.gif", 12,12], //[path_to_right_arrow, arrowwidth, arrowheight] 17 showarrow: {toplevel: false, sublevel: false} //Show arrow images on top level items and sub level items, respectively? 18}, 19hideinterval: 200, //delay in milliseconds before entire menu disappears onmouseout. 20effects: {enableswipe: true, enableslide: true, enablefade: true, duration: 200}, 21httpsiframesrc: "blank.htm", //If menu is run on a secure (https) page, the IFRAME shim feature used by the script should point to an *blank* page *within* the secure area to prevent an IE security prompt. Specify full URL to that page on your server (leave as is if not applicable). 22 23///No need to edit beyond here//////////////////// 24 25topmenuids: [], //array containing ids of all the primary menus on the page 26topitems: {}, //object array containing all top menu item links 27subuls: {}, //object array containing all ULs 28lastactivesubul: {}, //object object containing info for last mouse out menu item's UL 29topitemsindex: -1, 30ulindex: -1, 31hidetimers: {}, //object array timer 32shimadded: false, 33nonFF: !/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent), //detect non FF browsers 34ismobile:navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i) != null, //boolean check for popular mobile browsers 35 36getoffset:function(what, offsettype){ 37 return (what.offsetParent)? what[offsettype]+this.getoffset(what.offsetParent, offsettype) : what[offsettype] 38}, 39 40getoffsetof:function(el){ 41 el._offsets={left:this.getoffset(el, "offsetLeft"), top:this.getoffset(el, "offsetTop")} 42}, 43 44getwindowsize:function(){ 45 this.docwidth=window.innerWidth? window.innerWidth-10 : this.standardbody.clientWidth-10; 46 this.docheight=window.innerHeight? window.innerHeight-15 : this.standardbody.clientHeight-18; 47}, 48 49gettopitemsdimensions:function(){ 50 for (var m=0; m<this.topmenuids.length; m++){ 51 var topmenuid=this.topmenuids[m]; 52 for (var i=0; i<this.topitems[topmenuid].length; i++){ 53 var header=this.topitems[topmenuid][i]; 54 var submenu=document.getElementById(header.getAttribute('data-rel')); 55 header._dimensions={w:header.offsetWidth, h:header.offsetHeight, submenuw:submenu.offsetWidth, submenuh:submenu.offsetHeight} 56 } 57 } 58}, 59 60isContained:function(m, e){ 61 var e=window.event || e; 62 var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement); 63 while (c && c!=m)try {c=c.parentNode} catch(e){c=m} 64 if (c==m) 65 return true; 66 else 67 return false; 68}, 69 70addpointer:function(target, spanclass, /*spaninfo,*/ BeforeorAfter){ 71 var pointer=document.createElement("span"); 72// pointer.src=imginfo[0] 73 pointer.innerHTML = '»'; 74// pointer.style.width=spaninfo[1]+"px"; 75// pointer.style.height=spaninfo[2]+"px"; 76// if(spanclass=="rightarrowpointer"){ 77// pointer.style.left=target.offsetWidth-spaninfo[2]-2+"px"; 78// } 79 pointer.className=spanclass; 80 var target_firstEl=target.childNodes[target.firstChild.nodeType!=1? 1 : 0]; //see if the first child element within A is a SPAN (found in sliding doors technique) 81 if (target_firstEl && target_firstEl.tagName=="SPAN"){ 82 target=target_firstEl; //arrow should be added inside this SPAN instead if found 83 } 84 if (BeforeorAfter=="before") 85 target.insertBefore(pointer, target.firstChild); 86 else
87 target.appendChild(pointer); 88}, 89 90css:function(el, targetclass, action){ 91 var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig"); 92 if (action=="check") 93 return needle.test(el.className); 94 else if (action=="remove") 95 el.className=el.className.replace(needle, ""); 96 else if (action=="add" && !needle.test(el.className)) 97 el.className+=" "+targetclass; 98}, 99 100addshimmy:function(target){ 101 var shim=(!window.opera)? document.createElement("iframe") : document.createElement("div"); //Opera 9.24 doesnt seem to support transparent IFRAMEs 102 shim.className="ddiframeshim"; 103 shim.setAttribute("src", location.protocol=="https:"? this.httpsiframesrc : "about:blank"); 104 shim.setAttribute("frameborder", "0"); 105 target.appendChild(shim); 106 try{ 107 shim.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)'; 108 } 109 catch(e){} 110 return shim; 111}, 112 113positionshim:function(header, submenu, dir, scrollX, scrollY){ 114 if (header._istoplevel){ 115 var scrollY=window.pageYOffset? window.pageYOffset : this.standardbody.scrollTop; 116 var topgap=header._offsets.top-scrollY; 117 var bottomgap=scrollY+this.docheight-header._offsets.top-header._dimensions.h; 118 if (topgap>0){ 119 this.shimmy.topshim.style.left=scrollX+"px"; 120 this.shimmy.topshim.style.top=scrollY+"px"; 121 this.shimmy.topshim.style.width="99%"; 122 this.shimmy.topshim.style.height=topgap+"px"; //distance from top window edge to top of menu item 123 } 124 if (bottomgap>0){ 125 this.shimmy.bottomshim.style.left=scrollX+"px"; 126 this.shimmy.bottomshim.style.top=header._offsets.top + header._dimensions.h +"px"; 127 this.shimmy.bottomshim.style.width="99%"; 128 this.shimmy.bottomshim.style.height=bottomgap+"px"; //distance from bottom of menu item to bottom window edge 129 } 130 } 131}, 132 133hideshim:function(){ 134 this.shimmy.topshim.style.width=this.shimmy.bottomshim.style.width=0; 135 this.shimmy.topshim.style.height=this.shimmy.bottomshim.style.height=0; 136}, 137 138 139buildmenu:function(mainmenuid, header, submenu, submenupos, istoplevel, dir){ 140 header._master=mainmenuid; //Indicate which top menu this header is associated with 141 header._pos=submenupos; //Indicate pos of sub menu this header is associated with 142 header._istoplevel=istoplevel; 143 if (istoplevel && !ddlevelsmenu.ismobile){ 144 this.addEvent(header, function(e){ 145 ddlevelsmenu.hidemenu(ddlevelsmenu.subuls[this._master][parseInt(this._pos)].parentNode) 146 }, "click"); 147 } 148 this.subuls[mainmenuid][submenupos]=submenu; 149 header._dimensions={w:header.offsetWidth, h:header.offsetHeight, submenuw:submenu.offsetWidth, submenuh:submenu.offsetHeight}; 150 this.getoffsetof(header); 151 submenu.parentNode.style.left=0; 152 submenu.parentNode.style.top=0; 153 submenu.parentNode.style.visibility="hidden"; 154 submenu.style.visibility="hidden"; 155 this.addEvent(header, function(e){ //mouseover event 156 if (ddlevelsmenu.ismobile || !ddlevelsmenu.isContained(this, e)){ 157 var submenu=ddlevelsmenu.subuls[this._master][parseInt(this._pos)]; 158 if (this._istoplevel){ 159 ddlevelsmenu.css(this, "selected", "add"); 160 clearTimeout(ddlevelsmenu.hidetimers[this._master][this._pos]); 161 } 162 ddlevelsmenu.getoffsetof(header); 163 var scrollX=window.pageXOffset? window.pageXOffset : ddlevelsmenu.standardbody.scrollLeft; 164 var scrollY=window.pageYOffset? window.pageYOffset : ddlevelsmenu.standardbody.scrollTop; 165 var submenurightedge=this._offsets.left + this._dimensions.submenuw + (this._istoplevel && dir=="topbar"? 0 : this._dimensions.w); 166 var submenubottomedge=this._offsets.top + this._dimensions.submenuh; 167 //Sub menu starting left position 168 var menuleft=(this._istoplevel? this._offsets.left + (dir=="sidebar"? this._dimensions.w : 0) : this._dimensions.w); 169 if (submenurightedge-scrollX>ddlevelsmenu.docwidth){ 170 menuleft+= -this._dimensions.submenuw + (this._istoplevel && dir=="topbar" ? this._dimensions.w : -this._dimensions.w); 171 } 172 var menuOpenToLeft = (menuleft < 0); 173 submenu.parentNode.style.left=menuleft+"px"; 174 //Sub menu starting top position 175 var menutop=(this._istoplevel? this._offsets.top + (dir=="sidebar"? 0 : this._dimensions.h) : this.offsetTop); 176 if (submenubottomedge-scrollY>ddlevelsmenu.docheight){ //no room downwards? 177 if (this._dimensions.submenuh<this._offsets.top+(dir=="sidebar"? this._dimensions.h : 0)-scrollY){ //move up? 178 menutop+= - this._dimensions.submenuh + (this._istoplevel && dir=="topbar"? -this._dimensions.h : this._dimensions.h);
179 } 180 else{ //top of window edge 181 menutop+= -(this._offsets.top-scrollY) + (this._istoplevel && dir=="topbar"? -this._dimensions.h : 0); 182 } 183 } 184 submenu.parentNode.style.top=menutop+"px"; 185 if (ddlevelsmenu.enableshim && (ddlevelsmenu.effects.enableswipe==false || ddlevelsmenu.nonFF)){ //apply shim immediately only if animation is turned off, or if on, in non FF2.x browsers 186 ddlevelsmenu.positionshim(header, submenu, dir, scrollX, scrollY); 187 } 188 else{ 189 submenu.FFscrollInfo={x:scrollX, y:scrollY}; 190 } 191 if(ddlevelsmenu.ismobile){ 192 var stopEventPropagation = true; 193 if(submenu.style.visibility == 'hidden'){ 194 ddlevelsmenu.showmenu(header, submenu, dir, menuOpenToLeft); 195 }else{ 196 var parentHref = submenu.getAttribute("data-href"); 197 if(!parentHref){ 198 ddlevelsmenu.hidemenu(submenu.parentNode); 199 }else{ 200 stopEventPropagation = false; 201 } 202 } 203 if (stopEventPropagation && (header._istoplevel || e.target.parentNode.getElementsByTagName('ul').length>0)){ //if user clicks on a header (instead of a menu item) 204 e.preventDefault(); 205 e.stopPropagation(); 206 } 207 }else{ 208 ddlevelsmenu.showmenu(header, submenu, dir, menuOpenToLeft); 209 if (e.preventDefault){ 210 e.preventDefault(); 211 } 212 if (e.stopPropagation){ 213 e.stopPropagation(); 214 } 215 } 216 217// ddlevelsmenu.showmenu(header, submenu, dir, menuOpenToLeft); 218// if (!ddlevelsmenu.ismobile){ 219// if (e.preventDefault) 220// e.preventDefault(); 221// if (e.stopPropagation) 222// e.stopPropagation();
223// } 224// else{ //if is mobile 225// if (header._istoplevel || e.target.parentNode.getElementsByTagName('ul').length>0){ //if user clicks on a header (instead of a menu item) 226// e.preventDefault(); 227// e.stopPropagation(); 228// } 229// } 230 } 231 }, (this.ismobile)? "click" : "mouseover"); 232 this.addEvent(header, function(e){ //mouseout event 233 var submenu=ddlevelsmenu.subuls[this._master][parseInt(this._pos)]; 234 if (this._istoplevel){ 235 if (!ddlevelsmenu.isContained(this, e) && !ddlevelsmenu.isContained(submenu.parentNode, e)) //hide drop down div if mouse moves out of menu bar item but not into drop down div itself 236 ddlevelsmenu.hidemenu(submenu.parentNode); 237 } 238 else if (!this._istoplevel && !ddlevelsmenu.isContained(this, e)){ 239 ddlevelsmenu.hidemenu(submenu.parentNode); 240 } 241 242 }, "mouseout") 243}, 244 245setopacity:function(el, value){ 246 el.style.opacity=value; 247 if (typeof el.style.opacity!="string"){ //if it's not a string (ie: number instead), it means property not supported 248 el.style.MozOpacity=value; 249 try{ 250 if (el.filters){ 251 el.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity="+ value*100 +")"; 252 } 253 } catch(e){} 254 } 255}, 256 257showmenu:function(header, submenu, dir, menuOpenToLeft){ 258 if (this.effects.enableswipe || this.effects.enablefade){ 259 if (this.effects.enableswipe){ 260 var endpoint=(header._istoplevel && dir=="topbar")? header._dimensions.submenuh : header._dimensions.submenuw; 261 submenu.parentNode.style.width=submenu.parentNode.style.height=0; 262 submenu.parentNode.style.overflow="hidden"; 263 } 264 if (this.effects.enablefade){ 265 submenu.parentNode.style.width=submenu.offsetWidth+"px"; 266 submenu.parentNode.style.height=submenu.offsetHeight+"px"; 267 this.setopacity(submenu.parentNode, 0); //set opacity to 0 so menu appears hidden initially 268 } 269 submenu._curanimatedegree=0; 270 submenu.parentNode.style.visibility="visible"; 271 submenu.style.visibility="visible"; 272 clearInterval(submenu._animatetimer); 273 submenu._starttime=new Date().getTime(); //get time just before animation is run 274 submenu._animatetimer=setInterval(function(){ddlevelsmenu.revealmenu(header, submenu, endpoint, dir, menuOpenToLeft)}, 10); 275 } 276 else{ 277 submenu.parentNode.style.visibility="visible"; 278 submenu.style.visibility="visible"; 279 } 280}, 281 282revealmenu:function(header, submenu, endpoint, dir, menuOpenToLeft){ 283 var elapsed=new Date().getTime()-submenu._starttime; //get time animation has run 284 if (elapsed<this.effects.duration){ 285 if (this.effects.enableswipe){ 286 if (submenu._curanimatedegree==0){ //reset either width or height of sub menu to "auto" when animation begins 287 submenu.parentNode.style[header._istoplevel && dir=="topbar"? "width" : "height"]=(header._istoplevel && dir=="topbar"? submenu.offsetWidth : submenu.offsetHeight)+"px"; 288 } 289 if(!menuOpenToLeft){ 290 submenu.parentNode.style[header._istoplevel && dir=="topbar"? "height" : "width"]=(submenu._curanimatedegree*endpoint)+"px"; 291 } 292 if (this.effects.enableslide){ 293 var cssVal=Math.floor((submenu._curanimatedegree-1)*endpoint); 294 if(menuOpenToLeft){ 295 cssVal=(-1)*cssVal; 296 } 297 submenu.style[header._istoplevel && dir=="topbar"? "top" : "left"]=cssVal+"px"; 298 } 299 } 300 if (this.effects.enablefade){ 301 this.setopacity(submenu.parentNode, submenu._curanimatedegree); 302 } 303 } 304 else{ 305 clearInterval(submenu._animatetimer); 306 if (this.effects.enableswipe){ 307 submenu.parentNode.style.width=submenu.offsetWidth+"px"; 308 submenu.parentNode.style.height=submenu.offsetHeight+"px"; 309 submenu.parentNode.style.overflow="visible"; 310 if (this.effects.enableslide){ 311 submenu.style.top=0; 312 submenu.style.left=0; 313 } 314 } 315 if (this.effects.enablefade){ 316 this.setopacity(submenu.parentNode, 1); 317 submenu.parentNode.style.filter=""; 318 } 319 if (this.enableshim && submenu.FFscrollInfo) //if this is FF browser (meaning shim hasn't been applied yet 320 this.positionshim(header, submenu, dir, submenu.FFscrollInfo.x, submenu.FFscrollInfo.y); 321 } 322 submenu._curanimatedegree=(1-Math.cos((elapsed/this.effects.duration)*Math.PI)) / 2 323}, 324 325hidemenu:function(submenu){ 326 if (typeof submenu._pos!="undefined"){ //if submenu is outermost DIV drop down menu 327 this.css(this.topitems[submenu._master][parseInt(submenu._pos)], "selected", "remove"); 328 if (this.enableshim) 329 this.hideshim(); 330 } 331 clearInterval(submenu.firstChild._animatetimer); 332 submenu.style.left=0; 333 submenu.style.top="-1000px"; 334 submenu.style.visibility="hidden"; 335 submenu.firstChild.style.visibility="hidden"; 336}, 337 338 339addEvent:function(target, functionref, tasktype) { 340 if (target.addEventListener) 341 target.addEventListener(tasktype, functionref, false); 342 else if (target.attachEvent) 343 target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event)}); 344}, 345 346domready:function(functionref){ //based on code from the jQuery library 347 if (dd_domreadycheck){ 348 functionref(); 349 return; 350 } 351 // Mozilla, Opera and webkit nightlies currently support this event 352 if (document.addEventListener) { 353 // Use the handy event callback 354 document.addEventListener("DOMContentLoaded", function(){ 355 document.removeEventListener("DOMContentLoaded", arguments.callee, false ); 356 functionref(); 357 dd_domreadycheck=true; 358 }, false ) 359 } 360 else if (document.attachEvent){ 361 // If IE and not an iframe 362 // continually check to see if the document is ready 363 if ( document.documentElement.doScroll && window == window.top) (function(){ 364 if (dd_domreadycheck){ 365 functionref(); 366 return; 367 } 368 try{ 369 // If IE is used, use the trick by Diego Perini 370 // http://javascript.nwbox.com/IEContentLoaded/ 371 document.documentElement.doScroll("left") 372 }catch(error){ 373 setTimeout( arguments.callee, 0); 374 return; 375 } 376 //and execute any waiting functions 377 functionref(); 378 dd_domreadycheck=true; 379 })();
380 } 381 if (document.attachEvent && parent.length>0) //account for page being in IFRAME, in which above doesn't fire in IE 382 this.addEvent(window, function(){functionref()}, "load"); 383}, 384 385 386init:function(mainmenuid, dir){ 387 this.enableshim = !this.ismobile; //disable iframe for mobiles 388 this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body; 389 this.topitemsindex=-1; 390 this.ulindex=-1; 391 this.topmenuids.push(mainmenuid); 392 this.topitems[mainmenuid]=[]; //declare array on object 393 this.subuls[mainmenuid]=[]; //declare array on object 394 this.hidetimers[mainmenuid]=[]; //declare hide entire menu timer 395 if (this.enableshim && !this.shimadded){ 396 this.shimmy={}; 397 this.shimmy.topshim=this.addshimmy(document.body); //create top iframe shim obj 398 this.shimmy.bottomshim=this.addshimmy(document.body); //create bottom iframe shim obj 399 this.shimadded=true 400 } 401 var menubar=document.getElementById(mainmenuid); 402 var alllinks=menubar.getElementsByTagName("a"); 403 this.getwindowsize(); 404 for (var i=0; i<alllinks.length; i++){ 405 if (alllinks[i].getAttribute('data-rel')){ 406 var parentHref = alllinks[i].getAttribute('href'); 407 this.topitemsindex++; 408 this.ulindex++; 409 var menuitem=alllinks[i]; 410 this.topitems[mainmenuid][this.topitemsindex]=menuitem; //store ref to main menu links 411 var dropul=document.getElementById(menuitem.getAttribute('data-rel')); 412 if(parentHref != '#'){ 413 dropul.setAttribute("data-href", parentHref); 414 } 415 var shelldiv=document.createElement("div"); // create DIV which will contain the UL 416 shelldiv.className="ddsubmenustyle"; 417 dropul.removeAttribute("class"); 418 shelldiv.appendChild(dropul); 419 document.body.appendChild(shelldiv); //move main DIVs to end of document 420 shelldiv.style.zIndex=10001; //give drop down menus a high z-index 421 shelldiv._master=mainmenuid; //Indicate which main menu this main DIV is associated with 422 shelldiv._pos=this.topitemsindex; //Indicate which main menu item this main DIV is associated with 423 this.addEvent(shelldiv, function(){ddlevelsmenu.hidemenu(this)}, "click"); 424 var arrowclass=(dir=="sidebar")? "rightarrowpointer" : "downarrowpointer"; 425// var arrowpointer=(dir=="sidebar")? this.arrowpointers.rightarrow : this.arrowpointers.downarrow; 426 if (this.arrowpointers.showarrow.toplevel) 427 this.addpointer(menuitem, arrowclass, /*arrowpointer,*/ (dir=="sidebar")? "before" : "after"); 428 this.buildmenu(mainmenuid, menuitem, dropul, this.ulindex, true, dir); //build top level menu 429 shelldiv.onmouseover=function(){ 430 clearTimeout(ddlevelsmenu.hidetimers[this._master][this._pos]); 431 }; 432 this.addEvent(shelldiv, function(e){ //hide menu if mouse moves out of main DIV element into open space 433 if (!ddlevelsmenu.isContained(this, e) && !ddlevelsmenu.isContained(ddlevelsmenu.topitems[this._master][parseInt(this._pos)], e)){ 434 var dropul=this; 435 if (ddlevelsmenu.enableshim) 436 ddlevelsmenu.hideshim(); 437 ddlevelsmenu.hidetimers[this._master][this._pos]=setTimeout(function(){ 438 ddlevelsmenu.hidemenu(dropul); 439 }, ddlevelsmenu.hideinterval) 440 } 441 }, "mouseout"); 442 var subuls=dropul.getElementsByTagName("ul"); 443 for (var c=0; c<subuls.length; c++){ 444 this.ulindex++; 445 var parentli=subuls[c].parentNode; 446 var parentliLinks=parentli.getElementsByTagName('a'); 447 if(parentliLinks.length>0){ 448 var parentLiLinkHref = parentliLinks[0].getAttribute('href'); 449 if(parentLiLinkHref != '#'){ 450 subuls[c].setAttribute("data-href", parentLiLinkHref); 451 } 452 } 453 var subshell=document.createElement("div"); 454 subshell.appendChild(subuls[c]); 455 parentli.appendChild(subshell); 456 if (this.arrowpointers.showarrow.sublevel) 457 this.addpointer(parentli.getElementsByTagName("a")[0], "rightarrowpointer", /*this.arrowpointers.rightarrow,*/ "before"); 458 this.buildmenu(mainmenuid, parentli, subuls[c], this.ulindex, false, dir); //build sub level menus 459 } 460 } 461 } //end for loop 462 this.addEvent(window, function(){ddlevelsmenu.getwindowsize(); ddlevelsmenu.gettopitemsdimensions()}, "resize"); 463}, 464 465setup:function(mainmenuid, dir){ 466 var pageInitialized = false; 467 this.domready(function(){ 468 if(!pageInitialized){ 469 pageInitialized = true; 470 ddlevelsmenu.init(mainmenuid, dir); 471 } 472 });
473} 474 475};
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.