2 * Superfish v1.4.8 - jQuery menu widget
3 * Copyright (c) 2008 Joel Birch
5 * Dual licensed under the MIT and GPL licenses:
6 * http://www.opensource.org/licenses/mit-license.php
7 * http://www.gnu.org/licenses/gpl.html
9 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
12 * This is not the original jQuery Superfish plugin.
13 * Please refer to the README for more information.
17 $.fn.superfish = function(op){
18 var sf = $.fn.superfish,
20 $arrow = $(['<span class="',c.arrowClass,'"> »</span>'].join('')),
22 var $$ = $(this), menu = getMenu($$);
23 clearTimeout(menu.sfTimer);
24 $$.showSuperfishUl().siblings().hideSuperfishUl();
27 var $$ = $(this), menu = getMenu($$), o = sf.op;
28 clearTimeout(menu.sfTimer);
29 menu.sfTimer=setTimeout(function(){
30 if ($$.children('.sf-clicked').length == 0){
31 o.retainPath=($.inArray($$[0],o.$path)>-1);
33 if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
37 getMenu = function($menu){
38 var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
39 sf.op = sf.o[menu.serial];
42 addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
44 return this.each(function() {
45 var s = this.serial = sf.o.length;
46 var o = $.extend({},sf.defaults,op);
47 o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels),
49 for (var l = 0; l < p.length; l++){
50 p.eq(l).addClass([o.hoverClass,c.bcClass].join(' ')).filter('li:has(ul)').removeClass(o.pathClass);
54 $('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
55 if (o.autoArrows) addArrow( $(this).children('a:first-child, span.nolink:first-child') );
60 var $a = $('a, span.nolink',this);
62 var $li = $a.eq(i).parents('li');
63 $a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
68 var menuClasses = [c.menuClass];
69 if (sf.op.dropShadows){
70 menuClasses.push(c.shadowClass);
72 $(this).addClass(menuClasses.join(' '));
76 var sf = $.fn.superfish;
81 bcClass: 'sf-breadcrumb',
82 menuClass: 'sf-js-enabled',
83 anchorClass: 'sf-with-ul',
84 arrowClass: 'sf-sub-indicator',
85 shadowClass: 'sf-shadow'
88 hoverClass: 'sfHover',
89 pathClass: 'overideThisToUse',
92 animation: {opacity:'show'},
96 disableHI: false, // true disables hoverIntent detection
97 onInit: function(){}, // callback functions
98 onBeforeShow: function(){},
103 hideSuperfishUl : function(){
105 not = (o.retainPath===true) ? o.$path : '';
106 o.retainPath = false;
107 var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
108 .children('ul').addClass('sf-hidden');
112 showSuperfishUl : function(){
114 sh = sf.c.shadowClass+'-off',
115 $ul = this.addClass(o.hoverClass)
116 .children('ul.sf-hidden').hide().removeClass('sf-hidden');
117 o.onBeforeShow.call($ul);
118 $ul.animate(o.animation,o.speed,function(){ o.onShow.call($ul); });