Skip to content

Instantly share code, notes, and snippets.

@adamwulf
Created November 13, 2013 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamwulf/7454134 to your computer and use it in GitHub Desktop.
Save adamwulf/7454134 to your computer and use it in GitHub Desktop.
$(function(){
// the height of the content, discluding the header/footer
var content_height = 652;
// the beginning page number to show in the footer
var page = 1;
var hasAddedBios = false;
function buildNewsletter(){
if($('#newsletterContent').contents().length > 0){
// when we need to add a new page, use a jq object for a template
// or use a long HTML string, whatever your preference
$page = $("#page_template").clone().addClass("page").css("display", "block");
// append the page number to the footer
$page.find(".footer span").append(page);
$("body").append($page);
page++;
// here is the columnizer magic
$('#newsletterContent').columnize({
columns: 2,
target: ".page:last .content",
overflow: {
height: content_height,
id: "#newsletterContent",
doneFunc: function(){
console.log("done with page");
buildNewsletter();
}
}
});
}else if(!hasAddedBios){
// this will add a new page, that is columnized just
// like the rest of the document, but only contains
// the content of #bios in the first column.
hasAddedBios = true;
$('#newsletterContent').append($('#bios'));
buildNewsletter();
}
}
buildNewsletter();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment