/** * blog filter for blog pages * * @application: Posteo Website * @author: Andrea Ertel, posteo.de * @requires: jquery, jscroll/jquery.jscroll.js */ var blogFilter = (function() { 'use strict'; var toggleFiltered, showFiltered; toggleFiltered = function(cat) { var actCat = cat = $(this).attr("id"); if ($(this).hasClass("active_filter")) { $(this).removeClass("active_filter"); } else { // show only the choosen category blog entries $("li.filter").removeClass("active_filter"); $(this).addClass("active_filter"); // call filter function for articles showFiltered(actCat); // call fixFooterToBottom() from basics.js fixFooterToBottom(); } }; showFiltered = function(cat) { // set var with active Category var actCat = cat; // collect all articles of the category var activeArticles = $("article." + actCat); // some (p)resets $("article").hide(); $('#jscroll-loading').remove(); // show all articles of choosen category if (activeArticles.length > 0) { $.each( activeArticles, function( i, val ) { $("article." + actCat).show(); }); } // call fixFooterToBottom() from basics.js fixFooterToBottom(); }; return { toggleFiltered: toggleFiltered, showFiltered: showFiltered, }; }()); $(document).ready(function() { // initialize jscroll plugin for blog pages // filter posts with active filter category $('.p_js_jscroll').jscroll({ nextSelector: 'a.jscroll-next:last', loadingHtml: '
' + I18n.t("js.blog.loading_phrase") + '
' }); $('#filter').on('click', '.filter', blogFilter.toggleFiltered); });