1/* 2 * sf-Smallscreen v1.0b - Provides small-screen compatibility 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.sfsmallscreen = function(options){ 17 options = $.extend({ 18 mode: 'inactive', 19 breakpoint: 768, 20 useragent: '', 21 title: '', 22 addSelected: true, 23 menuClasses: true, 24 hyperlinkClasses: true, 25 excludeClass_menu: '', 26 excludeClass_hyperlink: '', 27 includeClass_menu: '', 28 includeClass_hyperlink: '' 29 }, options); 30 31 // We need to clean up the menu from anything unnecessary. 32 function refine(menu){ 33 if ($('.sf-megamenu', menu).length > 0){ 34 var refined = menu.clone(); 35 refined.find('div.sf-megamenu-column > ol').each(function(){ 36 $(this).replaceWith('<ul>' + $(this).html() + '</ul>'); 37 }); 38 refined.find('div.sf-megamenu-column').each(function(){ 39 $(this).replaceWith($(this).html()); 40 }).end().find('.sf-megamenu-wrapper > ol').each(function(){ 41 $(this).replaceWith($(this).html()); 42 }).end().find('li.sf-megamenu-wrapper').each(function(){ 43 $(this).replaceWith($(this).html()); 44 }); 45 } else { 46 var refined = menu.clone(); 47 } 48 refined.find('.sf-smallscreen-remove').each(function(){ 49 $(this).replaceWith($(this).html()); 50 }).end().find('.sf-sub-indicator, .sf-description').each(function(){ 51 $(this).remove(); 52 }); 53 return refined; 54 } 55 56 // Currently the only available reaction is converting the menu into a <select> element; 57 // In the next version there will be another reaction that will create a "compact" version of 58 // the menu, using <ul> element hence easy to style with CSS and so on and so forth. 59 function toSelect(menu, level){ 60 var items = ''; 61 $(menu).children('li').each(function(){ 62 var list = $(this); 63 list.children('a, span').each(function(){ 64 var item = $(this), 65 path = item.is('a') ? item.attr('href') : '', 66 itemClone = item.clone(), 67 classes = (options.hyperlinkClasses) ? ((options.excludeClass_hyperlink && itemClone.hasClass(options.excludeClass_hyperlink)) ? itemClone.removeClass(options.excludeClass_hyperlink).attr('class') : itemClone.attr('class')) : '', 68 classes = (options.includeClass_hyperlink && !itemClone.hasClass(options.includeClass_hyperlink)) ? ((options.hyperlinkClasses) ? itemClone.addClass(options.includeClass_hyperlink).attr('class') : options.includeClass_hyperlink) : classes, 69 classes = (classes) ? ' class="' + classes + '"' : '', 70 disable = item.is('span') ? ' disabled="disabled"' : '', 71 subIndicator = 1 < level ? Array(level).join('-') + ' ' : ''; 72 items += '<option value="' + path + '"' + classes + disable + '>' + subIndicator + $.trim(item.text()) +'</option>'; 73 list.find('> ul').each(function(){ 74 items += toSelect(this, level + 1); 75 }); 76 }); 77 }); 78 return items; 79 } 80 81 // Create the new version, hide the original. 82 function convert(menu){ 83 var menuClone = menu.clone(), classes = (options.menuClasses) ? ((options.excludeClass_menu && menuClone.hasClass(options.excludeClass_menu)) ? menuClone.removeClass(options.excludeClass_menu).attr('class') : menuClone.attr('class')) : '', 84 classes = (options.includeClass_menu && !menuClone.hasClass(options.includeClass_menu)) ? ((options.menuClasses) ? menuClone.addClass(options.includeClass_menu).attr('class') : options.includeClass_menu) : classes, 85 classes = (classes) ? ' class="' + classes + '"' : ''; 86 if ($('#' + menu.attr('id') + '-select').length == 0){ 87 var selectList = $('<select' + classes + ' id="' + menu.attr('id') + '-select"/>'), 88 refinedMenu = refine(menu); 89 newMenu = toSelect(refinedMenu, 1);
90 selectList.append('<option>' + options.title + '</option>').append(newMenu).change(function(){ 91 window.location = selectList.val(); 92 }); 93 if (options.addSelected) { 94 selectList.find('.active').attr("selected", !0); 95 } 96 menu.before(selectList).hide(); 97 } 98 } 99 100 // Turn everything back to normal. 101 function turnBack(menu){ 102 var id = '#' + menu.attr('id'); 103 $(id + '-select').remove(); 104 $(id).show(); 105 } 106 107 // Return original object to support chaining. 108 return this.each(function(){ 109 var menu = $(this), 110 mode = options.mode; 111 // The rest is crystal clear, isn't it? :) 112 switch (mode){ 113 case 'always_active' : 114 convert(menu); 115 break; 116 case 'window_width' : 117 if ($(window).width() < options.breakpoint){ 118 convert(menu); 119 } 120 var timer; 121 $(window).resize(function(){ 122 clearTimeout(timer); 123 timer = setTimeout(function(){ 124 if ($(window).width() < options.breakpoint){ 125 convert(menu); 126 } 127 else { 128 turnBack(menu); 129 } 130 }, 100); 131 }); 132 break; 133 case 'useragent_custom' : 134 if (options.useragent != ''){ 135 var ua = RegExp(options.useragent, 'i'); 136 if (navigator.userAgent.match(ua)){ 137 convert(menu); 138 } 139 } 140 break; 141 case 'useragent_predefined' : 142 if (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)){ 143 convert(menu); 144 } 145 break; 146 } 147 }); 148 }; 149})(jQuery);; 150/** 151* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+ 152* <http://cherne.net/brian/resources/jquery.hoverIntent.html> 153* 154* @param f onMouseOver function || An object with configuration options 155* @param g onMouseOut function || Nothing (use configuration options object) 156* @author Brian Cherne brian(at)cherne(dot)net 157*/ 158(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);; 159/* 160 * Supposition v0.2 - an optional enhancer for Superfish jQuery menu widget. 161 * 162 * Copyright (c) 2008 Joel Birch - based mostly on work by Jesse Klaasse and credit goes largely to him. 163 * Special thanks to Karl Swedberg for valuable input. 164 * 165 * Dual licensed under the MIT and GPL licenses: 166 * http://www.opensource.org/licenses/mit-license.php 167 * http://www.gnu.org/licenses/gpl.html 168 */ 169/* 170 * This is not the original jQuery Supersubs plugin. 171 * Please refer to the README for more information. 172 */ 173 174(function($){ 175 $.fn.supposition = function(){ 176 var $w = $(window), /*do this once instead of every onBeforeShow call*/ 177 _offset = function(dir) { 178 return window[dir == 'y' ? 'pageYOffset' : 'pageXOffset'] 179 || document.documentElement && document.documentElement[dir=='y' ? 'scrollTop' : 'scrollLeft'] 180 || document.body[dir=='y' ? 'scrollTop' : 'scrollLeft']; 181 }, 182 onHide = function(){ 183 this.css({bottom:''}); 184 }, 185 onBeforeShow = function(){ 186 this.each(function(){ 187 var $u = $(this); 188 $u.css('display','block'); 189 var menuWidth = $u.width(), 190 menuParentWidth = $u.closest('li').outerWidth(true), 191 menuParentLeft = $u.closest('li').offset().left, 192 totalRight = $w.width() + _offset('x'), 193 menuRight = $u.offset().left + menuWidth, 194 exactMenuWidth = (menuRight > (menuParentWidth + menuParentLeft)) ? menuWidth - (menuRight - (menuParentWidth + menuParentLeft)) : menuWidth; 195 if ($u.parents('.sf-js-enabled').hasClass('rtl')) { 196 if (menuParentLeft < exactMenuWidth) { 197 $u.css('left', menuParentWidth + 'px'); 198 $u.css('right', 'auto'); 199 } 200 } 201 else { 202 if (menuRight > totalRight && menuParentLeft > menuWidth) { 203 $u.css('right', menuParentWidth + 'px'); 204 $u.css('left', 'auto'); 205 } 206 } 207 var windowHeight = $w.height(), 208 offsetTop = $u.offset().top, 209 menuParentShadow = ($u.closest('.sf-menu').hasClass('sf-shadow') && $u.css('padding-bottom').length > 0) ? parseInt($u.css('padding-bottom').slice(0,-2)) : 0, 210 menuParentHeight = ($u.closest('.sf-menu').hasClass('sf-vertical')) ? '-' + menuParentShadow : $u.parent().outerHeight(true) - menuParentShadow, 211 menuHeight = $u.height(), 212 baseline = windowHeight + _offset('y'); 213 var expandUp = ((offsetTop + menuHeight > baseline) && (offsetTop > menuHeight)); 214 if (expandUp) { 215 $u.css('bottom', menuParentHeight + 'px'); 216 $u.css('top', 'auto'); 217 } 218 $u.css('display','none'); 219 }); 220 }; 221 222 return this.each(function() { 223 var o = $.fn.superfish.o[this.serial]; /* get this menu's options */ 224 225 /* if callbacks already set, store them */ 226 var _onBeforeShow = o.onBeforeShow, 227 _onHide = o.onHide; 228 229 $.extend($.fn.superfish.o[this.serial],{ 230 onBeforeShow: function() { 231 onBeforeShow.call(this); /* fire our Supposition callback */ 232 _onBeforeShow.call(this); /* fire stored callbacks */ 233 }, 234 onHide: function() { 235 onHide.call(this); /* fire our Supposition callback */ 236 _onHide.call(this); /* fire stored callbacks */ 237 } 238 }); 239 }); 240 }; 241})(jQuery);; 242/* 243 * Superfish v1.4.8 - jQuery menu widget 244 * Copyright (c) 2008 Joel Birch 245 * 246 * Dual licensed under the MIT and GPL licenses: 247 * http://www.opensource.org/licenses/mit-license.php 248 * http://www.gnu.org/licenses/gpl.html 249 * 250 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt 251 */ 252/* 253 * This is not the original jQuery Supersubs plugin. 254 * Please refer to the README for more information. 255 */ 256 257(function($){ 258 $.fn.superfish = function(op){ 259 var sf = $.fn.superfish, 260 c = sf.c, 261 $arrow = $(['<span class="',c.arrowClass,'"> »</span>'].join('')), 262 over = function(){ 263 var $$ = $(this), menu = getMenu($$); 264 clearTimeout(menu.sfTimer); 265 $$.showSuperfishUl().siblings().hideSuperfishUl(); 266 }, 267 out = function(){ 268 var $$ = $(this), menu = getMenu($$), o = sf.op; 269 clearTimeout(menu.sfTimer); 270 menu.sfTimer=setTimeout(function(){ 271 o.retainPath=($.inArray($$[0],o.$path)>-1);
272 $$.hideSuperfishUl(); 273 if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);} 274 },o.delay); 275 }, 276 getMenu = function($menu){ 277 var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0]; 278 sf.op = sf.o[menu.serial]; 279 return menu; 280 }, 281 addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); }; 282 283 return this.each(function() { 284 var s = this.serial = sf.o.length; 285 var o = $.extend({},sf.defaults,op); 286 o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){ 287 $(this).addClass([o.hoverClass,c.bcClass].join(' ')) 288 .filter('li:has(ul)').removeClass(o.pathClass); 289 }); 290 sf.o[s] = sf.op = o; 291 292 $('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() { 293 if (o.autoArrows) addArrow( $('>a:first-child',this) ); 294 }) 295 .not('.'+c.bcClass) 296 .hideSuperfishUl(); 297 298 var $a = $('a',this); 299 $a.each(function(i){ 300 var $li = $a.eq(i).parents('li'); 301 $a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);}); 302 }); 303 o.onInit.call(this); 304 305 }).each(function() { 306 var menuClasses = [c.menuClass]; 307 if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass); 308 $(this).addClass(menuClasses.join(' ')); 309 }); 310 }; 311 312 var sf = $.fn.superfish; 313 sf.o = []; 314 sf.op = {}; 315 sf.IE7fix = function(){ 316 var o = sf.op; 317 if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined) 318 this.toggleClass(sf.c.shadowClass+'-off'); 319 }; 320 sf.c = { 321 bcClass: 'sf-breadcrumb', 322 menuClass: 'sf-js-enabled', 323 anchorClass: 'sf-with-ul', 324 arrowClass: 'sf-sub-indicator', 325 shadowClass: 'sf-shadow' 326 }; 327 sf.defaults = { 328 hoverClass: 'sfHover', 329 pathClass: 'overideThisToUse', 330 pathLevels: 1, 331 delay: 800, 332 animation: {opacity:'show'}, 333 speed: 'normal', 334 autoArrows: true, 335 dropShadows: true, 336 disableHI: false, // true disables hoverIntent detection 337 onInit: function(){}, // callback functions 338 onBeforeShow: function(){}, 339 onShow: function(){}, 340 onHide: function(){} 341 }; 342 $.fn.extend({ 343 hideSuperfishUl : function(){ 344 var o = sf.op, 345 not = (o.retainPath===true) ? o.$path : ''; 346 o.retainPath = false; 347 var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass) 348 .find('>ul').addClass('sf-hidden'); 349 o.onHide.call($ul); 350 return this; 351 }, 352 showSuperfishUl : function(){ 353 var o = sf.op, 354 sh = sf.c.shadowClass+'-off', 355 $ul = this.addClass(o.hoverClass) 356 .find('>ul.sf-hidden').hide().removeClass('sf-hidden'); 357 sf.IE7fix.call($ul); 358 o.onBeforeShow.call($ul); 359 $ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); }); 360 return this; 361 } 362 }); 363})(jQuery);; 364/* 365 * Supersubs v0.2b - jQuery plugin 366 * Copyright (c) 2008 Joel Birch 367 * 368 * Dual licensed under the MIT and GPL licenses: 369 * http://www.opensource.org/licenses/mit-license.php 370 * http://www.gnu.org/licenses/gpl.html 371 * 372 * This plugin automatically adjusts submenu widths of suckerfish-style menus to that of 373 * their longest list item children. If you use this, please expect bugs and report them 374 * to the jQuery Google Group with the word 'Superfish' in the subject line. 375 * 376 */ 377/* 378 * This is not the original jQuery Supersubs plugin. 379 * Please refer to the README for more information. 380 */ 381 382(function($){ // $ will refer to jQuery within this closure 383 $.fn.supersubs = function(options){ 384 var opts = $.extend({}, $.fn.supersubs.defaults, options); 385 // return original object to support chaining 386 return this.each(function() { 387 // cache selections 388 var $$ = $(this); 389 // support metadata 390 var o = $.meta ? $.extend({}, opts, $$.data()) : opts; 391 // get the font size of menu. 392 // .css('fontSize') returns various results cross-browser, so measure an em dash instead 393 var fontsize = $('<li id="menu-fontsize">—</li>').css({ 394 'padding' : 0, 395 'position' : 'absolute', 396 'top' : '-99999em', 397 'width' : 'auto' 398 }).appendTo($$).width(); //clientWidth is faster, but was incorrect here 399 // remove em dash 400 $('#menu-fontsize').remove(); 401 402 // Jump on level if it's a "NavBar" 403 if ($$.hasClass('sf-navbar')) { 404 $$ = $('li > ul', $$); 405 } 406 // cache all ul elements
407 $ULs = $$.find('ul:not(.sf-megamenu)'); 408 // loop through each ul in menu 409 $ULs.each(function(i) { 410 // cache this ul 411 var $ul = $ULs.eq(i); 412 // get all (li) children of this ul 413 var $LIs = $ul.children(); 414 // get all anchor grand-children 415 var $As = $LIs.children('a'); 416 // force content to one line and save current float property 417 var liFloat = $LIs.css('white-space','nowrap').css('float'); 418 // remove width restrictions and floats so elements remain vertically stacked 419 var emWidth = $ul.add($LIs).add($As).css({ 420 'float' : 'none', 421 'width' : 'auto' 422 }) 423 // this ul will now be shrink-wrapped to longest li due to position:absolute 424 // so save its width as ems. Clientwidth is 2 times faster than .width() - thanks Dan Switzer 425 .end().end()[0].clientWidth / fontsize; 426 // add more width to ensure lines don't turn over at certain sizes in various browsers 427 emWidth += o.extraWidth; 428 // restrict to at least minWidth and at most maxWidth 429 if (emWidth > o.maxWidth) { emWidth = o.maxWidth; } 430 else if (emWidth < o.minWidth) { emWidth = o.minWidth; } 431 emWidth += 'em'; 432 // set ul to width in ems 433 $ul.css('width',emWidth); 434 // restore li floats to avoid IE bugs 435 // set li width to full width of this ul 436 // revert white-space to normal 437 $LIs.css({ 438 'float' : liFloat, 439 'width' : '100%', 440 'white-space' : 'normal' 441 }) 442 // update offset position of descendant ul to reflect new width of parent 443 .each(function(){ 444 var $childUl = $('>ul',this); 445 var offsetDirection = $childUl.css('left')!==undefined ? 'left' : 'right'; 446 $childUl.css(offsetDirection,emWidth); 447 }); 448 }); 449 }); 450 }; 451 // expose defaults 452 $.fn.supersubs.defaults = { 453 minWidth: 9, // requires em unit. 454 maxWidth: 25, // requires em unit. 455 extraWidth: 0 // extra width can ensure lines don't sometimes turn over due to slight browser differences in how they round-off values 456 }; 457})(jQuery); // plugin code ends; 458/** 459 * @file 460 * The Superfish Drupal Behavior to apply the Superfish jQuery plugin to lists. 461 */ 462 463(function ($) { 464 Drupal.behaviors.superfish = { 465 attach: function (context, settings) { 466 // Take a look at each list to apply Superfish to. 467 $.each(settings.superfish || {}, function(index, options) { 468 // Process all Superfish lists. 469 $('#superfish-' + options.id, context).once('superfish', function() { 470 var list = $(this); 471 472 // Check if we are to apply the Supersubs plug-in to it. 473 if (options.plugins || false) { 474 if (options.plugins.supersubs || false) { 475 list.supersubs(options.plugins.supersubs); 476 } 477 } 478 479 // Apply Superfish to the list. 480 list.superfish(options.sf); 481 482 // Check if we are to apply any other plug-in to it. 483 if (options.plugins || false) { 484 if (options.plugins.touchscreen || false) { 485 list.sftouchscreen(options.plugins.touchscreen); 486 } 487 if (options.plugins.smallscreen || false) { 488 list.sfsmallscreen(options.plugins.smallscreen); 489 } 490 if (options.plugins.supposition || false) { 491 list.supposition(); 492 } 493 if (options.plugins.bgiframe || false) { 494 list.find('ul').bgIframe({opacity:false}); 495 } 496 } 497 }); 498 }); 499 } 500 }; 501})(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.