From: Vincent Vanwaelscappel Date: Thu, 15 Jul 2021 16:48:31 +0000 (+0200) Subject: wip #4592 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=cad2750b04c78f99691d04f72be89e2321304e1d;p=fluidbook-html5.git wip #4592 @2 --- diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index b97f9a3b..49fcf083 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -21,1160 +21,18 @@ Fluidbook.prototype = { init: function (settings) { this.flags = {}; this.canNavigate = false; + this.shortLoading = false; + this.nointerface = false; + this.hideBook=false; if ($_GET['nointerface'] !== undefined) { $('body').addClass('nointerface'); settings.mobileTransitions = 'none'; - this.nointerface = true; - } else { - this.nointerface = false; - } - - this.initSettings(settings); - this.secure = new FluidbookSecure(this); - - var $this = this; - this.secure.checkSecure(function () { - $this.secureOK(); - }); - }, - - secureOK: function () { - this.singleMode = (this.settings.mobileNavigationType === 'portrait' || this.settings.mobileNavigationType === 'mobilefirst'); - - this.junk = this.settings.cacheDate; - this.l10n = new FluidbookL10N(this, $_GET['lang']); - this.networkControl = new FluidbookNetworkControl(this); - this.input = new FluidbookInput(this); - this.keyboard = new FluidbookKeyboard(this); - if (this.settings.landingPage != undefined && this.settings.landingPage != '') { - this.landingpage = new FluidbookLandingPage(this); - } - this.splash = new FluidbookSplash(this); - this.contentlock = new FluidbookContentLock(this); - this.menu = new FluidbookMenu(this); - this.support = new FluidbookSupport(this); - this.search = new FluidbookSearch(this); - this.mobilefirst = new FluidbookMobileFirst(this); - if (!this.mobilefirst.enabled) { - this.slider = new FluidbookSlider(this); - } - this.displayOnePage = this.alwaysDisplayOnePage = this.settings.mobileNavigationType === 'portrait' || (this.pad && this.pad.enabled) || this.mobilefirst.enabled; - this.zoom = new FluidbookZoom(this); - this.zoom.resetZoom(); - this.cache = new FluidbookCache(this.settings); - this.service = new FluidbookService(this, this.settings.id); - this.loader = new FluidbookLoader(this); - this.pad = new FluidbookPad(this); - this.scorm = new FluidbookScorm(this); - this.links = new FluidbookLinks(this); - this.waiters = []; - this.viewport = new FluidbookViewport(this); - this.viewport.updateViewport(); - this.desktop = new FluidbookDesktop(this); - this.share = new FluidbookShare(this); - this.firstTransition = true; - if (this.input.hasTouch) { - this.touch = new FluidbookTouch(this); - } - this.background = new FluidbookBackground(this); - this.video = new FluidbookVideo(this); - this.audioplayer = new FluidbookAudioPlayer(this); - this.bookmarks = new FluidbookBookmarks(this); - this.tooltip = new FluidbookTooltip(this); - this.accessibility = new FluidbookAccessibility(this); - this.sound = new FluidbookSound(this); - if (window.FluidbookSlideshow) { - this.slideshow = new FluidbookSlideshow(this); - } - this.printing = new FluidbookPrint(this); - this.posad = new FluidbookPOSAd(this); - this.notes = new FluidbookNotes(this); - this.gamify = new FluidbookGamify(this); - - if (this.settings.basket) { - this.cart = new FluidbookCart(this); - } - if (this.settings.form === 'bulle') { - this.form = new FluidbookBulleForm(this); - } else if (this.settings.form === 'bourbon') { - this.form = new FluidbookBourbonForm(this); - } else if (this.settings.form === 'avery') { - this.form = new FluidbookAveryForm(this); - } else { - this.form = false; - } - this.privacy = new FluidbookPrivacy(this); - if (typeof window.FluidbookTabs === 'function') { - this.tabs = new FluidbookTabs(this); - } - this.widget = new FluidbookWidget(this); - - this.refw = 0; - this.refh = 0; - this.searchString = ''; - this.vectorTexts = !this.support.imagesVersion; - this.indexHTML = ''; - this.gal = null; - this.isReady = false; - this.transitionAxis = 'x'; - if (this.support.isMobile) { - $("body").addClass('mobile'); - } else { - $("body").addClass('desktop'); - } - if (this.pad.enabled) { - $("body").addClass('pad'); - } - $('html').addClass(this.settings.mobileLVersion); - this.currentPage = -1; - this.currentPageURL = -1; - - this.contentlock.init(); - - this.nav = new FluidbookNav(this); - this.interface = new FluidbookInterface(this); - this.resize = new FluidbookResize(this); - this.pagetransitions = new FluidbookPageTransition(this); - this.stats = new FluidbookStats(this); - this.stats.track(10); - this.help = new FluidbookHelp(this); - this.articles = new FluidbookArticles(this); - - this.initTheme(); - this.initLoading(); - }, - - initSettings: function (settings) { - this.settings = settings; - // - if ($_GET['transition'] != null) { - var map = {1: 'none', 2: 'slide', 3: 'flip', 4: 'flip3d'}; - this.settings.mobileTransitions = map[$_GET['transition']]; - } - if (this.nointerface) { - this.settings.mobileTransitions = 'none'; - } - - /** - * @deprecated - */ - this.datas = this.settings; - }, - - setMaxPage: function (p, allowbackwards) { - return this.contentlock.setMaxPage(p, allowbackwards); - }, - - initTheme: function () { - var $this = this; - - if (this.settings.arrowsTheme) { - $('html').addClass('sharp'); - } - - if (this.settings.invertMenuPosition) { - $('html').addClass('menu-inverted'); - } else { - $('html').addClass('menu-default'); - } - - $(document).on('fluidbook.init', function () { - var logoImg = $("#splash .logo img"); - if ($(logoImg).isLoaded()) { - $this.splashLogoLoaded(); - } else { - $(logoImg).on('load', function () { - $this.splashLogoLoaded(); - }); - } - }); - }, - - splashLogoLoaded: function () { - resize(); - $("#splash .logo img").css('opacity', 1); - }, - - initLoading: function () { - if ($("#loader svg").length > 0) { - return; - } - $("#loader").append(getSpriteIcon('interface-loader')); - this.displayLoader(); - var $this = this; - this.loader.preloadStart(function () { - $this.ready(); - }); - }, - - allowChangePage: function () { - var $this = this; - setTimeout(function () { - $this.canNavigate = true; - $($this).trigger('fluidbook.navigation.cannavigate'); - }, 1500); - }, - - ready: function () { - if (this.isReady) { - return; - } - - this.isReady = true; - - $("#main").css('display', 'block'); - - // Trigger a resize - resize(); - - // Trigger ready event - $(this).trigger('fluidbook.ready'); - $(document).trigger('fluidbook.ready'); - - // Initial address handling - this.changeAddress(); - - var $this = this; - setTimeout(function () { - $this.help.displayAtStartup(); - }, 1500); - }, - - loadPlugins: function () { - $.each(this.settings.plugins, function (k, plugin) { - try { - var functionName = plugin.replace(/\./g, '_'); - eval(functionName + '();'); - } catch (err) { - } - }); - $.each(this.settings.htmlmultimedia, function (k, code) { - try { - eval(code); - } catch (err) { - } - }); - }, - initPage: function (pageNr, doublePage, position) { - if ($("#page_" + pageNr).length > 0) { - return; - } - $(doublePage).find('.' + position).remove(); - var page = '
'; - $(doublePage).append(page); - }, - hidePage: function (position) { - $("#pages ." + position).hide(); - }, - canChangePage: function () { - try { - return this.pagetransitions.canChangePage(); - } catch (e) { - - } - return false; - }, - initVideos: function () { - this.video.initVideos(); - }, - getNextOffset: function () { - var offset = 2; - if (this.displayOnePage) { - offset = 1; - } - this.transitionAxis = 'x'; - return offset; - }, - goNextPage: function () { - if (!this.canChangePage()) { - return; - } - - if (this.search.resultsNavActive()) { - this.search.nextResultsPage(); - } else { - this.transitionAxis = 'x'; - this.setCurrentPage(this.normalizePage(this.currentPage) + this.getNextOffset()); - } - }, - goFirstPage: function () { - if (!this.canChangePage()) { - return; - } - this.transitionAxis = 'x'; - this.setCurrentPage(1); - }, - goPreviousPage: function () { - if (!this.canChangePage()) { - return; - } - - if (this.search.resultsNavActive()) { - this.search.previousResultsPage(); - } else { - this.transitionAxis = 'x'; - this.setCurrentPage(this.normalizePage(this.currentPage) - this.getNextOffset()); - } - }, - goLastPage: function () { - if (!this.canChangePage()) { - return; - } - this.transitionAxis = 'x'; - this.setCurrentPage(this.contentlock.getMaxPage()); - }, - goNextChapter: function () { - if (!this.canChangePage()) { - return; - } - var next = this.bookmarks.getNextGroupCover(this.currentPage); - if (next === false) { - return; - } - this.transitionAxis = 'x'; - this.setCurrentPage(this.normalizePage(next)); - }, - goPreviousChapter: function () { - if (!this.canChangePage()) { - return; - } - var prev = this.bookmarks.getPreviousGroupCover(this.currentPage); - if (prev === false) { - return; - } - this.transitionAxis = 'x'; - this.setCurrentPage(this.normalizePage(prev)); - }, - goNextChapterPage: function () { - if (!this.canChangePage()) { - return; - } - - var next = this.bookmarks.getNextPageInGroupOfPage(this.currentPage); - if (next === false) { - return; - } - this.transitionAxis = 'y'; - this.setCurrentPage(this.normalizePage(next)); - }, - goPreviousChapterPage: function () { - if (!this.canChangePage()) { - return; - } - - var prev = this.bookmarks.getPreviousPageInGroupOfPage(this.currentPage); - if (prev === false) { - return; - } - this.transitionAxis = 'y'; - this.setCurrentPage(this.normalizePage(prev)); - }, - normalizePage: function (page) { - page = Math.max(1, Math.min(page, this.contentlock.getMaxPage())); - if (!this.displayOnePage && page % 2 === 1) { - page--; - } - return page; - }, - setCurrentPage: function (page) { - window.location.hash = "#/page/" + this.normalizePage(page); - }, - changeAddress: function () { - var hash = window.location.hash; - if ($('.mview[data-hash="' + hash + '"]').length > 0) { - return; - } - var $this = this; - var page; - var args = hash.split('/'); - var defaultStartPage = 1; - - if (FLUIDBOOK_START_PAGE !== undefined) { - defaultStartPage = FLUIDBOOK_START_PAGE; - } - - if (args.length <= 1 || args[1] == '' || args[1] == undefined) { - if (this.landingpage !== undefined && this.landingpage.hasLandingPage) { - window.location.hash = '/landing'; - return; - } - return this.setCurrentPage(defaultStartPage); - } - - // Handle flash URL. See #2640 - if (args.length > 1) { - var a1 = args[1]; - if (a1.match(/^[0-9]+$/)) { - args = ['#', 'page', a1]; - } - } - - $(this).trigger('fluidbook.hashchange', [args.slice()]); - - if (args[1] === 'closeview') { - s - return this.setCurrentPage(this.currentPage); - } else if (args[1] === 'page') { - var anchor = false; - if (fluidbook.settings.pageLabels[args[2]] !== undefined) { - page = fluidbook.settings.pageLabels[args[2]]; - anchor = args[2]; - } else { - page = parseInt(args[2]); - } - - if (isNaN(page) || page == undefined) { - return this.setCurrentPage('1'); - } - this.currentPageURL = page; - - if (page !== $this.currentPage) { - $($this).trigger('fluidbook.page.navigation', [page]); - $($this).trigger('changePage', [page]); - } - if (this.landingpage !== undefined) { - this.landingpage.hide(); - } - - this.menu._closeView(function () { - if (page !== $this.currentPage) { - $this.pagetransitions.pageTransition(page); - $this.stats.track(0, page); - if (anchor) { - $this.scrollToAnchorAfterTransition(anchor); - } - } else { - if (anchor) { - $this.scrollToAnchor(anchor); - } - } - $this.zoom.resetZoom(); - $this.splash.hide(); - }, true); - } else if (args[1] === 'landing') { - $this.splash.hide(); - if (this.landingpage !== undefined) { - this.landingpage.show(); - } - } else { - var view = args[1]; - - if (this.currentPage === -1) { - // Allow direct linking to specific types of content - if (view === 'multimedia' || view === 'video' || view === 'iframe' || view === 'slideshow') { - var searchURL = args.join('/'); - $.each(this.settings.links, function (pageNr, links) { - var hl = $('' + links + ''); - if ($(hl).find('[href="' + searchURL + '"]').length > 0) { - $this.currentPage = pageNr; - return false; - } - }); - if (this.currentPage === -1) { - this.currentPage = 0; - } - } else { - this.currentPage = 0; - } - - // Jump to correct page containing this content - // TODO: Investigate why this doesn't work properly - it should go to the page containing the link but it seems to get reset to 0, possibly caused by a resize function... - $this.pagetransitions.pageTransition(this.currentPage); - } - this.menu.openView(view, args[2], args[3], function () { - $this.splash.hide(); - }); - } - return; - }, - - scrollToAnchor: function (anchor) { - if (!this.mobilefirst.enabled) { - return; - } - var id = $('[data-anchor="' + anchor + '"]').attr('id'); - TweenMax.to($("#scroll"), 0.5, {scrollTo: {y: '#' + id, offsetY: $('header').outerHeight() + 10}}); - }, - - scrollToAnchorAfterTransition: function (anchor) { - if (!this.mobilefirst.enabled) { - return; - } - var $this = this; - if (this.splash.isVisible()) { - $(this).one('fluidbook.splash.hide', function () { - $this.scrollToAnchor(anchor); - }); - } else { - $(this).one('fluidbook.page.change.end', function () { - $this.scrollToAnchor(anchor); - }); - } - }, - - silentChangePage: function (page, transition) { - if (page !== this.currentPage) { - if (transition !== true) { - this.currentPage = page; - } - this.pagetransitions.pageTransition(page); - } - }, - - reloadCurrentPage: function () { - this.pageTransition(this.currentPage); - }, - - readingPage: function (side) { - if (!this.displayOnePage) { - var page = this.currentPage; - var change = false; - if (side === 'left' && page % 2 === 1) { - page--; - change = true; - } else if (side === 'right' && page % 2 === 0) { - page++; - change = true; - } - if (change) { - window.location.hash = "/page/" + page; - } - } - }, - getButtonsVisibility: function (page) { - if (page === undefined) { - page = this.currentPage; - } - - var max = this.contentlock.getMaxPage(); - if (this.contentlock.getMaxPage() % 2 === 1 && - this.settings.mobileNavigationType !== 'portrait' && - this.settings.mobileNavigationType !== 'mobilefirst' && - this.resize.orientation !== 'portrait') { - max--; - } - - var next = page < max; - var previous = (page > 1); - return {previous: previous, next: next}; - }, - hideUnnecessaryButtons: function (page) { - var speed = 500; - if (page === undefined) { - page = this.currentPage; - speed = 0; - } - - var visibility = this.getButtonsVisibility(page); - - if (visibility.next) { - this.showArrows("#next-arrows"); - } else { - this.hideArrows("#next-arrows"); - } - - if (visibility.previous) { - this.showArrows("#prev-arrows"); - } else { - this.hideArrows("#prev-arrows"); - } - }, - - hideArrows: function (id) { - $(id).addClass('hidden').attr('aria-hidden', 'true'); - $(id).find('a').prop('tabindex', -1); - }, - - showArrows: function (id) { - $(id).removeClass('hidden').attr('aria-hidden', 'false'); - $(id).find('a').prop('tabindex', 0); - }, - - updateShadows: function (page, animationDuration) { - if (animationDuration === undefined) { - animationDuration = 0; - } - animationDuration *= 1000; - var delay; - if (animationDuration === 0) { - delay = 0; - } else { - delay = animationDuration; - } - - var left = true, right = true; - if (!this.displayOnePage) { - if ((page <= 1 && this.l10n.dir === 'ltr') || (page >= this.contentlock.getMaxPage() && this.l10n.dir === 'rtl')) { - left = false; - } else if ((page <= 1 && this.l10n.dir === 'rtl') || (page >= this.contentlock.getMaxPage() && this.l10n.dir === 'ltr')) { - right = false; - } - } - - var s = $("#shadow,#edges"); - - var s_in = []; - var s_out = []; - - if (left) { - s_in.push(".left.hidden"); - } else { - s_out.push(".left:not('.hidden')"); - } - - if (right) { - s_in.push(".right.hidden"); - } else { - s_out.push(".right:not('.hidden')"); - } - - if (s_in.length > 0) { - setTimeout(function () { - $(s).children(s_in.join(',')).removeClass('hidden'); - }, delay); - } - if (s_out.length > 0) { - $(s).children(s_out.join(',')).addClass('hidden'); - } - } - , - showAllButtons: function () { - $("#next-arrows,#prev-arrows").addClass('help').show(); - }, - - setPageNumbers: function () { - $("#pagesnumbers .left").html(this.getPageNumberOfSide('left', true)); - $("#pagesnumbers .right").html(this.getPageNumberOfSide('right', true)); - $("#pagesnumbers").removeClass('hidden'); - }, - getPhysicalPageNumberOfSide: function (side, strict) { // Side should be 'left' or 'right' - if (undefined === strict) { - strict = false; - } - - var pageSide = $("#currentDoublePage").find('.' + side); - if (pageSide.length === 0) { - if (strict) { - return false; - } - pageSide = $("#currentDoublePage").find('.page').eq(0); - } - return $(pageSide).data('page'); - }, - getDisplayedPages: function () { - var res = []; - var left = this.getPhysicalPageNumberOfSide('left', true); - var right = this.getPhysicalPageNumberOfSide('right', true); - if (left !== false) { - res.push(left); - } - if (right !== false) { - res.push(right); - } - return res; - }, - - getPageNumberOfSide: function (side, strict) { - if (undefined === strict) { - strict = false; - } - - var physical = this.getPhysicalPageNumberOfSide(side, strict); - if (!physical || physical === 1) { - return ''; - } - return this.physicalToVirtual(physical); - }, - clickLogo: function () { - if (this.settings.url_link == '' || this.settings.url_link == 'http://') { - return; - } - - if (this.settings.url_link.indexOf('#') === 0) { - window.location.hash = this.settings.url_link; - } else { - this.wopen(this.settings.url_link, '_blank'); - } - }, - - addWaiter: function (reset) { - if (reset == undefined) { - reset = false; - } - if (reset) { - this.resetWaiters(); - } - var rand = Math.round(Math.random() * 100000); - this.waiters.push(rand); - return rand; - }, - waiterActive: function (id) { - return this.waiters.indexOf(id) > -1; - }, - resetWaiters: function () { - this.waiters = []; - }, - physicalToVirtual: function (page) { - return this.settings.numerotation[page - 1]; - }, - virtualToPhysical: function (page) { - if (page === undefined) { - return false; - } - var i = this.settings.numerotation.indexOf(page.toString()); - if (i == -1) { - return false; - } - return i + 1; - }, - - hideMenuItems: function () { - $('#menuList > ul > li, #shareLinks,footer#mobile-credits').fadeOut(100); - - }, - - showMenuItems: function () { - $('#menuList > ul > li, #shareLinks,footer#mobile-credits').fadeIn(300); - }, - - print: function (button) { - this.stats.track(3); - return this.openPDF(button, true); - }, - - downloadPDF: function (button) { - this.stats.track(7); - return this.openPDF(button, false) - }, - - openPDF: function (button, print) { - var $this = this; - var pdf; - var pdfName; - - if (this.settings.pages != this.contentlock.getMaxPage()) { - pdf = 'https://workshop.fluidbook.com/s/e/' + this.settings.cid + '/1-' + this.contentlock.getMaxPage(); - } else if (this.settings.pdfName.substr(0, 4) === 'http') { - pdf = this.settings.pdfName; - } else { - pdf = this.relativeToAbsolute('data/' + this.settings.pdfName); - } - var e = pdf.split('/'); - pdfName = e.pop(); - - this._openFile(pdf, button, 'pdf', pdfName, print); - }, - - _openFile: function (url, e, type, localname, print) { - if (print === undefined) { - print = false; - } - - var $this = this; - if (this.settings.phonegap != false) { - if (type == undefined) { - var e = url.split('.'); - type = e.pop(); - } - - if (url.indexOf('http') === 0) { - return this._downloadFilePhonegap(url, localname, window.TEMPORARY, this._openFilePhonegap, [url, e, type]); - } else { - if (this._openFilePhonegap(url, e, type)) { - return; - } - } - - } - var w = this.wopen(url, '_blank', ''); - if (print) { - setTimeout(function () { - w.print(); - }, 2000); - } - }, - - _openFilePreload: function (url, e, type, localname, print) { - - var $this = this; - var f = function () { - $this._openFile(url, e, type, localname, print); - }; - - if (this.settings.phonegap != false) { - this.displayLoader(); - $.ajax({ - url: url, - type: 'HEAD', - success: function (data) { - f(); - $this.hideLoader(1, true); - }, - }); - } else { - f(); - } - - }, - - _downloadFilePhonegap: function (url, localname, fs, callback, callbackArgs) { - console.log('download file phonegap'); - var $this = this; - if (fs === undefined) { - fs = LocalFileSystem.PERSISTENT; - } - - var requestFileSystem = window.requestFileSystem || - window.webkitRequestFileSystem; - - requestFileSystem(fs, 0, function (fileSystem) { - console.log('fs requested'); - fileSystem.root.getFile("dummy.html", {create: true, exclusive: false}, function (fileEntry) { - console.log('dummy file created') - var filePath = fileEntry.toURL().replace("dummy.html", "") + localname; - var fileTransfer = new FileTransfer(); - var uri = encodeURI(url); - fileTransfer.download( - uri, - filePath, - function (entry) { - console.log('file donwloaded'); - if (callback !== undefined) { - if (callbackArgs === undefined) { - callbackArgs = []; - } - callbackArgs[0] = entry.toURL(); - callback.apply($this, callbackArgs); - } - }, - function (error) { - console.log('file error'); - } - ); - }); - }, function () { - - }); - }, - - _openFilePhonegap: function (url, e, type) { - var $this = this; - var types_ios = {pdf: 'com.adobe.pdf'}; - var types_android = {pdf: 'application/pdf'}; - if (this.settings.phonegap === 'ios') { - console.log('open download on ios ' + type + ' -> ' + types_ios[type]); - this.displayLoader(); - if (types_ios[type] !== undefined) { - console.log('intro to open with External file util'); - - try { - var offset = $(e).offset(); - - offset.left += ($(e).width() / 2); - offset.top += ($(e).height() / 2); - - offset.left *= 2; - offset.top *= 2; - - if ($(e).data('ios-preview') === '1') { - offset.top = offset.left = 0; - } - } catch (err) { - console.log('error while getting offset'); - } - - try { - console.log('attempt to open with External file util'); - ExternalFileUtil.openWith(url, types_ios[type], function () { - console.log('ok to open with External file util : ' + url); - - $this.hideLoader(); - }, function () { - console.log('failed to open with External file util'); - $this.wopen(url, "_blank", 'location=no'); - $this.hideLoader(); - }, offset); - } catch (err) { - console.error('unable to open with externalfileutil'); - $this.wopen(url, "_blank", 'location=no'); - $this.hideLoader(); - } - return true; - } - } - - if (this.settings.phonegap === 'android') { - if (types_android[type] !== undefined) { - - var errorCallback = function (e) { - $this.bugreport(e); - $this.hideLoader(); - }; - - console.log('open pdf file'); - this.displayLoader(); - try { - window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, function (fileSystem) { - console.log('got local file system'); - console.log('try to resolve url'); - window.resolveLocalFileSystemURL(url, function (entry) { - console.log('resolved from file'); - window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function (dirEntry) { - console.log('resolved to dir'); - entry.copyTo(dirEntry, entry.name, function (copyEntry) { - console.log('copied file'); - - window.plugins.webintent.startActivity({ - action: window.plugins.webintent.ACTION_VIEW, - type: types_android[type], - url: copyEntry.toURL() - }, function (args) { - $this.hideLoader(5); - }, function (args) { - $this.wopen(copyEntry.toURL(), '_blank', ''); - $this.hideLoader(5); - }); - }, errorCallback); - }, errorCallback); - }, errorCallback); - }, errorCallback); - } catch (e) { - $this.bugreport(e); - $this.hideLoader(); - } - } - return true; - } - return false; - }, - - relativeToAbsolute: function (relative) { - var a = document.createElement('a'); - a.href = relative; - return a.cloneNode(false).href; - }, - - alertInternetRequired: function () { - navigator.notification.alert('', function () { - - }, this.l10n.__('an internet connection is required for this action')); - }, - - touchOffset: function (offset) { - offset *= $("#currentDoublePage").width(); - $("#currentDoublePage").addClass('sliding'); - $("#currentDoublePage").css({ - translateX: offset - }); - }, - displayLoader: function () { - $("#loader").addClass('show'); - if (!this.support.isMobile) { - $('body').addClass('loading'); - } - }, - - hideLoader: function (delay, force) { - if (force == undefined) { - force = false; - } - if (delay == undefined) { - delay = 0; - } - var $this = this; - if (delay == 0) { - return this._hideLoader(force); - } - setTimeout(function () { - $this._hideLoader(force); - }, delay * 1000); - }, - - _hideLoader: function (force) { - if (force == undefined) { - force = false; - } - if (!force && $('#splash').css('visibility') == 'visible') { - return; - } - $("#loader").removeClass('show'); - if (!this.support.isMobile) { - $('body').removeClass('loading'); - } - }, - - wopen: function (url, target, options, print) { - var $this = this; - var win; - if (this.support.nwjs) { - win = nw.Window.get().window; - } else { - win = window; - } - - url = url.replace('$uuid', this.stats.vid); - - if (target == undefined) { - target = '_self'; - } - if (options == undefined) { - options = ''; - } - - // fix #3407 - if (target === '_popupiframe' && Modernizr.ios && url.search(/\.pdf$/) >= 0) { - target = '_blank'; - } - - var locationdefault = 'yes'; - var mtarget = target; - var replace = true; - if (this.settings.phonegap) { - if (target == '_unique' || target == '_new') { - mtarget = '_blank'; - } - } else { - if (target == '_new') { - mtarget = 'fb_' + this.settings.id + '_' + Math.round(Math.random() * 10000000); - options += ',scrollbars=yes' - } else if (target == '_unique') { - mtarget = 'fb_' + this.settings.id; - options += ',scrollbars=yes' - } else { - - } - } - - if (this.settings.phonegap) { - locationdefault = 'yes'; - } - - if (options == '') { - options = 'location=' + locationdefault; - } else if (options.indexOf('location=') == -1) { - options += ',location=' + locationdefault; - } - - if (this.settings.phonegap && mtarget == '_blank') { - options += ',zoom=yes,enableViewportScale=yes' - } - - if (!this.settings.phonegap && mtarget == '_blank') { - options = undefined; - replace = undefined; - } - // Open the window - if (mtarget === '_popupiframe') { - this.openInPopupIframe(url); - return false; - } - var w; - if (options == undefined && replace == undefined) { - if (this.support.IE == 0) { - w = win.open(url, mtarget); - console.log(w); - } else { - $("#wopen").remove(); - $('body').append(''); - $("#wopen").get(0).click(); - setTimeout(function () { - $("#wopen").remove(); - }, 200); - } - } else { - w = win.open(url, mtarget, options, replace); - } - - try { - // Attempt to focus opened windows (useful for already opened windows) - if (target == '_new' || target == '_unique') { - w.focus(); - } - } catch (e) { - - } - return w; - }, - - openInPopupIframe: function (url, callback) { - this.menu.openView('freeiframe', url, '', function () { - if (callback !== undefined) { - callback(); - } - }); - }, - - setFlag: function (name, value) { - if (value === undefined) { - value = true; - } - this.flags[name] = value; - }, - - hasFlag: function (name) { - return this.flags[name] === true; - }, - - hasFlags: function (names) { - var res = true; - var $this = this; - $.each(names, function (k, v) { - if ($this.hasFlag(v)) { - return; - } - res = false; - return true; - }); - return res; - }, - - unlockCurrentPage: function () { - this.contentlock.unlockCurrentPage(); - }, - - bugreport: function (e) { - if (window.confirm('An error occured: ' + e.name + '. Do you want to send a report ?')) { - var subject = '[Fluidbook error report] ' + e.message; - var o = { - name: e.name, - message: e.message, - stack: e.stack, - } - window.location = 'mailto:tech@fluidbook.com?subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(JSON.stringify(o)); + this.shortLoading = this.nointerface = true; } - }, -} -function Fluidbook(settings) { - this.init(settings); -} - -// Constantes -// Background dispoition -Fluidbook.NONE = 3; -Fluidbook.STRETCH = 0; -Fluidbook.RATIO = 2; -Fluidbook.REPEAT = 1; -// Horizontal alignments -Fluidbook.CENTER = 4; -Fluidbook.LEFT = 5; -Fluidbook.RIGHT = 6; -// Vertical alignments -Fluidbook.MIDDLE = 7; -Fluidbook.TOP = 8; -Fluidbook.BOTTOM = 9; - -Fluidbook.prototype = { - init: function (settings) { - this.flags = {}; - this.canNavigate = false; - - if ($_GET['nointerface'] !== undefined) { - $('body').addClass('nointerface'); - settings.mobileTransitions = 'none'; - this.nointerface = true; - } else { - this.nointerface = false; + if ($_GET['shortLoading'] !== undefined) { + console.info('Short loading'); + this.shortLoading = true; } this.initSettings(settings); @@ -1299,7 +157,7 @@ Fluidbook.prototype = { var map = {1: 'none', 2: 'slide', 3: 'flip', 4: 'flip3d'}; this.settings.mobileTransitions = map[$_GET['transition']]; } - if (this.nointerface) { + if (this.shortLoading) { this.settings.mobileTransitions = 'none'; } @@ -2291,4 +1149,4 @@ Fluidbook.prototype = { window.location = 'mailto:tech@fluidbook.com?subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(JSON.stringify(o)); } }, -} +}; diff --git a/js/libs/fluidbook/fluidbook.loader.js b/js/libs/fluidbook/fluidbook.loader.js index 805da53e..081bef92 100644 --- a/js/libs/fluidbook/fluidbook.loader.js +++ b/js/libs/fluidbook/fluidbook.loader.js @@ -55,7 +55,7 @@ FluidbookLoader.prototype = { }, preloadStart: function (callback) { - if (this.fluidbook.nointerface) { + if (this.fluidbook.shortLoading) { this.toPreload = [1]; } else { this.toPreload = [1, 2, 3]; @@ -218,7 +218,7 @@ FluidbookLoader.prototype = { numPreloadBefore /= 2; } - if (this.fluidbook.nointerface) { + if (this.fluidbook.shortLoading) { numPreloadAfter = numPreloadBefore = 0; } @@ -768,7 +768,7 @@ FluidbookLoader.prototype = { callbackCalled = true; cb(); } - }, $this.fluidbook.nointerface ? 0 : 10); + }, $this.fluidbook.shortLoading ? 0 : 10); } } diff --git a/js/libs/fluidbook/fluidbook.networkcontrol.js b/js/libs/fluidbook/fluidbook.networkcontrol.js index 2f6e5a4c..03788239 100644 --- a/js/libs/fluidbook/fluidbook.networkcontrol.js +++ b/js/libs/fluidbook/fluidbook.networkcontrol.js @@ -38,7 +38,7 @@ FluidbookNetworkControl.prototype = { }, executeWhenNetwork: function (f, highPriority) { - if (this.fluidbook.nointerface) { + if (this.fluidbook.shortLoading) { f(); return; } diff --git a/js/libs/fluidbook/fluidbook.splash.js b/js/libs/fluidbook/fluidbook.splash.js index 98119b66..f14dda1a 100644 --- a/js/libs/fluidbook/fluidbook.splash.js +++ b/js/libs/fluidbook/fluidbook.splash.js @@ -17,7 +17,7 @@ FluidbookSplash.prototype = { min = defaultMin; } - if (this.fluidbook.nointerface) { + if (this.fluidbook.shortLoading) { min = 0; this.waitForTimer = false; this.hideIfPossible(); @@ -42,7 +42,7 @@ FluidbookSplash.prototype = { } $(this.fluidbook).trigger('fluidbook.splash.beforehide'); var $this = this; - if (this.fluidbook.support.transitions3dacc && this.fluidbook.settings.mobileTransitions === 'flip3d' && !this.fluidbook.mobilefirst.enabled && !this.fluidbook.nointerface) { + if (this.fluidbook.support.transitions3dacc && this.fluidbook.settings.mobileTransitions === 'flip3d' && !this.fluidbook.mobilefirst.enabled && !this.fluidbook.shortLoading) { $("#main,#viewOverlay,#view").css('visibility', 'visible'); resize(); this.fluidbook.networkControl.pause(4000); @@ -73,7 +73,7 @@ FluidbookSplash.prototype = { _hide: function () { this.isHidding=true; var $this = this; - var timeout = this.fluidbook.nointerface ? 0 : 700; + var timeout = this.fluidbook.shortLoading ? 0 : 700; this.fluidbook.resize.resize(false, true); setTimeout(function () { $this.__hide(); @@ -85,7 +85,7 @@ FluidbookSplash.prototype = { this.fluidbook.resize.resize(false); this.fluidbook.hideLoader(0, true); - if (this.fluidbook.nointerface) { + if (this.fluidbook.shortLoading) { $('#splash').remove(); } else if (this.fluidbook.support.transitions2d && !this.fluidbook.support.iOS) { $("#splash").css('opacity', 0).one('transitionend', function () { diff --git a/js/main.js b/js/main.js index 8f3105ad..58e25d16 100644 --- a/js/main.js +++ b/js/main.js @@ -253,6 +253,7 @@ try { } INITED = true; + console.log('init fluidbook'); window.fluidbook = new Fluidbook(SETTINGS); if (null != gal) { fluidbook.gal = gal;