Skip to content

Instantly share code, notes, and snippets.

@deanlandolt
Created July 7, 2010 20:51
Show Gist options
  • Save deanlandolt/467257 to your computer and use it in GitHub Desktop.
Save deanlandolt/467257 to your computer and use it in GitHub Desktop.
a { text-decoration: none; display: inline; }
.feed-title { font-size: 150%; background-color: #eee; padding: 10px; }
div.hentry { padding: 10px; border-top: 1px solid #eee; }
div.hentry:hover { background-color: #fafafa; }
div.nav.sequence {
color: #959585;
font-size: 80%;
font-weight: bold;
text-align: center;
background-color: #fffee1;
border-top: 1px solid #dedebb;
padding-bottom: 2px; }
div.nav.sequence:hover { background-color: #f9faaa; }
dt { font-variant: small-caps; float: left; padding-right: 1em; }
div.hentry .metadata { color: #666; font-size: 80%; font-variant: small-caps; float: right; padding-left: 1em; }
$(function () {
function getNext() {
var nextLink = $('#nextLink');
if (nextLink.length && nextLink.attr("href")) {
var url = nextLink.attr("href");
nextLink.attr("href", "");
$("#nextLink div").html("loading …");
$.get(url, function(data) {
nextLink.detach();
$(".hfeed").append($(".hentry", data));
nextLink = $("#nextLink", data);
if (nextLink.length) {
// tack on the next link
$(".hfeed").append(nextLink);
}
}, "html");
}
};
function getPrev() {
var prevLink = $('#prevLink');
if (prevLink.length && prevLink.attr("href")) {
var url = prevLink.attr("href");
prevLink.attr("href", "");
$("#prevLink div").html("loading …");
$.get(url, function(data) {
prevLink.detach();
$(".hentry").first().before($(".hentry", data));
prevLink = $("#prevLink", data);
if (prevLink.length) {
// tack on the prev link
$(".hentry").first().before(prevLink);
}
}, "html");
}
};
function isBottom() {
return $(window).scrollTop() > ($(document).height() - $(window).height() - 10);
}
if (isBottom()) getNext();
$(window).scroll(function () {
if (isBottom()) {
// we're at the bottom of the page, or very close
getNext();
}
});
$('#prevLink').live('click', function(ev) {
ev.preventDefault();
getPrev();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment