blob: b2f8a3646c35d5e5ca751f1d599cfd6f01607c1c (
plain)
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
|
;(function ($, window, undefined){
'use strict';
$.fn.foundationAccordion = function (options) {
// DRY up the logic used to determine if the event logic should execute.
var hasHover = function(accordion) {
return accordion.hasClass('hover') && !Modernizr.touch
};
$(document).on('mouseenter', '.accordion li', function () {
var p = $(this).parent();
if (hasHover(p)) {
var flyout = $(this).children('.content').first();
$('.content', p).not(flyout).hide().parent('li').removeClass('active');
flyout.show(0, function () {
flyout.parent('li').addClass('active');
});
}
}
);
$(document).on('click.fndtn', '.accordion li .title', function () {
var li = $(this).closest('li'),
p = li.parent();
if(!hasHover(p)) {
var flyout = li.children('.content').first();
if (li.hasClass('active')) {
p.find('li').removeClass('active').end().find('.content').hide();
} else {
$('.content', p).not(flyout).hide().parent('li').removeClass('active');
flyout.show(0, function () {
flyout.parent('li').addClass('active');
});
}
}
}
);
};
})( jQuery, this );
|