1/* 2 * sf-AutomaticWidth v1.0b - Automatically adjusts the menu width for the jQuery Superfish plugin. 3 * 4 * Developer's note: 5 * Built as a part of the Superfish project for Drupal (http://drupal.org/project/superfish) 6 * Found any bug? have any cool ideas? contact me right away! http://drupal.org/user/619294/contact 7 * 8 * jQuery version: 1.3.x or higher. 9 * 10 * Dual licensed under the MIT and GPL licenses: 11 * http://www.opensource.org/licenses/mit-license.php 12 * http://www.gnu.org/licenses/gpl.html 13 */ 14 15(function($){ 16 $.fn.sfautomaticwidth = function(){ 17 function automaticWidth(menu){ 18 // This plugin is not useful for vertical menus. 19 if (menu.hasClass('sf-horizontal') || menu.hasClass('sf-navbar')){ 20 // Adding a helper class. 21 // Making the main UL as wide as its container. 22 menu.addClass('sf-automatic-width').css('width','100%'); 23 var 24 // We need the inner width of the main UL. 25 menuWidth = menu[0].clientWidth, 26 // Selecting only the first level parents. 27 children = menu.children('li'), 28 // Number of children. 29 childrenNumber = children.length, 30 // Calculating the total width of the children based on their outer width. 31 childrenWidth = 0; 32 for (var a = 0; a < childrenNumber; a++) { 33 // Resetting the children width and getting its outer width then. 34 childrenWidth += children.eq(a).css({width:''}).outerWidth(true); 35 } 36 // Is the menu container wider than the menu? 37 // (It'll be more flexible in later versions.) 38 if (menuWidth > childrenWidth) { 39 var 40 // Calculating how much width should be added to each first level parent. 41 difference = (((menuWidth - childrenWidth) * 100) / menuWidth) / childrenNumber; 42 for (var a = 0; a < childrenNumber; a++){ 43 var 44 child = children.eq(a), 45 // Calculating and applying the new width to the item. 46 autoWidth = (((child[0].clientWidth * 99.8) / menuWidth) + difference) + '%'; 47 child.css({width:autoWidth}); 48 } 49 } 50 // Reset the widths if the menu became narrower than its children. 51 if (menuWidth < childrenWidth) { 52 for (var a = 0; a < childrenNumber; a++){ 53 children.eq(a).css({width:''}); 54 } 55 } 56 } 57 } 58 // Return original object to support chaining. 59 // Although unnecessary because of the way the module uses these plugins. 60 for (var b = 0; b < this.length; b++) { 61 var menu = $(this).eq(b); 62 automaticWidth(menu); 63 var timer; 64 $(window).resize(function(){ 65 clearTimeout(timer); 66 timer = setTimeout(function(){ 67 automaticWidth(menu); 68 }, 100); 69 }); 70 } 71 return this; 72 }; 73})(jQuery); 74; 75/* 76 * sf-Touchscreen v1.3b - Provides touchscreen compatibility for the jQuery Superfish plugin. 77 * 78 * Developer's note: 79 * Built as a part of the Superfish project for Drupal (http://drupal.org/project/superfish) 80 * Found any bug? have any cool ideas? contact me right away! http://drupal.org/user/619294/contact 81 * 82 * jQuery version: 1.3.x or higher. 83 * 84 * Dual licensed under the MIT and GPL licenses: 85 * http://www.opensource.org/licenses/mit-license.php 86 * http://www.gnu.org/licenses/gpl.html 87 */ 88 89(function($){ 90 $.fn.sftouchscreen = function(options){ 91 options = $.extend({ 92 mode: 'inactive', 93 breakpoint: 768, 94 breakpointUnit: 'px', 95 useragent: '', 96 behaviour: 2, 97 disableHover: false 98 }, options); 99 100 function activate(menu){ 101 var eventHandler = (('ontouchstart' in window) || (window.DocumentTouch && document instanceof DocumentTouch)) ? ['click touchstart','mouseup touchend'] : ['click','mouseup']; 102 // Select hyperlinks from parent menu items. 103 menu.find('li:has(ul)').children('a,span.nolink').each(function(){ 104 var item = $(this), 105 parent = item.closest('li'); 106 if (options.disableHover){ 107 parent.unbind('mouseenter mouseleave'); 108 } 109 if (options.behaviour == 2){
110 if (parent.children('a.menuparent,span.nolink.menuparent').length > 0 && parent.children('ul').children('.sf-clone-parent').length == 0){ 111 var 112 // Cloning the hyperlink of the parent menu item. 113 cloneLink = parent.children('a.menuparent,span.nolink.menuparent').clone(), 114 // Wrapping the hyerplinks in <li>. 115 cloneLink = $('<li class="sf-clone-parent" />').html(cloneLink); 116 // Removing unnecessary stuff. 117 cloneLink.find('.sf-sub-indicator').remove(), 118 // Adding a helper class and attaching them to the sub-menus. 119 parent.children('ul').addClass('sf-has-clone-parent').prepend(cloneLink); 120 } 121 } 122 // No .toggle() here as it's not possible to reset it. 123 item.bind(eventHandler[0], function(event){ 124 // Already clicked? 125 if (item.hasClass('sf-clicked')){ 126 // Depending on the preferred behaviour, either proceed to the URL. 127 if (options.behaviour == 0){ 128 window.location = item.attr('href'); 129 } 130 // or collapse the sub-menu. 131 else if (options.behaviour == 1 || options.behaviour == 2){
132 event.preventDefault(); 133 item.removeClass('sf-clicked'); 134 parent.hideSuperfishUl().find('a,span.nolink').removeClass('sf-clicked'); 135 } 136 } 137 // Prevent the default action otherwise. 138 else { 139 event.preventDefault(); 140 item.addClass('sf-clicked'); 141 parent.showSuperfishUl().siblings('li:has(ul)').hideSuperfishUl().find('.sf-clicked').removeClass('sf-clicked'); 142 } 143 }); 144 }); 145 146 $(document).bind(eventHandler[1], function(event){ 147 if (menu.not(event.target) && menu.has(event.target).length === 0){ 148 menu.find('.sf-clicked').removeClass('sf-clicked'); 149 menu.find('li:has(ul)').hideSuperfishUl(); 150 } 151 }); 152 } 153 // Return original object to support chaining. 154 // This is not necessary actually because of the way the module uses these plugins. 155 for (var b = 0; b < this.length; b++) { 156 var menu = $(this).eq(b), 157 mode = options.mode; 158 // The rest is crystal clear, isn't it? :) 159 if (mode == 'always_active'){ 160 activate(menu); 161 } 162 else if (mode == 'window_width'){ 163 var breakpoint = (options.breakpointUnit == 'em') ? (options.breakpoint * parseFloat($('body').css('font-size'))) : options.breakpoint, 164 windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, 165 timer; 166 if ((typeof Modernizr === 'undefined' || typeof Modernizr.mq !== 'function') && windowWidth < breakpoint){ 167 activate(menu); 168 } 169 else if (typeof Modernizr !== 'undefined' && typeof Modernizr.mq === 'function' && Modernizr.mq('(max-width:' + (breakpoint - 1) + 'px)')) { 170 activate(menu); 171 } 172 $(window).resize(function(){ 173 clearTimeout(timer); 174 timer = setTimeout(function(){ 175 var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; 176 if ((typeof Modernizr === 'undefined' || typeof Modernizr.mq !== 'function') && windowWidth < breakpoint){ 177 activate(menu); 178 } 179 else if (typeof Modernizr !== 'undefined' && typeof Modernizr.mq === 'function' && Modernizr.mq('(max-width:' + (breakpoint - 1) + 'px)')) { 180 activate(menu); 181 } 182 }, 50); 183 }); 184 } 185 else if (mode == 'useragent_custom'){ 186 if (options.useragent != ''){ 187 var ua = RegExp(options.useragent, 'i'); 188 if (navigator.userAgent.match(ua)){ 189 activate(menu); 190 } 191 } 192 } 193 else if (mode == 'useragent_predefined' && navigator.userAgent.match(/(android|bb\d+|meego)|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i)){ 194 activate(menu); 195 } 196 } 197 return this; 198 } 199})(jQuery); 200; 201/** 202* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+ 203* <http://cherne.net/brian/resources/jquery.hoverIntent.html> 204* 205* @param f onMouseOver function || An object with configuration options 206* @param g onMouseOut function || Nothing (use configuration options object) 207* @author Brian Cherne brian(at)cherne(dot)net 208*/ 209(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);; 210/* 211 * Superfish v1.4.8 - jQuery menu widget 212 * Copyright (c) 2008 Joel Birch 213 * 214 * Dual licensed under the MIT and GPL licenses: 215 * http://www.opensource.org/licenses/mit-license.php 216 * http://www.gnu.org/licenses/gpl.html 217 * 218 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt 219 */ 220/* 221 * This is not the original jQuery Superfish plugin. 222 * Please refer to the README for more information. 223 */ 224 225(function($){ 226 $.fn.superfish = function(op){ 227 var sf = $.fn.superfish, 228 c = sf.c, 229 $arrow = $(['<span class="',c.arrowClass,'"> »</span>'].join('')), 230 over = function(){ 231 var $$ = $(this), menu = getMenu($$); 232 clearTimeout(menu.sfTimer); 233 $$.showSuperfishUl().siblings().hideSuperfishUl(); 234 }, 235 out = function(){ 236 var $$ = $(this), menu = getMenu($$), o = sf.op; 237 clearTimeout(menu.sfTimer); 238 menu.sfTimer=setTimeout(function(){ 239 if ($$.children('.sf-clicked').length == 0){ 240 o.retainPath=($.inArray($$[0],o.$path)>-1);
241 $$.hideSuperfishUl(); 242 if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);} 243 } 244 },o.delay); 245 }, 246 getMenu = function($menu){ 247 var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0]; 248 sf.op = sf.o[menu.serial]; 249 return menu; 250 }, 251 addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); }; 252 253 return this.each(function() { 254 var s = this.serial = sf.o.length; 255 var o = $.extend({},sf.defaults,op); 256 o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels), 257 p = o.$path; 258 for (var l = 0; l < p.length; l++){ 259 p.eq(l).addClass([o.hoverClass,c.bcClass].join(' ')).filter('li:has(ul)').removeClass(o.pathClass); 260 } 261 sf.o[s] = sf.op = o; 262 263 $('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() { 264 if (o.autoArrows) addArrow( $(this).children('a:first-child, span.nolink:first-child') ); 265 }) 266 .not('.'+c.bcClass) 267 .hideSuperfishUl(); 268 269 var $a = $('a, span.nolink',this); 270 $a.each(function(i){ 271 var $li = $a.eq(i).parents('li'); 272 $a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);}); 273 }); 274 o.onInit.call(this); 275 276 }).each(function() { 277 var menuClasses = [c.menuClass], 278 addShadow = true; 279 if ($.browser !== undefined){ 280 if ($.browser.msie && $.browser.version < 7){ 281 addShadow = false; 282 } 283 } 284 if (sf.op.dropShadows && addShadow){ 285 menuClasses.push(c.shadowClass); 286 } 287 $(this).addClass(menuClasses.join(' ')); 288 }); 289 }; 290 291 var sf = $.fn.superfish; 292 sf.o = []; 293 sf.op = {}; 294 sf.IE7fix = function(){ 295 var o = sf.op; 296 if ($.browser !== undefined){ 297 if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity != undefined) { 298 this.toggleClass(sf.c.shadowClass+'-off'); 299 } 300 } 301 }; 302 sf.c = { 303 bcClass: 'sf-breadcrumb', 304 menuClass: 'sf-js-enabled', 305 anchorClass: 'sf-with-ul', 306 arrowClass: 'sf-sub-indicator', 307 shadowClass: 'sf-shadow' 308 }; 309 sf.defaults = { 310 hoverClass: 'sfHover', 311 pathClass: 'overideThisToUse', 312 pathLevels: 1, 313 delay: 800, 314 animation: {opacity:'show'}, 315 speed: 'fast', 316 autoArrows: true, 317 dropShadows: true, 318 disableHI: false, // true disables hoverIntent detection 319 onInit: function(){}, // callback functions 320 onBeforeShow: function(){}, 321 onShow: function(){}, 322 onHide: function(){} 323 }; 324 $.fn.extend({ 325 hideSuperfishUl : function(){ 326 var o = sf.op, 327 not = (o.retainPath===true) ? o.$path : ''; 328 o.retainPath = false; 329 var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass) 330 .children('ul').addClass('sf-hidden'); 331 o.onHide.call($ul); 332 return this; 333 }, 334 showSuperfishUl : function(){ 335 var o = sf.op, 336 sh = sf.c.shadowClass+'-off', 337 $ul = this.addClass(o.hoverClass) 338 .children('ul.sf-hidden').hide().removeClass('sf-hidden'); 339 sf.IE7fix.call($ul); 340 o.onBeforeShow.call($ul); 341 $ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); }); 342 return this; 343 } 344 }); 345})(jQuery);; 346/* 347 * Supposition v0.2 - an optional enhancer for Superfish jQuery menu widget. 348 * 349 * Copyright (c) 2008 Joel Birch - based mostly on work by Jesse Klaasse and credit goes largely to him. 350 * Special thanks to Karl Swedberg for valuable input. 351 * 352 * Dual licensed under the MIT and GPL licenses: 353 * http://www.opensource.org/licenses/mit-license.php 354 * http://www.gnu.org/licenses/gpl.html 355 */ 356/* 357 * This is not the original jQuery Supposition plugin. 358 * Please refer to the README for more information. 359 */ 360 361(function($){ 362 $.fn.supposition = function(){ 363 var $w = $(window), /*do this once instead of every onBeforeShow call*/ 364 _offset = function(dir) { 365 return window[dir == 'y' ? 'pageYOffset' : 'pageXOffset'] 366 || document.documentElement && document.documentElement[dir=='y' ? 'scrollTop' : 'scrollLeft'] 367 || document.body[dir=='y' ? 'scrollTop' : 'scrollLeft']; 368 }, 369 onHide = function(){ 370 this.css({bottom:''}); 371 }, 372 onBeforeShow = function(){ 373 this.each(function(){ 374 var $u = $(this); 375 $u.css('display','block'); 376 var $mul = $u.closest('.sf-menu'), 377 level = $u.parents('ul').length, 378 menuWidth = $u.width(), 379 menuParentWidth = $u.closest('li').outerWidth(true), 380 menuParentLeft = $u.closest('li').offset().left, 381 totalRight = $w.width() + _offset('x'), 382 menuRight = $u.offset().left + menuWidth, 383 exactMenuWidth = (menuRight > (menuParentWidth + menuParentLeft)) ? menuWidth - (menuRight - (menuParentWidth + menuParentLeft)) : menuWidth; 384 if ($u.parents('.sf-js-enabled').hasClass('rtl')) { 385 if (menuParentLeft < exactMenuWidth) { 386 if (($mul.hasClass('sf-horizontal') && level == 1) || ($mul.hasClass('sf-navbar') && level == 2)){ 387 $u.css({left:0,right:'auto'}); 388 } 389 else { 390 $u.css({left:menuParentWidth + 'px',right:'auto'}); 391 } 392 } 393 } 394 else { 395 if (menuRight > totalRight && menuParentLeft > menuWidth) { 396 if (($mul.hasClass('sf-horizontal') && level == 1) || ($mul.hasClass('sf-navbar') && level == 2)){ 397 $u.css({right:0,left:'auto'}); 398 } 399 else { 400 $u.css({right:menuParentWidth + 'px',left:'auto'}); 401 } 402 } 403 } 404 var windowHeight = $w.height(), 405 offsetTop = $u.offset().top, 406 menuParentShadow = ($mul.hasClass('sf-shadow') && $u.css('padding-bottom').length > 0) ? parseInt($u.css('padding-bottom').slice(0,-2)) : 0, 407 menuParentHeight = ($mul.hasClass('sf-vertical')) ? '-' + menuParentShadow : $u.parent().outerHeight(true) - menuParentShadow, 408 menuHeight = $u.height(), 409 baseline = windowHeight + _offset('y'); 410 var expandUp = ((offsetTop + menuHeight > baseline) && (offsetTop > menuHeight)); 411 if (expandUp) { 412 $u.css({bottom:menuParentHeight + 'px',top:'auto'}); 413 } 414 $u.css('display','none'); 415 }); 416 }; 417 418 return this.each(function() { 419 var o = $.fn.superfish.o[this.serial]; /* get this menu's options */ 420 421 /* if callbacks already set, store them */ 422 var _onBeforeShow = o.onBeforeShow, 423 _onHide = o.onHide; 424 425 $.extend($.fn.superfish.o[this.serial],{ 426 onBeforeShow: function() { 427 onBeforeShow.call(this); /* fire our Supposition callback */ 428 _onBeforeShow.call(this); /* fire stored callbacks */ 429 }, 430 onHide: function() { 431 onHide.call(this); /* fire our Supposition callback */ 432 _onHide.call(this); /* fire stored callbacks */ 433 } 434 }); 435 });
436 }; 437})(jQuery);; 438/* 439 * sf-Smallscreen v1.2b - Provides small-screen compatibility for the jQuery Superfish plugin. 440 * 441 * Developer's note: 442 * Built as a part of the Superfish project for Drupal (http://drupal.org/project/superfish) 443 * Found any bug? have any cool ideas? contact me right away! http://drupal.org/user/619294/contact 444 * 445 * jQuery version: 1.3.x or higher. 446 * 447 * Dual licensed under the MIT and GPL licenses: 448 * http://www.opensource.org/licenses/mit-license.php 449 * http://www.gnu.org/licenses/gpl.html 450 */ 451 452(function($){ 453 $.fn.sfsmallscreen = function(options){ 454 options = $.extend({ 455 mode: 'inactive', 456 type: 'accordion', 457 breakpoint: 768, 458 breakpointUnit: 'px', 459 useragent: '', 460 title: '', 461 addSelected: false, 462 menuClasses: false, 463 hyperlinkClasses: false, 464 excludeClass_menu: '', 465 excludeClass_hyperlink: '', 466 includeClass_menu: '', 467 includeClass_hyperlink: '', 468 accordionButton: 1, 469 expandText: 'Expand', 470 collapseText: 'Collapse' 471 }, options); 472 473 // We need to clean up the menu from anything unnecessary. 474 function refine(menu){ 475 var 476 refined = menu.clone(), 477 // Things that should not be in the small-screen menus. 478 rm = refined.find('span.sf-sub-indicator, span.sf-description'), 479 // This is a helper class for those who need to add extra markup that shouldn't exist 480 // in the small-screen versions. 481 rh = refined.find('.sf-smallscreen-remove'), 482 // Mega-menus has to be removed too. 483 mm = refined.find('ul.sf-megamenu'); 484 for (var a = 0; a < rh.length; a++){ 485 rh.eq(a).replaceWith(rh.eq(a).html()); 486 } 487 for (var b = 0; b < rm.length; b++){ 488 rm.eq(b).remove(); 489 } 490 if (mm.length > 0){ 491 mm.removeClass('sf-megamenu'); 492 var ol = refined.find('div.sf-megamenu-column > ol'); 493 for (var o = 0; o < ol.length; o++){ 494 ol.eq(o).replaceWith('<ul>' + ol.eq(o).html() + '</ul>'); 495 } 496 var elements = ['div.sf-megamenu-column','.sf-megamenu-wrapper > ol','li.sf-megamenu-wrapper']; 497 for (var i = 0; i < elements.length; i++){ 498 obj = refined.find(elements[i]); 499 for (var t = 0; t < obj.length; t++){ 500 obj.eq(t).replaceWith(obj.eq(t).html()); 501 } 502 } 503 refined.find('.sf-megamenu-column').removeClass('sf-megamenu-column'); 504 } 505 refined.add(refined.find('*')).css({width:''}); 506 return refined; 507 } 508 509 // Creating <option> elements out of the menu. 510 function toSelect(menu, level){ 511 var 512 items = '', 513 childLI = $(menu).children('li'); 514 for (var a = 0; a < childLI.length; a++){ 515 var list = childLI.eq(a), parent = list.children('a, span'); 516 for (var b = 0; b < parent.length; b++){ 517 var 518 item = parent.eq(b), 519 path = item.is('a') ? item.attr('href') : '', 520 // Class names modification. 521 itemClone = item.clone(), 522 classes = (options.hyperlinkClasses) ? ((options.excludeClass_hyperlink && itemClone.hasClass(options.excludeClass_hyperlink)) ? itemClone.removeClass(options.excludeClass_hyperlink).attr('class') : itemClone.attr('class')) : '', 523 classes = (options.includeClass_hyperlink && !itemClone.hasClass(options.includeClass_hyperlink)) ? ((options.hyperlinkClasses) ? itemClone.addClass(options.includeClass_hyperlink).attr('class') : options.includeClass_hyperlink) : classes; 524 // Retaining the active class if requested. 525 if (options.addSelected && item.hasClass('active')){ 526 classes += ' active'; 527 } 528 // <option> has to be disabled if the item is not a link. 529 disable = item.is('span') || item.attr('href')=='#' ? ' disabled="disabled"' : '', 530 // Crystal clear. 531 subIndicator = 1 < level ? Array(level).join('-') + ' ' : ''; 532 // Preparing the <option> element. 533 items += '<option value="' + path + '" class="' + classes + '"' + disable + '>' + subIndicator + $.trim(item.text()) +'</option>', 534 childUL = list.find('> ul'); 535 // Using the function for the sub-menu of this item. 536 for (var u = 0; u < childUL.length; u++){
537 items += toSelect(childUL.eq(u), level + 1); 538 } 539 } 540 } 541 return items; 542 } 543 544 // Create the new version, hide the original. 545 function convert(menu){ 546 var menuID = menu.attr('id'), 547 // Creating a refined version of the menu. 548 refinedMenu = refine(menu); 549 // Currently the plugin provides two reactions to small screens. 550 // Converting the menu to a <select> element, and converting to an accordion version of the menu. 551 if (options.type == 'accordion'){ 552 var 553 toggleID = menuID + '-toggle', 554 accordionID = menuID + '-accordion'; 555 // Making sure the accordion does not exist. 556 if ($('#' + accordionID).length == 0){ 557 var 558 // Getting the style class. 559 styleClass = menu.attr('class').split(' ').filter(function(item){ 560 return item.indexOf('sf-style-') > -1 ? item : ''; 561 }), 562 // Creating the accordion. 563 accordion = $(refinedMenu).attr('id', accordionID); 564 // Removing unnecessary classes. 565 accordion.removeClass('sf-horizontal sf-vertical sf-navbar sf-shadow sf-js-enabled'); 566 // Adding necessary classes. 567 accordion.addClass('sf-accordion sf-hidden'); 568 // Removing style attributes and any unnecessary class. 569 accordion.children('li').removeAttr('style').removeClass('sfHover'); 570 // Doing the same and making sure all the sub-menus are off-screen (hidden). 571 accordion.find('ul').removeAttr('style').not('.sf-hidden').addClass('sf-hidden'); 572 // Creating the accordion toggle switch. 573 var toggle = '<div class="sf-accordion-toggle ' + styleClass + '"><a href="#" id="' + toggleID + '"><span>' + options.title + '</span></a></div>'; 574 575 // Adding Expand\Collapse buttons if requested. 576 if (options.accordionButton == 2){ 577 var parent = accordion.find('li.menuparent'); 578 for (var i = 0; i < parent.length; i++){ 579 parent.eq(i).prepend('<a href="#" class="sf-accordion-button">' + options.expandText + '</a>'); 580 } 581 } 582 // Inserting the according and hiding the original menu. 583 menu.before(toggle).before(accordion).hide(); 584 585 var 586 accordionElement = $('#' + accordionID), 587 // Deciding what should be used as accordion buttons. 588 buttonElement = (options.accordionButton < 2) ? 'a.menuparent,span.nolink.menuparent' : 'a.sf-accordion-button', 589 button = accordionElement.find(buttonElement); 590 591 // Attaching a click event to the toggle switch. 592 $('#' + toggleID).bind('click', function(e){ 593 // Preventing the click. 594 e.preventDefault(); 595 // Adding the sf-expanded class. 596 $(this).toggleClass('sf-expanded'); 597 598 if (accordionElement.hasClass('sf-expanded')){ 599 // If the accordion is already expanded: 600 // Hiding its expanded sub-menus and then the accordion itself as well. 601 accordionElement.add(accordionElement.find('li.sf-expanded')).removeClass('sf-expanded') 602 .end().find('ul').hide() 603 // This is a bit tricky, it's the same trick that has been in use in the main plugin for sometime. 604 // Basically we'll add a class that keeps the sub-menu off-screen and still visible, 605 // and make it invisible and removing the class one moment before showing or hiding it. 606 // This helps screen reader software access all the menu items. 607 .end().hide().addClass('sf-hidden').show(); 608 // Changing the caption of any existing accordion buttons to 'Expand'. 609 if (options.accordionButton == 2){ 610 accordionElement.find('a.sf-accordion-button').text(options.expandText); 611 } 612 } 613 else { 614 // But if it's collapsed, 615 accordionElement.addClass('sf-expanded').hide().removeClass('sf-hidden').show(); 616 } 617 }); 618 619 // Attaching a click event to the buttons. 620 button.bind('click', function(e){
621 // Making sure the buttons does not exist already. 622 if ($(this).closest('li').children('ul').length > 0){ 623 e.preventDefault(); 624 // Selecting the parent menu items. 625 var parent = $(this).closest('li'); 626 // Creating and inserting Expand\Collapse buttons to the parent menu items, 627 // of course only if not already happened. 628 if (options.accordionButton == 1 && parent.children('a.menuparent,span.nolink.menuparent').length > 0 && parent.children('ul').children('li.sf-clone-parent').length == 0){ 629 var 630 // Cloning the hyperlink of the parent menu item. 631 cloneLink = parent.children('a.menuparent,span.nolink.menuparent').clone(), 632 // Wrapping the hyerplinks in <li>. 633 cloneLink = $('<li class="sf-clone-parent" />').html(cloneLink); 634 // Adding a helper class and attaching them to the sub-menus. 635 parent.children('ul').addClass('sf-has-clone-parent').prepend(cloneLink); 636 } 637 // Once the button is clicked, collapse the sub-menu if it's expanded. 638 if (parent.hasClass('sf-expanded')){ 639 parent.children('ul').slideUp('fast', function(){ 640 // Doing the accessibility trick after hiding the sub-menu. 641 $(this).closest('li').removeClass('sf-expanded').end().addClass('sf-hidden').show(); 642 }); 643 // Changing the caption of the inserted Collapse link to 'Expand', if any is inserted. 644 if (options.accordionButton == 2 && parent.children('.sf-accordion-button').length > 0){ 645 parent.children('.sf-accordion-button').text(options.expandText); 646 } 647 } 648 // Otherwise, expand the sub-menu. 649 else { 650 // Doing the accessibility trick and then showing the sub-menu. 651 parent.children('ul').hide().removeClass('sf-hidden').slideDown('fast') 652 // Changing the caption of the inserted Expand link to 'Collape', if any is inserted. 653 .end().addClass('sf-expanded').children('a.sf-accordion-button').text(options.collapseText) 654 // Hiding any expanded sub-menu of the same level. 655 .end().siblings('li.sf-expanded').children('ul') 656 .slideUp('fast', function(){ 657 // Doing the accessibility trick after hiding it. 658 $(this).closest('li').removeClass('sf-expanded').end().addClass('sf-hidden').show(); 659 }) 660 // Assuming Expand\Collapse buttons do exist, resetting captions, in those hidden sub-menus. 661 .parent().children('a.sf-accordion-button').text(options.expandText); 662 } 663 } 664 }); 665 } 666 } 667 else { 668 var 669 // Class names modification. 670 menuClone = menu.clone(), classes = (options.menuClasses) ? ((options.excludeClass_menu && menuClone.hasClass(options.excludeClass_menu)) ? menuClone.removeClass(options.excludeClass_menu).attr('class') : menuClone.attr('class')) : '', 671 classes = (options.includeClass_menu && !menuClone.hasClass(options.includeClass_menu)) ? ((options.menuClasses) ? menuClone.addClass(options.includeClass_menu).attr('class') : options.includeClass_menu) : classes, 672 classes = (classes) ? ' class="' + classes + '"' : ''; 673 674 // Making sure the <select> element does not exist already. 675 if ($('#' + menuID + '-select').length == 0){ 676 // Creating the <option> elements. 677 var newMenu = toSelect(refinedMenu, 1), 678 // Creating the <select> element and assigning an ID and class name. 679 selectList = $('<select' + classes + ' id="' + menuID + '-select"/>') 680 // Attaching the title and the items to the <select> element. 681 .html('<option>' + options.title + '</option>' + newMenu) 682 // Attaching an event then. 683 .change(function(){ 684 // Except for the first option that is the menu title and not a real menu item. 685 if ($('option:selected', this).index()){ 686 window.location = selectList.val(); 687 } 688 }); 689 // Applying the addSelected option to it. 690 if (options.addSelected){ 691 selectList.find('.active').attr('selected', !0); 692 } 693 // Finally inserting the <select> element into the document then hiding the original menu. 694 menu.before(selectList).hide(); 695 } 696 } 697 } 698 699 // Turn everything back to normal. 700 function turnBack(menu){ 701 var 702 id = '#' + menu.attr('id'); 703 // Removing the small screen version. 704 $(id + '-' + options.type).remove(); 705 // Removing the accordion toggle switch as well. 706 if (options.type == 'accordion'){ 707 $(id + '-toggle').parent('div').remove(); 708 } 709 // Crystal clear! 710 $(id).show(); 711 } 712
713 // Return original object to support chaining. 714 // Although this is unnecessary because of the way the module uses these plugins. 715 for (var s = 0; s < this.length; s++){ 716 var 717 menu = $(this).eq(s), 718 mode = options.mode; 719 // The rest is crystal clear, isn't it? :) 720 if (mode == 'always_active'){ 721 convert(menu); 722 } 723 else if (mode == 'window_width'){ 724 var breakpoint = (options.breakpointUnit == 'em') ? (options.breakpoint * parseFloat($('body').css('font-size'))) : options.breakpoint, 725 windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, 726 timer; 727 if ((typeof Modernizr === 'undefined' || typeof Modernizr.mq !== 'function') && windowWidth < breakpoint){ 728 convert(menu); 729 } 730 else if (typeof Modernizr !== 'undefined' && typeof Modernizr.mq === 'function' && Modernizr.mq('(max-width:' + (breakpoint - 1) + 'px)')) { 731 convert(menu); 732 } 733 $(window).resize(function(){ 734 clearTimeout(timer); 735 timer = setTimeout(function(){ 736 var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; 737 if ((typeof Modernizr === 'undefined' || typeof Modernizr.mq !== 'function') && windowWidth < breakpoint){ 738 convert(menu); 739 } 740 else if (typeof Modernizr !== 'undefined' && typeof Modernizr.mq === 'function' && Modernizr.mq('(max-width:' + (breakpoint - 1) + 'px)')) { 741 convert(menu); 742 } 743 else { 744 turnBack(menu); 745 } 746 }, 50); 747 }); 748 } 749 else if (mode == 'useragent_custom'){ 750 if (options.useragent != ''){ 751 var ua = RegExp(options.useragent, 'i'); 752 if (navigator.userAgent.match(ua)){ 753 convert(menu); 754 } 755 } 756 } 757 else if (mode == 'useragent_predefined' && navigator.userAgent.match(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i)){ 758 convert(menu); 759 } 760 } 761 return this; 762 } 763})(jQuery); 764; 765/* 766 * Supersubs v0.4b - jQuery plugin 767 * Copyright (c) 2013 Joel Birch 768 * 769 * Dual licensed under the MIT and GPL licenses: 770 * http://www.opensource.org/licenses/mit-license.php 771 * http://www.gnu.org/licenses/gpl.html 772 * 773 * This plugin automatically adjusts submenu widths of suckerfish-style menus to that of 774 * their longest list item children. If you use this, please expect bugs and report them 775 * to the jQuery Google Group with the word 'Superfish' in the subject line. 776 * 777 */ 778/* 779 * This is not the original jQuery Supersubs plugin. 780 * Please refer to the README for more information. 781 */ 782 783(function($){ // $ will refer to jQuery within this closure 784 $.fn.supersubs = function(options){ 785 var opts = $.extend({}, $.fn.supersubs.defaults, options); 786 // return original object to support chaining 787 // Although this is unnecessary due to the way the module uses these plugins. 788 for (var a = 0; a < this.length; a++) { 789 // cache selections 790 var $$ = $(this).eq(a), 791 // support metadata 792 o = $.meta ? $.extend({}, opts, $$.data()) : opts; 793 // Jump one level if it's a "NavBar" 794 if ($$.hasClass('sf-navbar')) { 795 $$ = $$.children('li').children('ul'); 796 } 797 // cache all ul elements 798 var $ULs = $$.find('ul'), 799 // get the font size of menu. 800 // .css('fontSize') returns various results cross-browser, so measure an em dash instead 801 fontsize = $('<li id="menu-fontsize">—</li>'), 802 size = fontsize.attr('style','padding:0;position:absolute;top:-99999em;width:auto;') 803 .appendTo($$)[0].clientWidth; //clientWidth is faster than width() 804 // remove em dash 805 fontsize.remove(); 806 807 // loop through each ul in menu 808 for (var b = 0; b < $ULs.length; b++) { 809 var 810 // cache this ul 811 $ul = $ULs.eq(b);
812 // If a multi-column sub-menu, and only if correctly configured. 813 if (o.megamenu && $ul.hasClass('sf-megamenu') && $ul.find('.sf-megamenu-column').length > 0){ 814 // Look through each column. 815 var $column = $ul.find('div.sf-megamenu-column > ol'), 816 // Overall width. 817 mwWidth = 0; 818 for (var d = 0; d < $column.length; d++){ 819 resize($column.eq(d)); 820 // New column width, in pixels. 821 var colWidth = $column.width(); 822 // Just a trick to convert em unit to px. 823 $column.css({width:colWidth}) 824 // Making column parents the same size. 825 .parents('.sf-megamenu-column').css({width:colWidth}); 826 // Overall width. 827 mwWidth += parseInt(colWidth); 828 } 829 // Resizing the columns container too. 830 $ul.add($ul.find('li.sf-megamenu-wrapper, li.sf-megamenu-wrapper > ol')).css({width:mwWidth}); 831 } 832 else { 833 resize($ul); 834 } 835 } 836 } 837 function resize($ul){ 838 var 839 // get all (li) children of this ul 840 $LIs = $ul.children(), 841 // get all anchor grand-children 842 $As = $LIs.children('a'); 843 // force content to one line and save current float property 844 $LIs.css('white-space','nowrap'); 845 // remove width restrictions and floats so elements remain vertically stacked 846 $ul.add($LIs).add($As).css({float:'none',width:'auto'}); 847 // this ul will now be shrink-wrapped to longest li due to position:absolute 848 // so save its width as ems. 849 var emWidth = $ul.get(0).clientWidth / size; 850 // add more width to ensure lines don't turn over at certain sizes in various browsers 851 emWidth += o.extraWidth; 852 // restrict to at least minWidth and at most maxWidth 853 if (emWidth > o.maxWidth) {emWidth = o.maxWidth;} 854 else if (emWidth < o.minWidth) {emWidth = o.minWidth;} 855 emWidth += 'em'; 856 // set ul to width in ems 857 $ul.css({width:emWidth}); 858 // restore li floats to avoid IE bugs 859 // set li width to full width of this ul 860 // revert white-space to normal 861 $LIs.add($As).css({float:'',width:'',whiteSpace:''}); 862 // update offset position of descendant ul to reflect new width of parent. 863 // set it to 100% in case it isn't already set to this in the CSS 864 for (var c = 0; c < $LIs.length; c++) { 865 var $childUl = $LIs.eq(c).children('ul'); 866 var offsetDirection = $childUl.css('left') !== undefined ? 'left' : 'right'; 867 $childUl.css(offsetDirection,'100%'); 868 } 869 } 870 return this; 871 }; 872 // expose defaults 873 $.fn.supersubs.defaults = { 874 megamenu: true, // define width for multi-column sub-menus and their columns. 875 minWidth: 12, // requires em unit. 876 maxWidth: 27, // requires em unit. 877 extraWidth: 1 // extra width can ensure lines don't sometimes turn over due to slight browser differences in how they round-off values 878 }; 879})(jQuery); // plugin code ends 880; 881/** 882 * @file 883 * The Superfish Drupal Behavior to apply the Superfish jQuery plugin to lists. 884 */ 885 886(function ($) { 887 Drupal.behaviors.superfish = { 888 attach: function (context, settings) { 889 // Take a look at each list to apply Superfish to. 890 $.each(settings.superfish || {}, function(index, options) { 891 // Process all Superfish lists. 892 $('#superfish-' + options.id, context).once('superfish', function() { 893 var list = $(this); 894 895 // Check if we are to apply the Supersubs plug-in to it. 896 if (options.plugins || false) { 897 if (options.plugins.supersubs || false) { 898 list.supersubs(options.plugins.supersubs); 899 } 900 } 901 902 // Apply Superfish to the list. 903 list.superfish(options.sf); 904 905 // Check if we are to apply any other plug-in to it. 906 if (options.plugins || false) { 907 if (options.plugins.touchscreen || false) { 908 list.sftouchscreen(options.plugins.touchscreen); 909 } 910 if (options.plugins.smallscreen || false) { 911 list.sfsmallscreen(options.plugins.smallscreen); 912 } 913 if (options.plugins.automaticwidth || false) { 914 list.sfautomaticwidth(); 915 } 916 if (options.plugins.supposition || false) { 917 list.supposition(); 918 } 919 if (options.plugins.bgiframe || false) { 920 list.find('ul').bgIframe({opacity:false}); 921 } 922 } 923 }); 924 }); 925 } 926 }; 927})(jQuery);;
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.