--- /dev/null
+function FluidbookInterface(fluidbook) {
+ this.fluidbook = fluidbook;
+
+ this.interfaceVisible = false;
+ this.visibleTimeout;
+ this.visibleTime = 5000;
+ this.interfaceVisible = false;
+
+ this.init();
+}
+
+FluidbookInterface.prototype = {
+ init: function () {
+ var res = '';
+ if ($('html').hasClass('ltr')) {
+ res += this.fluidbook.nav.getLink('interface-previous', '#', 'previous', '', '', '', true);
+ res += this.fluidbook.nav.getLink('interface-next', '#', 'next', '', '', '', true);
+ } else {
+ res += this.fluidbook.nav.getLink('interface-previous', '#', 'next', '', '', '', true);
+ res += this.fluidbook.nav.getLink('interface-next', '#', 'previous', '', '', '', true);
+ }
+
+ $('#interface').append(res);
+ $(document).on('click', '#next', goNextPage);
+ $(document).on('click', '#previous', goPreviousPage);
+
+ this.initArrowsVisibilityManagement();
+ },
+
+ autoHideArrows: function () {
+ if (!this.fluidbook.resize.reduceHorizontalMargins()) {
+ return false;
+ }
+ return true;
+ },
+
+ initArrowsVisibilityManagement: function () {
+ var $this = this;
+ $(document).on('click', '.nonlinkarea', function () {
+ $this.toggleInterface();
+ return false;
+ });
+
+ $(this.fluidbook).on('fluidbook.ready', function () {
+ $this.resetTimeout();
+ });
+ },
+
+ toggleInterface: function () {
+ if (this.interfaceVisible) {
+ return this.hideInterface();
+ } else {
+ return this.displayInterface();
+ }
+ },
+ displayInterface: function () {
+ this.interfaceVisible = true;
+ this.getInterfaceSelector().addClass('visible');
+ this.resetTimeout();
+ },
+ resetTimeout: function () {
+ this.clearTimeout();
+ if (!this.autoHideArrows()) {
+ return false;
+ }
+ var $this = this;
+
+ this.visibleTimeout = setTimeout(function () {
+ $this.hideInterface();
+ }, this.visibleTime);
+ },
+ hideInterface: function () {
+ this.interfaceVisible = false;
+ if ($("#helpView").is(':visible') || document.activeElement.tagName.toLowerCase() === 'input') {
+ this.resetTimeout();
+ return;
+ }
+
+ this.getInterfaceSelector().css({opacity: 0}).delay(1100).css('visibility', 'hidden');
+ this.clearTimeout();
+ },
+
+ getInterfaceSelector: function () {
+ var selector = '#next,#previous';
+ if (this.fluidbook.pad.enabled) {
+ selector = 'header,#interface';
+ }
+ return $(selector);
+ },
+
+ clearTimeout: function () {
+ clearTimeout(this.visibleTimeout);
+ },
+};
\ No newline at end of file
this.isReady = true;
$("#main").css('display', 'block');
this.nav = new FluidbookNav(this);
+ this.interface = new FluidbookInterface(this);
this.slider = new FluidbookSlider(this);
this.help = new FluidbookHelp(this);
this.help.displayAtStartup();
// if (!visible) {
// $(link).addClass('hidden');
// }
- }
-
- this.setInterface();
+ };
if (navType == 'menu') {
setInterface: function () {
- // Ensure we don't add interface elements more than once
- if (this._inited['interface'] == true) {
- return;
- }
- this._inited['interface'] = true;
-
- var res = '';
- if ($('html').hasClass('ltr')) {
- res += this.getLink('interface-previous', '#', 'previous', '', '', '', true);
- res += this.getLink('interface-next', '#', 'next', '', '', '', true);
- } else {
- res += this.getLink('interface-previous', '#', 'next', '', '', '', true);
- res += this.getLink('interface-next', '#', 'previous', '', '', '', true);
- }
-
- $('#interface').append(res);
- $(document).on('click', '#next', goNextPage);
- $(document).on('click', '#previous', goPreviousPage);
},
// Build nested lists from chapters
function FluidbookPad(fluidbook) {\r
this.fluidbook = fluidbook;\r
this.enabled = this.fluidbook.datas.mobileNavigationType == 'tab';\r
- this.tapHoldTimeout;\r
- this.visibleTimeout;\r
- this.visibleTime = 5000;\r
- this.interfaceVisible = false;\r
+\r
if (this.enabled) {\r
this.init();\r
}\r
}\r
return false;\r
});\r
-\r
- $(document).on('click', '.nonlinkarea', function() {\r
- $this.toggleInterface();\r
- return false;\r
- });\r
- },\r
- toggleInterface: function() {\r
- if (this.interfaceVisible) {\r
- return this.hideInterface();\r
- } else {\r
- return this.displayInterface();\r
- }\r
- },\r
- displayInterface: function() {\r
- this.interfaceVisible = true;\r
- $("header,#interface").css({visibility: 'visible', opacity: 1});\r
- this.resetTimeout();\r
- },\r
- resetTimeout: function() {\r
- var $this = this;\r
- this.clearTimeout();\r
- this.visibleTimeout = setTimeout(function() {\r
- $this.hideInterface();\r
- }, this.visibleTime);\r
- },\r
- hideInterface: function() {\r
- this.interfaceVisible = false;\r
- if ($("#helpView").is(':visible') || document.activeElement.tagName.toLowerCase() === 'input') {\r
- this.resetTimeout();\r
- return;\r
- }\r
- $("header,#interface").css({opacity: 0}).delay(1100).css('visibility', 'hidden');\r
- this.clearTimeout();\r
- },\r
- clearTimeout: function() {\r
- clearTimeout(this.visibleTimeout);\r
},\r
+\r
getTransitionAxis: function(currentPage, nextPage) {\r
var linkedPages = this.fluidbook.bookmarks.getLinkedPages(currentPage);\r
if (linkedPages.indexOf(nextPage) == -1) {\r
}
FluidbookResize.prototype = {
+ reduceHorizontalMargins: function () {
+ return this.orientation == 'portrait' && this.fluidbook.support.isMobile && Modernizr.touch;
+ },
+
setMargins: function () {
- var marginX = 20;
var marginY = 20;
+ var marginX = 60;
+ if (this.reduceHorizontalMargins()) {
+ marginX = 20;
+ }
+
this.marginleft = marginX + parseInt(this.fluidbook.datas.extraXSpace);
this.margintop = marginY + parseInt(this.fluidbook.datas.extraYSpace);
this.marginbottom = marginY + 20;
- this.marginright = marginX;
+ this.marginright = marginX + parseInt(this.fluidbook.datas.extraXSpace);
+
},
init: function () {
});
this.resizeView();
+ this.setMargins();
var marginTop, marginBottom, marginLeft, marginRight;
marginTop = (parseInt(this.fluidbook.datas.menuHeight) + this.margintop) * interfaceScale;
marginBottom = (10 + this.marginbottom) * interfaceScale;
marginLeft = (this.marginleft + parseInt(extraX)) * interfaceScale;
- marginRight = marginLeft;
+ marginRight = (this.marginright + parseInt(extraX)) * interfaceScale;
}
var aw = this.ww - marginLeft - marginRight;