Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function( $ ){
- $.fn.shuffle = function() {
- $('#posts').each(function(){
- var $ul = $(this);
- var $liArr = $ul.children('.entry');
- $liArr.sort(function(a,b){
- var temp = parseInt( Math.random()*10 );
- var isOddOrEven = temp%2;
- var isPosOrNeg = temp>5 ? 1 : -1;
- return( isOddOrEven*isPosOrNeg );
- })
- .appendTo($ul);
- });
- var msnry = new Masonry( "#posts", {
- itemSelector: ".entry"
- });
- };
- })( jQuery );
- $("#shuffle").on( "click", function() {
- event.preventDefault();
- $("#posts").shuffle();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement