/* This modules adds subslides support. */ (function($, deck, undefined) { var $d = $(document); /* Extends defaults/options. */ $.extend(true, $[deck].defaults, { }); var subSlidesCount = -1, subSlide = null; $d.bind('deck.init', function() { $('.incremental .highlight').addClass('subslide'); $('.incremental .subslide').addClass('deck-offscreen'); }); $d.bind('deck.change', function(e, from, to) { var slide = $[deck]('getSlide', to); var parentSlide = slide.parent().closest('.slide'); var subSlides = parentSlide.find('.subslide'); if (parentSlide.is('.incremental') && subSlides.length) { if (subSlide) { subSlide.hide(); } else if (!subSlide && from > to) { subSlidesCount = subSlides.length-1; } if (from < to) { subSlidesCount++; } else { subSlidesCount--; } subSlide = subSlides.eq(subSlidesCount); if (subSlide.is('.deck-offscreen')) { subSlide.removeClass('deck-offscreen').hide().slideDown(); } else { subSlide.slideDown(); } } else { if (subSlide) { subSlide.hide(); } subSlide = null; subSlidesCount = -1; } }); })(jQuery, 'deck', this);