var $this = this;
setTimeout(function () {
$this._hideSplash();
- }, 3000);
+ }, 300);
},
_hideSplash: function () {
- this.ready();
$("#main,#viewOverlay,#view").css('visibility', 'visible');
this.hideLoader(0, true);
$(this).trigger('fluidbook.splash.hide');
},
+
+ onReady: function(callback) {
+ if (this.isReady) {
+ callback();
+ } else {
+ $(this).on('fluidbook.ready', function() {
+ callback();
+ });
+ }
+ },
ready: function () {
if (this.isReady) {
return;
var args = window.location.hash.split('/');
if (args.length <= 1 || args[1] == '' || args[1] == undefined) {
+ if (this.landingpage.hasLandingPage) {
+ window.location.hash = '/landing';
+ return;
+ }
return this.setCurrentPage('1');
} else if (args[1] == 'closeview') {
return this.setCurrentPage(this.currentPage);
var $this = this;
if (this.fluidbook.datas.landingPage != undefined && this.fluidbook.datas.landingPage != '') {
-
this.hasLandingPage = true;
- window.location.hash = '/landing';
+ }
+
+ 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);
+ // });
- $("#landingPage").append('<iframe id="landingPageIframe" src="data/landing-page/index.html">');
+ },
+
+ 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
}
},
- handleLink: function(event) {
- event.preventDefault();
+ handleLink: function (event) {
- // 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:
// 3. Other / external link (open new window)
else {
- // ToDo: open in new window
- console.log($(this).attr('href'));
+ 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');
+ }
}
+ event.preventDefault();
+ return false;
+
},
- hide: function() {
- $('#landingPage').hide();
+ hide: function () {
+ $('#landingPage').removeClass('visible');
},
- show: function() {
- $('#landingPage').fadeIn();
+ show: function () {
+ $('#landingPage').addClass('visible');
},
resize: function (w, h) {
});
$(document).trigger('fluidbookready');
- $(this).trigger('fluidbook.ready');
setTimeout(function () {
resize();
}, 1000);
- if (!startAfterLoading) {
- fluidbook.changeAddress();
- }
+ fluidbook.onReady(function() {
+ if (!startAfterLoading) {
+ fluidbook.changeAddress();
+ }
+ });
//console.log('fluidbook.ready');
+ setTimeout(function(){
+ fluidbook.ready();
+ }, 3000);
}
} catch (err) {
console.log(err);