1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
16
|
(function($){
|
17
|
$.fn.superfish = function(op){
|
18
|
var sf = $.fn.superfish,
|
19
|
c = sf.c,
|
20
|
$arrow = $(['<span class="',c.arrowClass,'"> »</span>'].join('')),
|
21
|
over = function(){
|
22
|
var $$ = $(this), menu = getMenu($$);
|
23
|
clearTimeout(menu.sfTimer);
|
24
|
$$.showSuperfishUl().siblings().hideSuperfishUl();
|
25
|
},
|
26
|
out = function(){
|
27
|
var $$ = $(this), menu = getMenu($$), o = sf.op;
|
28
|
clearTimeout(menu.sfTimer);
|
29
|
menu.sfTimer=setTimeout(function(){
|
30
|
o.retainPath=($.inArray($$[0],o.$path)>-1);
|
31
|
$$.hideSuperfishUl();
|
32
|
if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
|
33
|
},o.delay);
|
34
|
},
|
35
|
getMenu = function($menu){
|
36
|
var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
|
37
|
sf.op = sf.o[menu.serial];
|
38
|
return menu;
|
39
|
},
|
40
|
addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
|
41
|
|
42
|
return this.each(function() {
|
43
|
var s = this.serial = sf.o.length;
|
44
|
var o = $.extend({},sf.defaults,op);
|
45
|
o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
|
46
|
$(this).addClass([o.hoverClass,c.bcClass].join(' '))
|
47
|
.filter('li:has(ul)').removeClass(o.pathClass);
|
48
|
});
|
49
|
sf.o[s] = sf.op = o;
|
50
|
|
51
|
$('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
|
52
|
if (o.autoArrows) addArrow( $('>a:first-child',this) );
|
53
|
})
|
54
|
.not('.'+c.bcClass)
|
55
|
.hideSuperfishUl();
|
56
|
|
57
|
var $a = $('a',this);
|
58
|
$a.each(function(i){
|
59
|
var $li = $a.eq(i).parents('li');
|
60
|
$a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
|
61
|
});
|
62
|
o.onInit.call(this);
|
63
|
|
64
|
}).each(function() {
|
65
|
var menuClasses = [c.menuClass];
|
66
|
if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
|
67
|
$(this).addClass(menuClasses.join(' '));
|
68
|
});
|
69
|
};
|
70
|
|
71
|
var sf = $.fn.superfish;
|
72
|
sf.o = [];
|
73
|
sf.op = {};
|
74
|
sf.IE7fix = function(){
|
75
|
var o = sf.op;
|
76
|
if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
|
77
|
this.toggleClass(sf.c.shadowClass+'-off');
|
78
|
};
|
79
|
sf.c = {
|
80
|
bcClass: 'sf-breadcrumb',
|
81
|
menuClass: 'sf-js-enabled',
|
82
|
anchorClass: 'sf-with-ul',
|
83
|
arrowClass: 'sf-sub-indicator',
|
84
|
shadowClass: 'sf-shadow'
|
85
|
};
|
86
|
sf.defaults = {
|
87
|
hoverClass: 'sfHover',
|
88
|
pathClass: 'overideThisToUse',
|
89
|
pathLevels: 1,
|
90
|
delay: 800,
|
91
|
animation: {opacity:'show'},
|
92
|
speed: 'normal',
|
93
|
autoArrows: true,
|
94
|
dropShadows: true,
|
95
|
disableHI: false,
|
96
|
onInit: function(){},
|
97
|
onBeforeShow: function(){},
|
98
|
onShow: function(){},
|
99
|
onHide: function(){}
|
100
|
};
|
101
|
$.fn.extend({
|
102
|
hideSuperfishUl : function(){
|
103
|
var o = sf.op,
|
104
|
not = (o.retainPath===true) ? o.$path : '';
|
105
|
o.retainPath = false;
|
106
|
var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
|
107
|
.find('>ul').addClass('sf-hidden');
|
108
|
o.onHide.call($ul);
|
109
|
return this;
|
110
|
},
|
111
|
showSuperfishUl : function(){
|
112
|
var o = sf.op,
|
113
|
sh = sf.c.shadowClass+'-off',
|
114
|
$ul = this.addClass(o.hoverClass)
|
115
|
.find('>ul.sf-hidden').hide().removeClass('sf-hidden');
|
116
|
sf.IE7fix.call($ul);
|
117
|
o.onBeforeShow.call($ul);
|
118
|
$ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
|
119
|
return this;
|
120
|
}
|
121
|
});
|
122
|
})(jQuery);
|