Created
January 30, 2014 23:02
-
-
Save CezaryDanielNowak/8721979 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I'ts ugly but works | |
$('.pagination').each(function(){ | |
var allLi = $(this).find('li'); | |
if(allLi.length > 20) { | |
var activeId = allLi.filter('.active').index(); | |
allLi.eq(0) | |
.add(allLi.eq(1)) | |
.add(allLi.eq(2)) | |
.add(allLi.eq(3)) | |
.add(allLi.eq(4)) | |
.add(allLi.eq(-1)) | |
.add(allLi.eq(-2)) | |
.add(allLi.eq(-3)) | |
.add(allLi.eq(-4)) | |
.add(allLi.eq(activeId)) | |
.add(allLi.eq(activeId-1)) | |
.add(allLi.eq(activeId-2)) | |
.add(allLi.eq(activeId-3)) | |
.add(allLi.eq(activeId+1)) | |
.add(allLi.eq(activeId+2)) | |
.add(allLi.eq(activeId+3)) | |
.addClass('allow'); | |
var replacedWithDots = false; | |
allLi.each(function() { | |
if( $(this).hasClass('allow') ) { | |
replacedWithDots = false; | |
} else if(!replacedWithDots) { | |
replacedWithDots = true; | |
$(this).html('<a>...</a>'); | |
} else { | |
$(this).remove(); | |
} | |
}) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wrote this 6 years ago, and code isn't good :D
But in general:
...