3 * Superfish v1.4.8 - jQuery menu widget
4 * Copyright (c) 2008 Joel Birch
6 * Dual licensed under the MIT and GPL licenses:
7 * http://www.opensource.org/licenses/mit-license.php
8 * http://www.gnu.org/licenses/gpl.html
10 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
14 $.fn
.superfish = function(op
){
16 var sf
= $.fn
.superfish
,
18 $arrow
= $(['<span class="',c
.arrowClass
,'"> »</span>'].join('')),
20 var $$ = $(this), menu
= getMenu($$);
21 clearTimeout(menu
.sfTimer
);
22 $$.showSuperfishUl().siblings().hideSuperfishUl();
25 var $$ = $(this), menu
= getMenu($$), o
= sf
.op
;
26 clearTimeout(menu
.sfTimer
);
27 menu
.sfTimer
=setTimeout(function(){
28 o
.retainPath
=($.inArray($$[0],o
.$path
)>-1);
30 if (o
.$path
.length
&& $$.parents(['li.',o
.hoverClass
].join('')).length
<1){over
.call(o
.$path
);}
33 getMenu = function($menu
){
34 var menu
= $menu
.parents(['ul.',c
.menuClass
,':first'].join(''))[0];
35 sf
.op
= sf
.o
[menu
.serial
];
38 addArrow = function($a
){ $a
.addClass(c
.anchorClass
).append($arrow
.clone()); };
40 return this.each(function() {
41 var s
= this.serial
= sf
.o
.length
;
42 var o
= $.extend({},sf
.defaults
,op
);
43 o
.$path
= $('li.'+o
.pathClass
,this).slice(0,o
.pathLevels
).each(function(){
44 $(this).addClass([o
.hoverClass
,c
.bcClass
].join(' '))
45 .filter('li:has(ul)').removeClass(o
.pathClass
);
49 $('li:has(ul)',this)[($.fn
.hoverIntent
&& !o
.disableHI
) ? 'hoverIntent' : 'hover'](over
,out
).each(function() {
50 if (o
.autoArrows
) addArrow( $('>a:first-child',this) );
57 var $li
= $a
.eq(i
).parents('li');
58 $a
.eq(i
).focus(function(){over
.call($li
);}).blur(function(){out
.call($li
);});
63 var menuClasses
= [c
.menuClass
];
64 if (sf
.op
.dropShadows
&& !($.browser
.msie
&& $.browser
.version
< 7)) menuClasses
.push(c
.shadowClass
);
65 $(this).addClass(menuClasses
.join(' '));
69 var sf
= $.fn
.superfish
;
72 sf
.IE7fix = function(){
74 if ($.browser
.msie
&& $.browser
.version
> 6 && o
.dropShadows
&& o
.animation
.opacity
!=undefined)
75 this.toggleClass(sf
.c
.shadowClass
+'-off');
78 bcClass
: 'sf-breadcrumb',
79 menuClass
: 'sf-js-enabled',
80 anchorClass
: 'sf-with-ul',
81 arrowClass
: 'sf-sub-indicator',
82 shadowClass
: 'sf-shadow'
85 hoverClass
: 'sfHover',
86 pathClass
: 'overideThisToUse',
89 animation
: {opacity
:'show'},
93 disableHI
: false, // true disables hoverIntent detection
94 onInit : function(){}, // callback functions
95 onBeforeShow: function(){},
96 onShow : function(){},
100 hideSuperfishUl : function(){
102 not
= (o
.retainPath
===true) ? o
.$path
: '';
103 o
.retainPath
= false;
104 var $ul
= $(['li.',o
.hoverClass
].join(''),this).add(this).not(not
).removeClass(o
.hoverClass
)
105 .find('>ul').hide().css('visibility','hidden');
109 showSuperfishUl : function(){
111 sh
= sf
.c
.shadowClass
+'-off',
112 $ul
= this.addClass(o
.hoverClass
)
113 .find('>ul:hidden').css('visibility','visible');
115 o
.onBeforeShow
.call($ul
);
116 $ul
.animate(o
.animation
,o
.speed
,function(){ sf
.IE7fix
.call($ul
); o
.onShow
.call($ul
); });