},
addLinks: function (pages) {
- pages = pages.map(function (x) {
- if (x === '-') {
- return '-';
- }
- return parseInt(x);
- });
-
this.links = [];
var $this = this;
var sections = [];
var sectionPages = [];
var foundOnePage = false;
$.each(pages, function (k, p) {
+ let weight = 1;
+ let e = p.split('*');
+ if (e.length === 2) {
+ weight = parseInt(e[1]);
+ p = e[0];
+ }
+ let page = {page: p, weight: weight};
+
if (p === '-' && foundOnePage) {
- sectionPages.push(p);
+ sectionPages.push(page);
} else {
- if ($this.getSectionByPageNumber(p) - 1 === id) {
+ page.page = parseInt(page.page);
+ if ($this.getSectionByPageNumber(page.page) - 1 === id) {
foundOnePage = true;
- sectionPages.push(p);
+ sectionPages.push(page);
} 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);
});
} else {
- sections.push(pages);
+ var section = [];
+ $.each(pages, function (k, p) {
+ let weight = 1;
+ let e = p.toString().split('*');
+ if (e.length === 2) {
+ weight = parseInt(e[1]);
+ p = e[0];
+ }
+ section.push({page: p, weight: weight});
+ });
+ sections.push(section);
}
var index = 1;
$.each(sections, function (k, sectionPages) {
- var nbPages = sectionPages.length;
+ var totalWeight = 0;
+ $.each(sectionPages, function (k, value) {
+ totalWeight += value.weight;
+ });
+
var i = 0;
$.each(sectionPages, function (k, value) {
- if (value !== '-') {
- var activeLandscape = value;
+ if (value.page !== '-') {
+ var activeLandscape = parseInt(value.page);
if (!$this.fluidbook.alwaysDisplayOnePage && value % 2 === 1) {
activeLandscape--;
}
$this.links.push({
- css: {height: (100 / nbPages) + '%', top: (100 / nbPages * i) + '%'},
- page: parseInt(value),
+ css: {height: (value.weight * (100 / totalWeight)) + '%', top: (100 / totalWeight * i) + '%'},
+ page: parseInt(value.page),
pageActiveLandscape: activeLandscape,
index: index,
id: 'o' + index
});
}
- i++;
+ i += value.weight;
index++;
});
});
}
});
}
+ console.log(page,id);
if (id === 'none') {
this.svg.find('[id^="o"].active').removeClass('active');
}
var section = 0;
$.each(this.sections, function (k, v) {
- if (page >= v) {
+ if (parseInt(page) >= v) {
section = k + 1;
}
});