function FluidbookLandingPage(fluidbook) {
- this.fluidbook = fluidbook;
- this.hasLandingPage = false;
- this.init();
+ this.fluidbook = fluidbook;
+ this.hasLandingPage = false;
+ this.init();
}
FluidbookLandingPage.prototype = {
- init: function () {
- var $this = this;
+ init: function () {
+ var $this = this;
+
+ if (this.fluidbook.datas.landingPage != undefined && this.fluidbook.datas.landingPage != '') {
+ this.hasLandingPage = true;
+ }
+
+ setTimeout(function () {
+ $this.setupLandingPage();
+ }, 10);
+
+ // When the splash page hides, we are ready to show the landing page (if one exists)
+ // $(this.fluidbook).on('fluidbook.ready', function() {
+ // setTimeout($this.show, 500);
+ // });
+
+ },
+
+ setupLandingPage: function () {
+ var $this = this;
+
+ if (this.hasLandingPage) {
+ // window.location.hash = '/landing'; // handled by fluidbook.changeAddress()
+
+ $("#landingPage").html('<iframe id="landingPageIframe" width="100%" height="100%" frameborder="0" src="data/landing-page/index.html"></iframe>');
+
+ // Click handler for all links inside iframe
+ // We must wait for the iframe to load before we can add a listener to the document
+ $('#landingPageIframe').on('load', function () {
+ $(this).contents().on('click', 'a', $this.handleLink);
+ });
+ }
+ },
+
+ handleLink: function (event) {
+
+
+ //## Handle possible link types:
+
+ // 1. Link to a page (data-page attribute)
+ if ($(this).data('page') !== undefined) {
+ fluidbook.landingpage.hide();
+ fluidbook.setCurrentPage(parseInt($(this).data('page')));
+ }
+
+ // 2. Link to a Fluidbook internal link ID (data-link attribute)
+ else if ($(this).data('link') !== undefined) {
+ fluidbook.landingpage.hide();
+ var link = $('[data-id="' + $(this).data('link') + '"] a');
+ if (link.length > 0) {
+ window.location.hash = link.attr('href');
+ }
+ }
+
+ // 3. Other / external link (open new window)
+ else {
+ var href = $(this).attr('href');
+ // Local / internal link
+ if (href.indexOf('#') === 0) {
+ event.preventDefault();
+ window.location.hash = href;
+ fluidbook.landingpage.hide();
+ // External link
+ } else {
+ // ToDo: figure out how to handle this properly with security restrictions
+ window.open(href, '_blank');
+ }
+ }
- if (this.fluidbook.datas.landingPage != undefined && this.fluidbook.datas.landingPage != '') {
- this.hasLandingPage = true;
- }
-
- setTimeout(function(){$this.setupLandingPage();}, 10);
-
- // When the splash page hides, we are ready to show the landing page (if one exists)
- // $(this.fluidbook).on('fluidbook.ready', function() {
- // setTimeout($this.show, 500);
- // });
-
- },
-
- setupLandingPage: function () {
- var $this = this;
-
- if (this.hasLandingPage) {
- // window.location.hash = '/landing'; // handled by fluidbook.changeAddress()
-
- $("#landingPage").html('<iframe id="landingPageIframe" src="data/landing-page/index.html">');
-
- // Click handler for all links inside iframe
- // We must wait for the iframe to load before we can add a listener to the document
- $('#landingPageIframe').on('load', function () {
- $(this).contents().on('click', 'a', $this.handleLink);
- });
- }
- },
-
- handleLink: function (event) {
-
-
- //## Handle possible link types:
-
- // 1. Link to a page (data-page attribute)
- if ($(this).data('page') !== undefined) {
- fluidbook.landingpage.hide();
- fluidbook.setCurrentPage(parseInt($(this).data('page')));
- }
-
- // 2. Link to a Fluidbook internal link ID (data-link attribute)
- else if ($(this).data('link') !== undefined) {
- fluidbook.landingpage.hide();
- var link = $('[data-id="' + $(this).data('link') + '"] a');
- if (link.length > 0) {
- window.location.hash = link.attr('href');
- }
- }
-
- // 3. Other / external link (open new window)
- else {
- var href = $(this).attr('href');
- // Local / internal link
- if (href.indexOf('#') === 0) {
event.preventDefault();
- window.location.hash = href;
- fluidbook.landingpage.hide();
- // External link
- } else {
- // ToDo: figure out how to handle this properly with security restrictions
- window.open(href, '_blank');
- }
- }
+ return false;
- event.preventDefault();
- return false;
+ },
- },
+ hide: function () {
+ $('#landingPage').removeClass('visible');
+ },
- hide: function () {
- $('#landingPage').removeClass('visible');
- },
+ show: function () {
+ $('#landingPage').addClass('visible');
+ },
- show: function () {
- $('#landingPage').addClass('visible');
- },
+ resize: function (w, h) {
+ if (!this.hasLandingPage) {
+ return;
+ }
- resize: function (w, h) {
- if (!this.hasLandingPage) {
- return;
- }
+ console.log('TODO: landing page resize...');
- console.log('TODO: landing page resize...');
-
- }
+ }
};
// return this.fluidbook.loader.getImage(src, this._dimensions[name][0], this._dimensions[name][1]);
// },
addLink: function (navType, name, href, id, title, help, before, className, showIcon) {
-
var $nav = this.getNavFromType(navType),
elementID = navType + '_' + id;
} else {
$nav.find("ul #" + before).before(li);
}
- return l;
+ return $("#" + elementID).get(0);
},
getLink: function (name, href, id, title, help, className, showIcon, navType) {
if (showIcon == undefined) {
navOrder.push(navOrder.splice(localeIconIndex, 1)[0]); // Push to end of array
}
+ var $this = this;
+
for (var i in navOrder) {
var icon = navOrder[i];
//var visible = hide.indexOf(icon) == -1;
if (icon == 'home' && !skipHome) {
var homeURL = this.fluidbook.datas.home;
+ var homeRequireLoader = true;
if (this.fluidbook.datas.home == '%apphome%' || forceHome && DATAS.phonegap) {
homeURL = decodeURIComponent(window.localStorage.getItem('apphome'));
}
$_GET['home'] = decodeURIComponent($_GET['home']);
}
homeURL = $_GET['home'];
+ } else if (this.fluidbook.landingpage.hasLandingPage) {
+ homeURL = '#/landing';
+ homeRequireLoader = false;
}
try {
if (homeURL != '') {
}
- $('#home').on('click', function () {
- var $this = this;
- fluidbook.displayLoader();
- setTimeout(function () {
- window.location = $($this).attr('href');
- }, 500);
+ $(link).on('click', function () {
+ if (homeRequireLoader) {
+ var $thislink = this;
+ fluidbook.displayLoader();
+ setTimeout(function () {
+ window.location = $($thislink).attr('href');
+ }, 500);
+ } else {
+ $this.menuAPI.close();
+ window.location = $(this).attr('href');
+ }
return false;
- })
+ });
+
} else if (icon == 'index') {
link = this.addLink(navType, 'nav-index', '#/index', 'index', 'overview', 'overview');
} else if (icon == 'chapters') {
var extraIcon = DATAS['navExtraIcon' + n];
var extraVisibility = DATAS['navExtraVisibility' + n];
var extraType = DATAS['navExtraType' + n];
- console.log(extraURL + ';' + extraIcon + ';' + extraVisibility + ';' + extraType);
if (extraURL == '' || extraIcon == '') {
continue;
}
if (foundLink == undefined) {
continue;
}
- console.log(foundLink);
link = $(foundLink).find('a').append(linkIcon);
if (navType == 'menu' && extraType == 'icon') {
var tooltip = $(link).data('tooltip');
if (this.fluidbook.datas.afterSearch != '' && this.fluidbook.datas.afterSearchDisplayForHTML && this.fluidbook.datas.themeEnableAfterSearch && navType == 'horizontalNav') {
// Use the "afterSearch" image and links set in the theme and link editor
var afterSearchContent = '<div id="afterSearch"><div class="c">' + this.fluidbook.loader.getImage('data/images/' + this.fluidbook.datas.afterSearch) + '</div><div class="links">' + this.fluidbook.datas.links.aftersearch + '</div></li>';
- console.log('insert ' + afterSearchContent);
$nav.after(afterSearchContent);
}