]> _ Git - fluidbook-html5.git/commitdiff
wip #3634
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 2 Jun 2020 18:26:31 +0000 (20:26 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 2 Jun 2020 18:26:31 +0000 (20:26 +0200)
js/libs/fluidbook/fluidbook.articles.js
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.menu.js
style/fluidbook.less

index 24ec05682e7359b92f1bc83aeb5c75421e953c6a..05cbc823ef16900c39d7bb8cecfcbb382b7d856c 100644 (file)
@@ -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 = '<div class="footer fixed"><a href="#/article/' + article.prev + '" class="article-prev">' + getSpriteIcon('interface-previous-simple') + ' ' + this.fluidbook.l10n.__('previous article') + '</a><a href="#/article/' + article.next + '" class="article-next">' + this.fluidbook.l10n.__('next article') + ' ' + getSpriteIcon('interface-next-simple') + '</a></div>';
+        var view = '<div class="content">' + article.contents + '</div>' + footer;
+        $("#view").html('<div class="mview" data-menu="article">' + view + '</div>');
+
+        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
index 085dede32b0f92d0df29c5bd4a93126821b782c1..b5f1119fae63d4ab07fae28db419defb16acc39c 100644 (file)
@@ -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);
index d0dbf6cfe39a79e1879ae8e8f4f1cef0a39facb0..c51e286d371cf314fba81951191f81b7a4b4ec25 100644 (file)
@@ -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) {
index 196fc7e9b02e652c573f763c3bcc0e6874357bd9..3f602757257d98f357987c8a1e1383b6d8567250 100644 (file)
@@ -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