-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.drop.js
More file actions
73 lines (68 loc) · 2.65 KB
/
jquery.drop.js
File metadata and controls
73 lines (68 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
(function($){
$.fn.extend({
drop: function(options) {
//Defaults
var defaults = {
hoverClass: "hover", // class name used for when an element is hovered and has no dropdown
hasDropdownClass: "drop", // class name used for when an element that contains a dropdown
activeClass: "active", // class name used for when an element is hovered and has a dropdown
animated: false, // true to make dropdown anmiated
easeIn: false, // easing for "in" transition
easeOut: false, // easing for "out" transition
duration: 0, // milliseconds for animation
durationIn: false, // milliseconds for animation "in"
durationOut: false // milliseconds for animation "out"
}
var options = $.extend(defaults, options);
//if easing is set check for easing plugin
if(options.easeIn || options.easeOut) {
if(!jQuery.easing["jswing"]) {
alert('To use easing please include jquery.easing.js.');
}
}
return this.each(function() {
var o = options;
var $el = $(this);
var durationIn = (o.durationIn) ? o.durationIn : o.duration;
var durationOut = (o.durationOut) ? o.durationOut : o.duration;
if($('ul',this).children('li').length > 0) {
$el.addClass(o.hasDropdownClass);
}
$el.hover(
function(){
if($(this).hasClass(o.hasDropdownClass)) {
$(this).addClass(o.activeClass);
if(o.animated) {
if(o.easeIn) {
$el.children('ul').stop(true,true).slideDown({duration: durationIn, easing: o.easeIn});
} else {
$el.children('ul').stop(true,true).slideDown({duration: durationIn});
}
} else {
$el.children('ul').fadeIn({duration: durationIn});
}
} else {
$(this).addClass(o.hoverClass);
}
},
function() {
if($(this).hasClass(o.hasDropdownClass)) {
$(this).removeClass(o.activeClass);
if(o.animated) {
if(o.easeOut) {
$el.children('ul').stop(true,true).slideUp({duration: durationOut, easing: o.easeOut});
} else {
$el.children('ul').stop(true,true).slideUp({duration: durationOut});
}
} else {
$el.children('ul').fadeOut({duration: durationOut});
}
} else {
$(this).removeClass(o.hoverClass);
}
}
);
});
}
});
})(jQuery);