Skip to content

Instantly share code, notes, and snippets.

@bdalziel
Created September 15, 2011 03:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdalziel/1218482 to your computer and use it in GitHub Desktop.
Save bdalziel/1218482 to your computer and use it in GitHub Desktop.
var setupEllipsis = function(container, itemIndex, itemCount, maxItemCount) {
// Make everything visible
var hidden = container.all('li.hidden');
hidden.removeClass('hidden');
var ellipsis = container.all('li.ellipsis');
ellipsis.removeClass('ellipsis');
// Get the bounding box data for the selected item
var activePage = container.one('li.pageNum-'+itemIndex);
var ellipL = Y.Util.getClassValue(activePage, 'ellipL');
var ellipU = Y.Util.getClassValue(activePage, 'ellipU');
var ellipM = Y.Util.getClassValue(activePage, 'ellipM');
var prevHidden = false;
var pages = container.all('li.pageNav');
pages.each(function (pageButton) {
curItemIndex = Y.Util.getClassValue(pageButton, 'pageNum');
if (curItemIndex == 0 ||
(curItemIndex >= ellipL &&
curItemIndex <= ellipU) ||
curItemIndex == ellipM) {
// You're visible
prevHidden = false;
}
else {
if (!prevHidden) {
pageButton.addClass('ellipsis');
prevHidden = true;
}
else {
pageButton.addClass('hidden');
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment