(function($){ // posts widget pagination $( document ).ready( function() { $( 'body' ).append( '
' ); } ); $( document ).on( 'click', '.widget-posts .pagination .page-numbers', function( e ) { e.preventDefault(); var $w = $( this ).parents( '.widget' ), url = $( this ).attr( 'href' ).replace( '#', ' #' ); console.log(url); // reload the widget // - prepend loading spinner $( '.pagination:eq(0)', $w ).prepend( '' ); $( '#posts-widget-placeholder' ).load( url, { ajax: 1, postswidget: $w.attr( 'id' ) }, function() { var pagination = $( '#posts-widget-placeholder .pagination' ).html(), loop = $( '#posts-widget-placeholder .loop' ).html(); // remove spinner $( '#posts-widget-spinner' ).remove(); $( '#posts-widget-placeholder' ).html( '' ); // swap content $( '.pagination', $w ).html( pagination ); $( '.loop', $w ).fadeOut( 200, function() { $( this ).html( loop ).fadeIn( 300 ); } ); // make external links point to an external window again $( 'a:has(.icon-external)', $w ).attr( 'target', '_blank' ); } ); } ); // zoom in on a posts widget. Browse its content differently $( document ).ready( function() { $( 'a:has(.icon-external)' ).attr( 'target', '_blank' ); } ); })(jQuery)