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 18//** Jun 28th, 2012: Unofficial update adds optional hover images for down and right arrows in the format: filename_over.ext 19//** These must be present for whichever or both of the arrow(s) are used and will preload. 20 21//** Dec 23rd, 2012 Unofficial update to fixed configurable z-index, add method option to init "toggle" which activates on click or "hover" 22//** which activates on mouse over/out - defaults to "toggle" (click activation), with detection of touch devices to activate on click for them. 23//** Add option for when there are two or more menus using "toggle" activation, whether or not all previously opened menus collapse 24//** on new menu activation, or just those within that specific menu 25//** See: http://www.dynamicdrive.com/forums/showthread.php?72449-PLEASE-HELP-with-Smooth-Navigational-Menu-(v1-51)&p=288466#post288466 26 27//** Feb 7th, 2013 Unofficial update change fixed configurable z-index back to graduated for cases of main UL wrapping. Update off menu click detection in 28//** ipad/iphone to touchstart because document click wasn't registering. see: http://www.dynamicdrive.com/forums/showthread.php?72825 29 30//** Feb 14th, 2013 Add window.ontouchstart to means tests for detecting touch browsers - thanks DD! 31//** Feb 15th, 2013 Add 'ontouchstart' in window and 'ontouchstart' in document.documentElement to means tests for detecting touch browsers - thanks DD! 32 33//** Feb 20th, 2013 correct for IE 9+ sometimes adding a pixel to the offsetHeight of the top level trigger for horizontal menus 34//** Feb 23rd, 2013 move CSS3 shadow adjustment for IE 9+ to the script, add resize event for all browsers to reposition open toggle 35//** menus and shadows in window if they would have gone to a different position at the new window dimensions 36//** Feb 25th, 2013 (v2.0) All unofficial updates by John merged into official and now called v2.0. Changed "method" option's default value to "hover" 37//** May 14th, 2013 (v2.1) Adds class 'repositioned' to menus moved due to being too close to the browser's right edge 38//** May 30th, 2013 (v2.1) Change from version sniffing to means testing for jQuery versions which require added code for click toggle event handling 39//** Sept 15th, 2013 add workaround for false positives for touch on Chrome 40//** Sept 22nd, 2013 (v2.2) Add vertical repositioning if sub menu will not fit in the viewable vertical area. May be turned off by setting 41// repositionv: false, 42//** in the init. Sub menus that are vertically repositioned will have the class 'repositionedv' added to them. 43 44var ddsmoothmenu = { 45 46///////////////////////// Global Configuration Options: ///////////////////////// 47 48//Specify full URL to down and right arrow images (23 is padding-right for top level LIs with drop downs, 6 is for vertical top level items with fly outs): 49arrowimages: {down:['downarrowclass', 'images/left_menu_arrows/down.gif', 23], right:['rightarrowclass', 'images/left_menu_arrows/right.gif', 6]}, 50transition: {overtime:300, outtime:300}, //duration of slide in/ out animation, in milliseconds 51shadow: true, //enable shadow? (offsets now set in ddsmoothmenu.css stylesheet) 52showhidedelay: {showdelay: 100, hidedelay: 200}, //set delay in milliseconds before sub menus appear and disappear, respectively 53zindexvalue: 1000, //set z-index value for menus 54closeonnonmenuclick: true, //when clicking outside of any "toggle" method menu, should all "toggle" menus close? 55closeonmouseout: false, //when leaving a "toggle" menu, should all "toggle" menus close? Will not work on touchscreen 56
57/////////////////////// End Global Configuration Options //////////////////////// 58 59overarrowre: /(?=\.(gif|jpg|jpeg|png|bmp))/i, 60overarrowaddtofilename: '_over', 61detecttouch: !!('ontouchstart' in window) || !!('ontouchstart' in document.documentElement) || !!window.ontouchstart || (!!window.Touch && !!window.Touch.length) || !!window.onmsgesturechange || (window.DocumentTouch && window.document instanceof window.DocumentTouch), 62detectwebkit: navigator.userAgent.toLowerCase().indexOf("applewebkit") > -1, //detect WebKit browsers (Safari, Chrome etc) 63idevice: /ipad|iphone/i.test(navigator.userAgent), 64detectie6: (function(){var ie; return (ie = /MSIE (\d+)/.exec(navigator.userAgent)) && ie[1] < 7;})(), 65detectie9: (function(){var ie; return (ie = /MSIE (\d+)/.exec(navigator.userAgent)) && ie[1] > 8;})(), 66ie9shadow: function(){}, 67css3support: typeof document.documentElement.style.boxShadow === 'string' || (!document.all && document.querySelector), //detect browsers that support CSS3 box shadows (ie9+ or FF3.5+, Safari3+, Chrome etc) 68prevobjs: [], menus: null, 69 70executelink: function($, prevobjs, e){ 71 var prevscount = prevobjs.length, link = e.target; 72 while(--prevscount > -1){ 73 if(prevobjs[prevscount] === this){ 74 prevobjs.splice(prevscount, 1); 75 if(link.href !== ddsmoothmenu.emptyhash && link.href && $(link).is('a') && !$(link).children('span.' + ddsmoothmenu.arrowimages.down[0] +', span.' + ddsmoothmenu.arrowimages.right[0]).length){ 76 if(link.target && link.target !== '_self'){ 77 window.open(link.href, link.target); 78 } else { 79 window.location.href = link.href; 80 } 81 e.stopPropagation(); 82 } 83 } 84 } 85}, 86 87repositionv: function($subul, $link, newtop, winheight, doctop, method, menutop){ 88 menutop = menutop || 0; 89 var topinc = 0, doclimit = winheight + doctop; 90 $subul.css({top: newtop, display: 'block'}); 91 while($subul.offset().top < doctop) { 92 $subul.css({top: ++newtop}); 93 ++topinc; 94 } 95 if(!topinc && $link.offset().top + $link.outerHeight() < doclimit && $subul.data('height') + $subul.offset().top > doclimit){ 96 $subul.css({top: doctop - $link.parents('ul').last().offset().top - $link.position().top}); 97 } 98 method === 'toggle' && $subul.css({display: 'none'}); 99 if(newtop !== menutop){$subul.addClass('repositionedv');} 100 return [topinc, newtop]; 101}, 102 103updateprev: function($, prevobjs, $curobj){ 104 var prevscount = prevobjs.length, prevobj, $indexobj = $curobj.parents().add(this); 105 while(--prevscount > -1){ 106 if($indexobj.index((prevobj = prevobjs[prevscount])) < 0){ 107 $(prevobj).trigger('click', [1]); 108 prevobjs.splice(prevscount, 1); 109 } 110 } 111 prevobjs.push(this); 112}, 113 114subulpreventemptyclose: function(e){ 115 var link = e.target; 116 if(link.href === ddsmoothmenu.emptyhash && $(link).parent('li').find('ul').length < 1){ 117 e.preventDefault(); 118 e.stopPropagation(); 119 } 120}, 121 122getajaxmenu: function($, setting, nobuild){ //function to fetch external page containing the panel DIVs 123 var $menucontainer=$('#'+setting.contentsource[0]); //reference empty div on page that will hold menu 124 $menucontainer.html("Loading Menu..."); 125 $.ajax({ 126 url: setting.contentsource[1], //path to external menu file 127 async: true, 128 error: function(ajaxrequest){ 129 $menucontainer.html('Error fetching content. Server Response: '+ajaxrequest.responseText); 130 }, 131 success: function(content){ 132 $menucontainer.html(content); 133 !!!nobuild && ddsmoothmenu.buildmenu($, setting); 134 } 135 }); 136}, 137 138closeall: function(e){ 139 var smoothmenu = ddsmoothmenu, prevscount; 140 if(!smoothmenu.globaltrackopen){return;} 141 if(e.type === 'mouseleave' || ((e.type === 'click' || e.type === 'touchstart') && smoothmenu.menus.index(e.target) < 0)){ 142 prevscount = smoothmenu.prevobjs.length; 143 while(--prevscount > -1){ 144 $(smoothmenu.prevobjs[prevscount]).trigger('click'); 145 smoothmenu.prevobjs.splice(prevscount, 1); 146 } 147 } 148}, 149 150emptyhash: $('<a href="#"></a>').get(0).href, 151 152buildmenu: function($, setting){ 153 var smoothmenu = ddsmoothmenu; 154 smoothmenu.globaltrackopen = smoothmenu.closeonnonmenuclick || smoothmenu.closeonmouseout; 155 var zsub = 0; //subtractor to be incremented so that each top level menu can be covered by previous one's drop downs 156 var prevobjs = smoothmenu.globaltrackopen? smoothmenu.prevobjs : []; 157 var $mainparent = $("#"+setting.mainmenuid).removeClass("ddsmoothmenu ddsmoothmenu-v").addClass(setting.classname || "ddsmoothmenu"); 158 setting.repositionv = setting.repositionv !== false; 159 var $mainmenu = $mainparent.find('>ul'); //reference main menu UL 160 var method = smoothmenu.detecttouch? 'toggle' : setting.method === 'toggle'? 'toggle' : 'hover'; 161 var $topheaders = $mainmenu.find('>li>ul').parent();//has('ul'); 162 var orient = setting.orientation!='v'? 'down' : 'right', $parentshadow = $(document.body); 163 $mainmenu.click(function(e){e.target.href === smoothmenu.emptyhash && e.preventDefault();}); 164 if(method === 'toggle') { 165 if(smoothmenu.globaltrackopen){ 166 smoothmenu.menus = smoothmenu.menus? smoothmenu.menus.add($mainmenu.add($mainmenu.find('*'))) : $mainmenu.add($mainmenu.find('*')); 167 } 168 if(smoothmenu.closeonnonmenuclick){ 169 if(orient === 'down'){$mainparent.click(function(e){e.stopPropagation();});} 170 $(document).unbind('click.smoothmenu').bind('click.smoothmenu', smoothmenu.closeall); 171 if(smoothmenu.idevice){ 172 document.removeEventListener('touchstart', smoothmenu.closeall, false); 173 document.addEventListener('touchstart', smoothmenu.closeall, false); 174 } 175 } else if (setting.closeonnonmenuclick){ 176 if(orient === 'down'){$mainparent.click(function(e){e.stopPropagation();});} 177 $(document).bind('click.' + setting.mainmenuid, function(e){$mainmenu.find('li>a.selected').parent().trigger('click');}); 178 if(smoothmenu.idevice){ 179 document.addEventListener('touchstart', function(e){$mainmenu.find('li>a.selected').parent().trigger('click');}, false); 180 } 181 } 182 if(smoothmenu.closeonmouseout){ 183 var $leaveobj = orient === 'down'? $mainparent : $mainmenu;
184 $leaveobj.bind('mouseleave.smoothmenu', smoothmenu.closeall); 185 } else if (setting.closeonmouseout){ 186 var $leaveobj = orient === 'down'? $mainparent : $mainmenu; 187 $leaveobj.bind('mouseleave.smoothmenu', function(){$mainmenu.find('li>a.selected').parent().trigger('click');}); 188 } 189 if(!$('style[title="ddsmoothmenushadowsnone"]').length){ 190 $('head').append('<style title="ddsmoothmenushadowsnone" type="text/css">.ddsmoothmenushadowsnone{display:none!important;}</style>'); 191 } 192 var shadowstimer; 193 $(window).bind('resize scroll', function(){ 194 clearTimeout(shadowstimer); 195 var $selected = $mainmenu.find('li>a.selected').parent(), 196 $shadows = $('.ddshadow').addClass('ddsmoothmenushadowsnone'); 197 $selected.eq(0).trigger('click'); 198 $selected.trigger('click'); 199 shadowstimer = setTimeout(function(){$shadows.removeClass('ddsmoothmenushadowsnone');}, 100); 200 }); 201 } 202 203 $topheaders.each(function(){ 204 var $curobj=$(this).css({zIndex: (setting.zindexvalue || smoothmenu.zindexvalue) + zsub--}); //reference current LI header 205 var $subul=$curobj.children('ul:eq(0)').css({display:'block'}).data('timers', {}); 206 var $link = $curobj.children("a:eq(0)").css({paddingRight: smoothmenu.arrowimages[orient][2]}).append( //add arrow images 207 '<span style="display: block;" class="' + smoothmenu.arrowimages[orient][0] + '"></span>' 208 ); 209 var dimensions = { 210 w : $link.outerWidth(), 211 h : $curobj.innerHeight(), 212 subulw : $subul.outerWidth(), 213 subulh : $subul.outerHeight() 214 }; 215 var menutop = orient === 'down'? dimensions.h : 0; 216 $subul.css({top: menutop}); 217 function restore(){$link.removeClass('selected');} 218 method === 'toggle' && $subul.click(smoothmenu.subulpreventemptyclose); 219 $curobj[method]( 220 function(e){ 221 if(!$curobj.data('headers')){ 222 smoothmenu.buildsubheaders($, $subul.find('>li>ul').parent(), setting, method, prevobjs); 223 $curobj.data('headers', true).find('>ul').each(function(i, ul){ 224 var $ul = $(ul); 225 $ul.data('height', $ul.outerHeight()); 226 }).css({display:'none', visibility:'visible'}); 227 } 228 method === 'toggle' && smoothmenu.updateprev.call(this, $, prevobjs, $curobj); 229 clearTimeout($subul.data('timers').hidetimer); 230 $link.addClass('selected'); 231 $subul.data('timers').showtimer=setTimeout(function(){ 232 var menuleft = orient === 'down'? 0 : dimensions.w; 233 var menumoved = menuleft, newtop, doctop, winheight, topinc = 0; 234 menuleft=($curobj.offset().left+menuleft+dimensions.subulw>$(window).width())? (orient === 'down'? -dimensions.subulw+dimensions.w : -dimensions.w) : menuleft; //calculate this sub menu's offsets from its parent 235 menumoved = menumoved !== menuleft; 236 $subul.css({top: menutop}).removeClass('repositionedv');
237 if(setting.repositionv && $link.offset().top + menutop + $subul.data('height') > (winheight = $(window).height()) + (doctop = $(document).scrollTop())){ 238 newtop = (orient === 'down'? 0 : $link.outerHeight()) - $subul.data('height'); 239 topinc = smoothmenu.repositionv($subul, $link, newtop, winheight, doctop, method, menutop)[0]; 240 } 241 $subul.css({left:menuleft, width:dimensions.subulw}).stop(true, true).animate({height:'show',opacity:'show'}, smoothmenu.transition.overtime, function(){this.style.removeAttribute && this.style.removeAttribute('filter');}); 242 if(menumoved){$subul.addClass('repositioned');} else {$subul.removeClass('repositioned');} 243 if (setting.shadow){ 244 if(!$curobj.data('$shadow')){ 245 $curobj.data('$shadow', $('<div></div>').addClass('ddshadow toplevelshadow').prependTo($parentshadow).css({zIndex: $curobj.css('zIndex')})); //insert shadow DIV and set it to parent node for the next shadow div 246 } 247 smoothmenu.ie9shadow($curobj.data('$shadow')); 248 var offsets = $subul.offset(); 249 var shadowleft = offsets.left; 250 var shadowtop = offsets.top; 251 $curobj.data('$shadow').css({overflow: 'visible', width:dimensions.subulw, left:shadowleft, top:shadowtop}).stop(true, true).animate({height:dimensions.subulh}, smoothmenu.transition.overtime); 252 } 253 }, smoothmenu.showhidedelay.showdelay); 254 }, 255 function(e, speed){ 256 var $shadow = $curobj.data('$shadow'); 257 if(method === 'hover'){restore();} 258 else{smoothmenu.executelink.call(this, $, prevobjs, e);} 259 clearTimeout($subul.data('timers').showtimer); 260 $subul.data('timers').hidetimer=setTimeout(function(){ 261 $subul.stop(true, true).animate({height:'hide', opacity:'hide'}, speed || smoothmenu.transition.outtime, function(){method === 'toggle' && restore();}); 262 if ($shadow){ 263 if (!smoothmenu.css3support && smoothmenu.detectwebkit){ //in WebKit browsers, set first child shadow's opacity to 0, as "overflow:hidden" doesn't work in them 264 $shadow.children('div:eq(0)').css({opacity:0}); 265 } 266 $shadow.stop(true, true).animate({height:0}, speed || smoothmenu.transition.outtime, function(){if(method === 'toggle'){this.style.overflow = 'hidden';}}); 267 } 268 }, smoothmenu.showhidedelay.hidedelay); 269 } 270 ); //end hover/toggle 271 }); //end $topheaders.each() 272}, 273 274buildsubheaders: function($, $headers, setting, method, prevobjs){ 275 //setting.$mainparent.data('$headers').add($headers); 276 $headers.each(function(){ //loop through each LI header 277 var smoothmenu = ddsmoothmenu; 278 var $curobj=$(this).css({zIndex: $(this).parent('ul').css('z-index')}); //reference current LI header 279 var $subul=$curobj.children('ul:eq(0)').css({display:'block'}).data('timers', {}), $parentshadow; 280 method === 'toggle' && $subul.click(smoothmenu.subulpreventemptyclose); 281 var $link = $curobj.children("a:eq(0)").append( //add arrow images 282 '<span style="display: block;" class="' + smoothmenu.arrowimages['right'][0] + '"></span>' 283 ); 284 var dimensions = { 285 w : $link.outerWidth(), 286 subulw : $subul.outerWidth(), 287 subulh : $subul.outerHeight() 288 }; 289 $subul.css({top: 0}); 290 function restore(){$link.removeClass('selected');} 291 $curobj[method]( 292 function(e){ 293 if(!$curobj.data('headers')){ 294 smoothmenu.buildsubheaders($, $subul.find('>li>ul').parent(), setting, method, prevobjs); 295 $curobj.data('headers', true).find('>ul').each(function(i, ul){ 296 var $ul = $(ul); 297 $ul.data('height', $ul.height()); 298 }).css({display:'none', visibility:'visible'}); 299 } 300 method === 'toggle' && smoothmenu.updateprev.call(this, $, prevobjs, $curobj); 301 clearTimeout($subul.data('timers').hidetimer); 302 $link.addClass('selected'); 303 $subul.data('timers').showtimer=setTimeout(function(){ 304 var menuleft= dimensions.w; 305 var menumoved = menuleft, newtop, doctop, winheight, topinc = 0; 306 menuleft=($curobj.offset().left+menuleft+dimensions.subulw>$(window).width())? -dimensions.w : menuleft; //calculate this sub menu's offsets from its parent 307 menumoved = menumoved !== menuleft; 308 $subul.css({top: 0}).removeClass('repositionedv'); 309 if(setting.repositionv && $link.offset().top + $subul.data('height') > (winheight = $(window).height()) + (doctop = $(document).scrollTop())){ 310 newtop = $link.outerHeight() - $subul.data('height'); 311 topinc = smoothmenu.repositionv($subul, $link, newtop, winheight, doctop, method); 312 newtop = topinc[1]; 313 topinc = topinc[0]; 314 } 315 $subul.css({left:menuleft, width:dimensions.subulw}).stop(true, true).animate({height:'show',opacity:'show'}
315, smoothmenu.transition.overtime, function(){this.style.removeAttribute && this.style.removeAttribute('filter');}); 316 if(menumoved){$subul.addClass('repositioned');} else {$subul.removeClass('repositioned');} 317 if (setting.shadow){ 318 if(!$curobj.data('$shadow')){ 319 $parentshadow = $curobj.parents("li:eq(0)").data('$shadow'); 320 $curobj.data('$shadow', $('<div></div>').addClass('ddshadow').prependTo($parentshadow).css({zIndex: $parentshadow.css('z-index')})); //insert shadow DIV and set it to parent node for the next shadow div 321 } 322 var offsets = $subul.offset(); 323 var shadowleft = menuleft; 324 var shadowtop = $curobj.position().top - (newtop? $subul.data('height') - $link.outerHeight() - topinc : 0); 325 if (smoothmenu.detectwebkit && !smoothmenu.css3support){ //in WebKit browsers, restore shadow's opacity to full 326 $curobj.data('$shadow').css({opacity:1}); 327 } 328 $curobj.data('$shadow').css({overflow: 'visible', width:dimensions.subulw, left:shadowleft, top:shadowtop}).stop(true, true).animate({height:dimensions.subulh}, smoothmenu.transition.overtime); 329 } 330 }, smoothmenu.showhidedelay.showdelay); 331 }, 332 function(e, speed){ 333 var $shadow = $curobj.data('$shadow'); 334 if(method === 'hover'){restore();} 335 else{smoothmenu.executelink.call(this, $, prevobjs, e);} 336 clearTimeout($subul.data('timers').showtimer); 337 $subul.data('timers').hidetimer=setTimeout(function(){ 338 $subul.stop(true, true).animate({height:'hide', opacity:'hide'}, speed || smoothmenu.transition.outtime, function(){ 339 method === 'toggle' && restore(); 340 }); 341 if ($shadow){ 342 if (!smoothmenu.css3support && smoothmenu.detectwebkit){ //in WebKit browsers, set first child shadow's opacity to 0, as "overflow:hidden" doesn't work in them 343 $shadow.children('div:eq(0)').css({opacity:0}); 344 } 345 $shadow.stop(true, true).animate({height:0}, speed || smoothmenu.transition.outtime, function(){if(method === 'toggle'){this.style.overflow = 'hidden';}}); 346 } 347 }, smoothmenu.showhidedelay.hidedelay); 348 } 349 ); //end hover/toggle for subheaders 350 }); //end $headers.each() for subheaders 351}, 352 353init: function(setting){ 354 if(this.detectie6 && parseFloat(jQuery.fn.jquery) > 1.3){ 355 this.init = function(setting){ 356 if (typeof setting.contentsource=="object"){ //if external ajax menu 357 jQuery(function($){ddsmoothmenu.getajaxmenu($, setting, 'nobuild');}); 358 } 359 return false; 360 }; 361 jQuery('link[href*="ddsmoothmenu"]').attr('disabled', true); 362 jQuery(function($){ 363 alert('You Seriously Need to Update Your Browser!\n\nDynamic Drive Smooth Navigational Menu Showing Text Only Menu(s)\n\nDEVELOPER\'s NOTE: This script will run in IE 6 when using jQuery 1.3.2 or less,\nbut not real well.'); 364 $('link[href*="ddsmoothmenu"]').attr('disabled', true); 365 }); 366 return this.init(setting); 367 } 368 var mainmenuid = '#' + setting.mainmenuid, right, down, stylestring = ['</style>\n'], stylesleft = setting.arrowswap? 4 : 2; 369 function addstyles(){ 370 if(stylesleft){return;} 371 if (typeof setting.customtheme=="object" && setting.customtheme.length==2){ //override default menu colors (default/hover) with custom set? 372 var mainselector=(setting.orientation=="v")? mainmenuid : mainmenuid+', '+mainmenuid; 373 stylestring.push([mainselector,' ul li a {background:',setting.customtheme[0],';}\n', 374 mainmenuid,' ul li a:hover {background:',setting.customtheme[1],';}'].join('')); 375 } 376 stylestring.push('\n<style type="text/css">'); 377 stylestring.reverse(); 378 jQuery('head').append(stylestring.join('\n')); 379 } 380 if(setting.arrowswap){ 381 right = ddsmoothmenu.arrowimages.right[1].replace(ddsmoothmenu.overarrowre, ddsmoothmenu.overarrowaddtofilename); 382 down = ddsmoothmenu.arrowimages.down[1].replace(ddsmoothmenu.overarrowre, ddsmoothmenu.overarrowaddtofilename); 383 jQuery(new Image()).bind('load error', function(e){ 384 setting.rightswap = e.type === 'load'; 385 if(setting.rightswap){ 386 stylestring.push([mainmenuid, ' ul li a:hover .', ddsmoothmenu.arrowimages.right[0], ', ', 387 mainmenuid, ' ul li a.selected .', ddsmoothmenu.arrowimages.right[0], 388 ' { background-image: url(', this.src, ');}'].join('')); 389 } 390 --stylesleft; 391 addstyles(); 392 }).attr('src', right); 393 jQuery(new Image()).bind('load error', function(e){ 394 setting.downswap = e.type === 'load'; 395 if(setting.downswap){ 396 stylestring.push([mainmenuid, ' ul li a:hover .', ddsmoothmenu.arrowimages.down[0], ', ', 397 mainmenuid, ' ul li a.selected .', ddsmoothmenu.arrowimages.down[0], 398 ' { background-image: url(', this.src, ');}'].join('')); 399 } 400 --stylesleft; 401 addstyles(); 402 }).attr('src', down); 403 } 404 jQuery(new Image()).bind('load error', function(e){ 405 if(e.type === 'load'){ 406 stylestring.push([mainmenuid+' ul li a .', ddsmoothmenu.arrowimages.right[0],' { background: url(', this.src, ') no-repeat;width:', this.width,'px;height:', this.height, 'px;}'].join('')); 407 } 408 --stylesleft; 409 addstyles(); 410 }).attr('src', ddsmoothmenu.arrowimages.right[1]); 411 jQuery(new Image()).bind('load error', function(e){ 412 if(e.type === 'load'){ 413 stylestring.push([mainmenuid+' ul li a .', ddsmoothmenu.arrowimages.down[0],' { background: url(', this.src, ') no-repeat;width:', this.width,'px;height:', this.height, 'px;}'].join('')); 414 } 415 --stylesleft; 416 addstyles(); 417 }).attr('src', ddsmoothmenu.arrowimages.down[1]);
418 setting.shadow = this.detectie6 && (setting.method === 'hover' || setting.orientation === 'v')? false : setting.shadow || this.shadow; //in IE6, always disable shadow except for horizontal toggle menus 419 jQuery(document).ready(function($){ //ajax menu? 420 if (setting.shadow && ddsmoothmenu.css3support){$('body').addClass('ddcss3support');} 421 if (typeof setting.contentsource=="object"){ //if external ajax menu 422 ddsmoothmenu.getajaxmenu($, setting); 423 } 424 else{ //else if markup menu 425 ddsmoothmenu.buildmenu($, setting); 426 } 427 }); 428} 429}; //end ddsmoothmenu variable 430 431 432// Patch for jQuery 1.9+ which lack click toggle (deprecated in 1.8, removed in 1.9) 433// Will not run if using another patch like jQuery Migrate, which also takes care of this 434if( 435 (function($){ 436 var clicktogglable = false; 437 try { 438 $('<a href="#"></a>').toggle(function(){}, function(){clicktogglable = true;}).trigger('click').trigger('click'); 439 } catch(e){} 440 return !clicktogglable; 441 })(jQuery) 442){ 443 (function(){ 444 var toggleDisp = jQuery.fn.toggle; // There's an animation/css method named .toggle() that toggles display. Save a reference to it. 445 jQuery.extend(jQuery.fn, { 446 toggle: function( fn, fn2 ) { 447 // The method fired depends on the arguments passed. 448 if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) { 449 return toggleDisp.apply(this, arguments); 450 } 451 // Save reference to arguments for access in closure 452 var args = arguments, guid = fn.guid || jQuery.guid++, 453 i = 0, 454 toggler = function( event ) { 455 // Figure out which function to execute 456 var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; 457 jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); 458 459 // Make sure that clicks stop 460 event.preventDefault(); 461 462 // and execute the function 463 return args[ lastToggle ].apply( this, arguments ) || false; 464 }; 465 466 // link all the functions, so any of them can unbind this click handler 467 toggler.guid = guid; 468 while ( i < args.length ) { 469 args[ i++ ].guid = guid; 470 } 471 472 return this.click( toggler ); 473 } 474 }); 475 })(); 476} 477 478/* TECHNICAL NOTE: To overcome an intermittent layout bug in IE 9+, the script will change margin top and left for the shadows to 479 1px less than their computed values, and the first two values for the box-shadow property will be changed to 1px larger than 480 computed, ex: -1px top and left margins and 6px 6px 5px #aaa box-shadow results in what appears to be a 5px box-shadow. 481 Other browsers skip this step and it shouldn't affect you in most cases. In some rare cases it will result in 482 slightly narrower (by 1px) box shadows for IE 9+ on one or more of the drop downs. Without this, sometimes 483 the shadows could be 1px beyond their drop down resulting in a gap. This is the first of the two patches below. 484 and also relates to the MS CSSOM which uses decimal fractions of pixels for layout while only reporting rounded values. 485 There appears to be no computedStyle workaround for this one. */ 486 487//Scripted CSS Patch for IE 9+ intermittent mis-rendering of box-shadow elements (see above TECHNICAL NOTE for more info) 488//And jQuery Patch for IE 9+ CSSOM re: offset Width and Height and re: getBoundingClientRect(). Both run only in IE 9 and later. 489//IE 9 + uses decimal fractions of pixels internally for layout but only reports rounded values using the offset and getBounding methods. 490//These are sometimes rounded inconsistently. This second patch gets the decimal values directly from computedStyle. 491if(ddsmoothmenu.detectie9){ 492 (function($){ //begin Scripted CSS Patch 493 function incdec(v, how){return parseInt(v) + how + 'px';} 494 ddsmoothmenu.ie9shadow = function($elem){ //runs once 495 var getter = document.defaultView.getComputedStyle($elem.get(0), null), 496 curshadow = getter.getPropertyValue('box-shadow').split(' '), 497 curmargin = {top: getter.getPropertyValue('margin-top'), left
497: getter.getPropertyValue('margin-left')}; 498 $('head').append(['\n<style title="ie9shadow" type="text/css">', 499 '.ddcss3support .ddshadow {', 500 '\tbox-shadow: ' + incdec(curshadow[0], 1) + ' ' + incdec(curshadow[1], 1) + ' ' + curshadow[2] + ' ' + curshadow[3] + ';', 501 '}', '.ddcss3support .ddshadow.toplevelshadow {', 502 '\topacity: ' + ($('.ddcss3support .ddshadow').css('opacity') - 0.1) + ';', 503 '\tmargin-top: ' + incdec(curmargin.top, -1) + ';', 504 '\tmargin-left: ' + incdec(curmargin.left, -1) + ';', '}', 505 '</style>\n'].join('\n')); 506 ddsmoothmenu.ie9shadow = function(){}; //becomes empty function after running once 507 }; //end Scripted CSS Patch 508 var jqheight = $.fn.height, jqwidth = $.fn.width; //begin jQuery Patch for IE 9+ .height() and .width() 509 $.extend($.fn, { 510 height: function(){ 511 var obj = this.get(0); 512 if(this.length < 1 || arguments.length || obj === window || obj === document){ 513 return jqheight.apply(this, arguments); 514 } 515 return parseFloat(document.defaultView.getComputedStyle(obj, null).getPropertyValue('height')); 516 }, 517 innerHeight: function(){ 518 if(this.length < 1){return null;} 519 var val = this.height(), obj = this.get(0), getter = document.defaultView.getComputedStyle(obj, null); 520 val += parseInt(getter.getPropertyValue('padding-top')); 521 val += parseInt(getter.getPropertyValue('padding-bottom')); 522 return val; 523 }, 524 outerHeight: function(bool){ 525 if(this.length < 1){return null;} 526 var val = this.innerHeight(), obj = this.get(0), getter = document.defaultView.getComputedStyle(obj, null); 527 val += parseInt(getter.getPropertyValue('border-top-width')); 528 val += parseInt(getter.getPropertyValue('border-bottom-width')); 529 if(bool){ 530 val += parseInt(getter.getPropertyValue('margin-top')); 531 val += parseInt(getter.getPropertyValue('margin-bottom')); 532 } 533 return val; 534 }, 535 width: function(){ 536 var obj = this.get(0); 537 if(this.length < 1 || arguments.length || obj === window || obj === document){ 538 return jqwidth.apply(this, arguments); 539 } 540 return parseFloat(document.defaultView.getComputedStyle(obj, null).getPropertyValue('width')); 541 }, 542 innerWidth: function(){ 543 if(this.length < 1){return null;} 544 var val = this.width(), obj = this.get(0), getter = document.defaultView.getComputedStyle(obj, null); 545 val += parseInt(getter.getPropertyValue('padding-right')); 546 val += parseInt(getter.getPropertyValue('padding-left')); 547 return val; 548 }, 549 outerWidth: function(bool){ 550 if(this.length < 1){return null;} 551 var val = this.innerWidth(), obj = this.get(0), getter = document.defaultView.getComputedStyle(obj, null); 552 val += parseInt(getter.getPropertyValue('border-right-width')); 553 val += parseInt(getter.getPropertyValue('border-left-width')); 554 if(bool){ 555 val += parseInt(getter.getPropertyValue('margin-right')); 556 val += parseInt(getter.getPropertyValue('margin-left')); 557 } 558 return val; 559 } 560 }); //end jQuery Patch for IE 9+ .height() and .width() 561 })(jQuery); 562}
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.