return g.join(',');
},
addGroup: function (from, nb, name) {
- var to = Math.min(from + (nb - 1), this.fluidbook.datas.pages);
+ var to = Math.min(from + (nb - 1), this.fluidbook.getMaxPage());
for (var i = from; i <= to; i++) {
this._pagesToGroup[i] = this._groups;
}
this._groups++;
},
completeGroups: function () {
- for (var i = 1; i <= this.fluidbook.datas.pages; i++) {
+ for (var i = 1; i <= this.fluidbook.getMaxPage(); i++) {
if (this._pagesToGroup[i] == undefined || this._pagesToGroup[i] == null) {
this._pagesToGroup[i] = this._groups;
this._groupOrder.push(this._groups);
},
getPagesOfGroup: function (groupId) {
var res = [];
- for (var i = 1; i <= this.fluidbook.datas.pages; i++) {
+ for (var i = 1; i <= this.fluidbook.getMaxPage(); i++) {
if (this._pagesToGroup[i] == groupId) {
res.push(i);
}
var res = [];
var nb;
var groupId;
- for (var i = 1; i <= this.fluidbook.datas.pages;) {
+ for (var i = 1; i <= this.fluidbook.getMaxPage();) {
if (this.isBookmarked(i) || !onlyBookmarked) {
groupId = this.getGroupOfPage(i);
nb = this.getPagesNumberInGroup(groupId);
var bookmarks = "";
for (var i = pageNr; i <= to; i++) {
- if (i > 0 && i <= this.fluidbook.datas.pages) {
+ if (i > 0 && i <= this.fluidbook.getMaxPage()) {
var side;
if (allwaysAtRight) {
side = 'right';
this.sound = new FluidbookSound(this);
this.slideshow = new FluidbookSlideshow(this);
- if(this.datas.basket) {
+ if (this.datas.basket) {
this.cart = new FluidbookCart(this);
}
if (this.datas.form == 'bulle') {
}
$('html').addClass(this.datas.mobileLVersion);
this.currentPage = -1;
+ this.maxPage = this.getMaxPage();
+
this.resize = new FluidbookResize(this);
this.stats = new FluidbookStats(this);
this.stats.track(10);
this.initTheme();
this.initKeyboardShortcuts();
},
+
+ setMaxPage: function (p) {
+ this.maxPage = p;
+ this.updateMaxPage();
+ },
+
+ getMaxPage: function () {
+ return this.maxPage;
+ },
+
+ updateMaxPage() {
+
+ },
+
initTheme: function () {
if (this.datas.arrowsTheme) {
$('html').addClass('sharp');
return;
}
this.transitionAxis = 'x';
- this.setCurrentPage(this.datas.pages);
+ this.setCurrentPage(this.getMaxPage());
},
goNextChapter: function () {
if (this.transitionning) {
this.setCurrentPage(this.normalizePage(prev));
},
normalizePage: function (page) {
- page = Math.max(1, Math.min(page, this.datas.pages));
+ page = Math.max(1, Math.min(page, this.getMaxPage()));
if (!this.displayOnePage && page % 2 == 1) {
page--;
}
var args = window.location.hash.split('/');
if (args.length <= 1 || args[1] == '' || args[1] == undefined) {
- if (this.landingpage!==undefined && this.landingpage.hasLandingPage) {
+ if (this.landingpage !== undefined && this.landingpage.hasLandingPage) {
window.location.hash = '/landing';
return;
}
if (page != $this.currentPage) {
$($this).trigger('changePage', [page]);
}
- if(this.landingpage!==undefined) {
+ if (this.landingpage !== undefined) {
this.landingpage.hide();
}
this.menu.closeView(function () {
else if (args[1] == 'landing') {
$this.hideSplash();
- if(this.landingpage!==undefined) {
+ if (this.landingpage !== undefined) {
this.landingpage.show();
}
}
if (center) {
if (newPage <= 1) {
res.center = -1;
- } else if (this.datas.pages % 2 == 0 && newPage == this.datas.pages) {
+ } else if (this.getMaxPage() % 2 == 0 && newPage == this.getMaxPage()) {
res.center = 1;
}
}
$("#previous").removeClass('hidden');
}
- if (page >= this.datas.pages) {
+ if (page >= this.getMaxPage()) {
$("#next").addClass('hidden');
} else {
$("#next").removeClass('hidden');
$("#previous:hidden").fadeIn(speed);
}
- if (page >= this.datas.pages) {
+ if (page >= this.getMaxPage()) {
$("#next:visible").fadeOut(speed);
} else {
$("#next:hidden").fadeIn(speed);
if (this.displayOnePage) {
right = true;
} else {
- if ((page <= 1 && this.l10n.dir == 'ltr') || (page >= this.datas.pages && this.l10n.dir == 'rtl')) {
+ if ((page <= 1 && this.l10n.dir == 'ltr') || (page >= this.getMaxPage() && this.l10n.dir == 'rtl')) {
left = false;
- } else if ((page <= 1 && this.l10n.dir == 'rtl') || (page >= this.datas.pages && this.l10n.dir == 'ltr')) {
+ } else if ((page <= 1 && this.l10n.dir == 'rtl') || (page >= this.getMaxPage() && this.l10n.dir == 'ltr')) {
right = false;
}
}
}
this.transitionning = false;
if (this.pad.enabled) {
- if (this.currentPage == this.datas.pages) {
+ if (this.currentPage == this.getMaxPage()) {
$("#down").css('opacity', 0);
} else {
$("#down").css('opacity', 1);
var $callback = callback;
var $page = $pages.shift();
- if ($page > this.fluidbook.datas.pages || $page < 1) {
+ if ($page > this.fluidbook.getMaxPage() || $page < 1) {
$this.preloadPagesBeforeTransition($pages, $callback);
return;
}
numPreloadAfter = 3;
numPreloadBefore = 1;
}
- var max = Math.min(page + numPreloadAfter, this.fluidbook.datas.pages);
+ var max = Math.min(page + numPreloadAfter, this.fluidbook.getMaxPage());
var min = Math.max(1, page - numPreloadBefore);
this.toPreload = [];
for (var i = min; i <= max; i++) {
this.preloadPages();
},
cleanPreloaded: function () {
- for (var i = 1; i <= this.fluidbook.datas.pages; i++) {
+ for (var i = 1; i <= this.fluidbook.getMaxPage(); i++) {
if (this.backgrounds[i] != undefined && this.toPreload.indexOf(i) == -1) {
this.deletePage(i);
}
return this.loadImage('images/shadows/pages/' + position + '.png', this.fluidbook.datas.width / 4, this.fluidbook.datas.height);
},
loadLeftPage: function (page, doublePage, callback) {
- if (page > 0 && page <= this.fluidbook.datas.pages) {
+ if (page > 0 && page <= this.fluidbook.getMaxPage()) {
this.loadPage(page, doublePage, 'left', callback);
} else {
$(doublePage).find('.left').remove();
}
},
loadRightPage: function (page, doublePage, callback) {
- if (!this.fluidbook.displayOnePage && page <= this.fluidbook.datas.pages && page > 0) {
+ if (!this.fluidbook.displayOnePage && page <= this.fluidbook.getMaxPage() && page > 0) {
this.loadPage(page, doublePage, 'right', callback);
} else {
$(doublePage).find('.right').remove();
}
pageNrs.push(pageNr);
pageNr++;
- if (pageNr < this.fluidbook.datas.pages) {
+ if (pageNr < this.fluidbook.getMaxPage()) {
pageNrs.push(pageNr);
}
}
var hits = [];
// Create a list of all pages so we can record which ones have a hit on the search term
- for (var i = 0; i <= this.fluidbook.datas.pages; i++) {
+ for (var i = 0; i <= this.fluidbook.getMaxPage(); i++) {
hits[i] = 0;
}
// Map result hits to pages
pageMin = 0;
}
- return Math.min(this.fluidbook.datas.pages, Math.max(pageMin, page));
+ return Math.min(this.fluidbook.getMaxPage(), Math.max(pageMin, page));
},
updateSnaps: function (single) {
if (single) {
- this.snapsCount = this.fluidbook.datas.pages;
+ this.snapsCount = this.fluidbook.getMaxPage();
} else {
- this.snapsCount = Math.floor(this.fluidbook.datas.pages / 2) + 1;
+ this.snapsCount = Math.floor(this.fluidbook.getMaxPage() / 2) + 1;
}
this.cursorWidth = Math.max(30, this.sliderWidth / this.snapsCount);
this.snapsWidth = (this.sliderWidth - this.cursorWidth) / (this.snapsCount - 1);
getCursorXByPage: function (page) {
var left;
if (this.fluidbook.l10n.rtl) {
- page = this.fluidbook.datas.pages - page;
+ page = this.fluidbook.getMaxPage() - page;
}
if (this.fluidbook.resize.orientation == 'portrait') {
left = this.snapsWidth * (page - 1);
if (page > 0) {
left = page;
}
- if (page <= this.fluidbook.datas.pages) {
+ if (page <= this.fluidbook.getMaxPage()) {
right = page + 1;
}
}
setThumb: function (thumb, page, shade) {
thumb.find('.bookmark').attr('data-page', page);
- if (page > 0 && page <= this.fluidbook.datas.pages) {
+ if (page > 0 && page <= this.fluidbook.getMaxPage()) {
thumb.css('visibility', 'visible');
this.fluidbook.loader.getThumbImage(page, thumb.find('.img'), shade);
thumb.find('a').attr('href', '#/page/' + page);
page--;
}
- var last = this.fluidbook.datas.pages;
+ var last = this.fluidbook.getMaxPage();
if (last % 2 == 1) {
last++;
}
view += '<form class="cart-bourbon-suggest" action="" method="post">';
view += '<div>';
view += '<label>Page number';
- view += '<input type="text" id="bourbon-suggestion-page" data-parsley-type="integer" name="page" value="' + this.fluidbook.currentPage + '" min="0" max="' + this.fluidbook.datas.pages + '" tabindex="100" required>';
+ view += '<input type="text" id="bourbon-suggestion-page" data-parsley-type="integer" name="page" value="' + this.fluidbook.currentPage + '" min="0" max="' + this.fluidbook.getMaxPage() + '" tabindex="100" required>';
view += '</label>';
view += '<label>Suggestion type';
view += '<select id="bourbon-suggestion-type"><option>TYPO / WORDING</option><option>CLARIFICATION REQUEST</option><option>IMPROVEMENT SUGGESTION (Gaps, Ideas, etc)</option></select>';
var c = '';
var s1, s2;
- for (var i = 0; i <= this.fluidbook.datas.pages; i += 2) {
+ for (var i = 0; i <= this.fluidbook.getMaxPage(); i += 2) {
var pages = [];
j = i + 1;
ix1 = '';
s2 = 'left'
}
- if (j <= this.fluidbook.datas.pages) {
+ if (j <= this.fluidbook.getMaxPage()) {
ix2 += '<div class="thumb ' + s1 + '"><a href="#/page/' + j + '">' + this.fluidbook.loader.getThumbImage(j, null, true) + '</a><span class="number">' + this.fluidbook.physicalToVirtual(j) + '</span>';
if (this.fluidbook.bookmarks.enabled) {
ix2 += this.fluidbook.bookmarks.getBookmarkForPage(j, true);