init: function (datas) {
this.datas = datas;
this.junk = datas.cacheDate;
+ this.landingpage = new FluidbookLandingPage(this);
this.menu = new FluidbookMenu(this);
this.zoom = new FluidbookZoom(this);
this.zoom.resetZoom();
$this.hideSplash();
}, true);
}
+
+ else if (args[1] == 'landing') {
+ $this.hideSplash();
+ this.landingpage.show();
+ }
+
else {
var view = args[1];
if (this.currentPage == -1) {
}
}
-}
\ No newline at end of file
+}
--- /dev/null
+function FluidbookLandingPage(fluidbook) {
+ this.fluidbook = fluidbook;
+ this.hasLandingPage = false;
+ this.init();
+}
+
+FluidbookLandingPage.prototype = {
+
+ init: function () {
+ var $this = this;
+
+ if (this.fluidbook.datas.landingPage != undefined && this.fluidbook.datas.landingPage != '') {
+
+ this.hasLandingPage = true;
+ window.location.hash = '/landing';
+
+ $("#landingPage").append('<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) {
+ event.preventDefault();
+
+ // ToDo: figure out why first link click after load isn't caught by this handler (page is set to -1 even if it is set in code on init)
+ console.log('Handling link...', $(this));
+
+ //## 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 {
+ // ToDo: open in new window
+ console.log($(this).attr('href'));
+ }
+
+ },
+
+ hide: function() {
+ $('#landingPage').hide();
+ },
+
+ show: function() {
+ $('#landingPage').fadeIn();
+ },
+
+ resize: function (w, h) {
+ if (!this.hasLandingPage) {
+ return;
+ }
+
+ console.log('TODO: landing page resize...');
+
+ }
+};
+