Sha256: 4b8e8a15606d88f25a7640f75f53377b59e7c1fad59e79816c37567a8cd8e547
Contents?: true
Size: 1.79 KB
Versions: 11
Compression:
Stored size: 1.79 KB
Contents
(function($) { $.widget('pageflow.pageNavigationList', { _create: function() { var element = this.element; var options = this.options; var scroller = options.scroller; var links = element.find('a'); pageflow.ready.then(function() { highlightActivePage(getPageId(pageflow.slides.currentPage())); }); pageflow.slides.on('pageactivate', function(e) { highlightActivePage(getPageId(e.target)); }); function getPageId(section) { return $(section).attr('id') || ($(section).data('permaId') || '').toString(); } function highlightActivePage(id) { var displayPageId = _.find(pageIdsUpUntil(id).reverse(), function(id) { return links.filter('[href="#' + id + '"]').length; }); highlightPage(displayPageId); } function highlightPage(id) { links.each(function() { var link = $(this); var active = '#' + id === link.attr('href'); link.toggleClass('active', active); link.attr('tabindex', active ? '-1' : '3'); if (options.scrollToActive && active) { scroller.scrollToElement(link[0], 800); } }); } function pageIdsUpUntil(id) { var found = false; return _.filter(pageIds(), function(other) { var result = !found; found = found || (id === other); return result; }); } function pageIds() { if (_.isArray(pageflow.pages)) { return _.map(pageflow.pages, function(page) { return page.perma_id.toString(); }); } else { return pageflow.pages.map(function(page) { return page.get('perma_id').toString(); }); } } } }); }(jQuery));
Version data entries
11 entries across 11 versions & 1 rubygems