if (this.hasSections()) {
$.each(this.sections, function (id, limit) {
var sectionPages = [];
+ var foundOnePage = false;
$.each(pages, function (k, p) {
- if ($this.getSectionByPageNumber(p) - 1 === id) {
+ if (p === '-' && foundOnePage) {
sectionPages.push(p);
+ } else {
+ if ($this.getSectionByPageNumber(p) - 1 === id) {
+ foundOnePage = true;
+ sectionPages.push(p);
+ } else if (foundOnePage) {
+ // Assume that if this page is not in the current section, next ones won't be either
+ return false;
+ }
}
});
sections.push(sectionPages);