diff options
Diffstat (limited to 'website/static/js/foundation3/jquery.foundation.accordion.js')
-rw-r--r-- | website/static/js/foundation3/jquery.foundation.accordion.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/website/static/js/foundation3/jquery.foundation.accordion.js b/website/static/js/foundation3/jquery.foundation.accordion.js new file mode 100644 index 0000000..b2f8a36 --- /dev/null +++ b/website/static/js/foundation3/jquery.foundation.accordion.js @@ -0,0 +1,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 ); + |