From: Vincent Vanwaelscappel Date: Tue, 2 Jun 2020 18:26:31 +0000 (+0200) Subject: wip #3634 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=85e06b3ed9763173f25f159688e82b346f95e8ee;p=fluidbook-html5.git wip #3634 --- diff --git a/js/libs/fluidbook/fluidbook.articles.js b/js/libs/fluidbook/fluidbook.articles.js index 24ec0568..05cbc823 100644 --- a/js/libs/fluidbook/fluidbook.articles.js +++ b/js/libs/fluidbook/fluidbook.articles.js @@ -8,9 +8,56 @@ FluidbookArticles.prototype = { if (!this.isEnabled()) { return; } + + var $this = this; + $(this.fluidbook).on('fluidbook.resize', function () { + console.log('resize'); + $this.resize(); + }); + + $(document).on('click', '.mview[data-menu="article"] .print', function () { + var a = $(this).closest('article').attr('data-id'); + var print_window = window.open('', 'print_article', 'height=400,width=600'); + print_window.document.write($this.fluidbook.settings.articlesList[a].print); + setTimeout(function () { + print_window.focus(); + print_window.print(); + print_window.close(); + }, 1000); + return false; + }); + }, + + openArticle: function (url, callback) { + var article = this.findArticleByURL(url); + if (article === null) { + callback(); + } + + var footer = ''; + var view = '
' + article.contents + '
' + footer; + $("#view").html('
' + view + '
'); + + this.fluidbook.silentChangePage(article.page); + callback(); + }, + + findArticleByURL: function (url) { + var res = null; + $.each(this.fluidbook.settings.articlesList, function (k, v) { + if (v.url === url) { + res = v; + return false; + } + }); + return res; }, isEnabled: function () { - return this.fluidbook.settings.articlesList.length>0; - } + return Object.keys(this.fluidbook.settings.articlesList).length > 0; + }, + + resize: function () { + + }, } \ No newline at end of file diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index 085dede3..b5f1119f 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -481,6 +481,12 @@ Fluidbook.prototype = { return; }, + silentChangePage: function (page) { + if (page !== this.currentPage) { + this.currentPage = page; + this.pagetransitions.pageTransition(this.currentPage); + } + }, reloadCurrentPage: function () { this.pageTransition(this.currentPage); diff --git a/js/libs/fluidbook/fluidbook.menu.js b/js/libs/fluidbook/fluidbook.menu.js index d0dbf6cf..c51e286d 100644 --- a/js/libs/fluidbook/fluidbook.menu.js +++ b/js/libs/fluidbook/fluidbook.menu.js @@ -110,6 +110,8 @@ FluidbookMenu.prototype = { this.openPrint(cb); } else if (view === 'download') { this.openDownload(cb); + } else if (view === 'article') { + this.fluidbook.articles.openArticle(param1, cb); } else { this['open' + camelView](param1, param2, cb); } @@ -590,13 +592,11 @@ FluidbookMenu.prototype = { var forceHeight = false; var fullscreen = m.data('fullscreen') === '1'; var nw, nh; - var hasCaption = true; $("#viewOverlay").css({width: ww, height: hh}); switch (m.data('menu')) { case 'chapters': - hasCaption = this.fluidbook.settings.chaptersCaptionDisplay !== false; this.fluidbook.settings.chaptersColumns = Math.max(1, Math.min(6, this.fluidbook.settings.chaptersColumns)); if (this.fluidbook.settings.chaptersCascade) { this.fluidbook.settings.chaptersColumns = 1; @@ -649,6 +649,15 @@ FluidbookMenu.prototype = { case 'locales': w = 300; break; + case 'article': + h = hh * 0.9; + w = Math.min(ww,1000); + if(ww<800){ + w=ww; + h=hh; + fullscreen=true; + } + break; case 'iframe': w = ww * 0.8; if (parseInt(this.fluidbook.settings.iframePopupMaxWidth) > 0) { @@ -861,7 +870,6 @@ FluidbookMenu.prototype = { if (optimizeHeight) { thumbnailsHeight = 0; var contentHeight = h; - hasCaption = false; } var slideMaxHeight = h - headerHeight - thumbnailsHeight; // Remaining height that main image + caption has to fit into @@ -908,7 +916,11 @@ FluidbookMenu.prototype = { break; } - var captionHeight = m.find('.caption').outerHeight(); + var captionHeight = 0; + m.find('.caption, .fixed').each(function () { + captionHeight += $(this).outerHeight(); + }) + css = {}; ccss = {}; if (fullscreen) { @@ -921,22 +933,16 @@ FluidbookMenu.prototype = { } else { m.removeClass('fs'); } + css.maxWidth = css.minWidth = css.width = w; css.maxHeight = h; - if (hasCaption) { - ccss.maxHeight = h - captionHeight; - } else { - ccss.maxHeight = h; - } + + ccss.maxHeight = h - captionHeight; if (forceHeight) { css.minHeight = css.height = h; if (contentHeight === undefined) { - if (hasCaption) { - ccss.minHeight = ccss.height = h - captionHeight; - } else { - ccss.minHeight = ccss.height = h; - } + ccss.minHeight = ccss.height = h - captionHeight; // if (m.find('.fonctions').length > 0) { // ccss.height -= m.find('.fonctions').outerHeight(); @@ -948,6 +954,7 @@ FluidbookMenu.prototype = { } else { ccss.minHeight = ccss.height = css.minHeight = css.height = ''; } + m.css(css); m.find(".content").css(ccss).attr('data-height', ccss.height); if (!fullscreen) { diff --git a/style/fluidbook.less b/style/fluidbook.less index 196fc7e9..3f602757 100644 --- a/style/fluidbook.less +++ b/style/fluidbook.less @@ -2873,3 +2873,4 @@ body > input { @import "mobilefirst.less"; @import "tabs.less"; @import "widget.less"; +@import "menu-articles.less"; \ No newline at end of file