Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Group related articles on mobile for single casino pages */
- (function ($) {
- function groupArticles() {
- var articles = $( '.single-casino .casino-articles' );
- if ( matchMedia('only screen and (max-width: 576px)').matches) {
- articles.find( '.ast-col-md-4' ).each(function (i, e) {
- var postCatSlug = $( this ).data( 'cat' );
- var postCatName = $( this ).data( 'cat-name' );
- //Build the mobile category sections
- if ( !$( '.mobile-articles .cat-' + postCatSlug ).length ) {
- $( '.mobile-articles' ).append( '<div class="cat-' + postCatSlug + '"><h3 class="article-group-title">' + postCatName + '<span class="toggle">+</span></span></h3><div class="group-inner"></div></div></div>' );
- }
- //Insert the posts
- var clonedEl = $( this ).clone();
- clonedEl.appendTo( '.mobile-articles .cat-' + postCatSlug + ' .group-inner' );
- });
- $( '.desktop-articles' ).hide();
- $( '.article-group-title' ).click(function (e) {
- e.preventDefault();
- $( this ).next( '.group-inner' ).slideToggle();
- var text = $( this ).find( '.toggle' ).text();
- $( this ).find( '.toggle' ).text( text == '+' ? '-' : '+');
- });
- } else {
- $( '.desktop-articles' ).show();
- $( '.mobile-articles' ).empty();
- }
- }
- groupArticles();
- window.addEventListener('resize', groupArticles);
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement