]> _ Git - fluidbook-html5.git/commitdiff
wait #2531 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 23 Jan 2019 14:47:58 +0000 (15:47 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 23 Jan 2019 14:47:58 +0000 (15:47 +0100)
js/libs/fluidbook/fluidbook.nav.js
js/libs/fluidbook/fluidbook.print.js

index e6c16a57800992f23e1befc30a3be000d53534ec..dd125eeaf6a48a593116b0d6c5164a70336e9108 100644 (file)
@@ -709,7 +709,7 @@ FluidbookNav.prototype = {
 
         // Print icon
         $(document).on('click', '.icon-print', function () {
-            if ($this.fluidbook.datas.phonegap !== false) {
+            if (!$this.fluidbook.printing.advancedPrint()) {
                 $this.fluidbook.print($(this));
                 return false;
             } else {
index 2bbed8eed77ce7d876b462f69d313992bff7c81b..53fe2ff5d1d606c3b981e5d2ae42c68d37d84ba2 100644 (file)
@@ -9,7 +9,7 @@ FluidbookPrint.prototype = {
         var $this = this;
 
         // Handle click on Print/Download button inside dialogue
-        $(document).on('click', '#confirmChoice', function(event) {
+        $(document).on('click', '#confirmChoice', function (event) {
             event.preventDefault();
 
             // ToDo: Consider what happens if Fluidbook is self-hosted or offline (maybe here is not the best place to handle that)
@@ -23,29 +23,29 @@ FluidbookPrint.prototype = {
                 choice = $('input[name="pageChoice"]:checked').val();
 
             switch (choice) {
-              case 'left':
-                $this.fluidbook._openFile(dynamicPDF + leftPageNumber, element, 'pdf', leftPageNumber + '.pdf', print);
-                break;
-              case 'right':
-                $this.fluidbook._openFile(dynamicPDF + rightPageNumber, element, 'pdf', rightPageNumber + '.pdf', print);
-                break;
-              case 'double':
-                var pageRange = leftPageNumber + '-' + rightPageNumber;
-                $this.fluidbook._openFile(dynamicPDF + pageRange, element, 'pdf', pageRange + '.pdf', print);
-                break;
-              case 'all':
-                $this.fluidbook.openPDF(element, print);
-                break;
-              case 'bookmarks':
-                $this.fluidbook.bookmarks.openPDF(element, print);
-                break;
-              default:
-                return false;
+                case 'left':
+                    $this.fluidbook._openFile(dynamicPDF + leftPageNumber, element, 'pdf', leftPageNumber + '.pdf', print);
+                    break;
+                case 'right':
+                    $this.fluidbook._openFile(dynamicPDF + rightPageNumber, element, 'pdf', rightPageNumber + '.pdf', print);
+                    break;
+                case 'double':
+                    var pageRange = leftPageNumber + '-' + rightPageNumber;
+                    $this.fluidbook._openFile(dynamicPDF + pageRange, element, 'pdf', pageRange + '.pdf', print);
+                    break;
+                case 'all':
+                    $this.fluidbook.openPDF(element, print);
+                    break;
+                case 'bookmarks':
+                    $this.fluidbook.bookmarks.openPDF(element, print);
+                    break;
+                default:
+                    return false;
             }
         });
 
         // When there are no bookmarks a click on the bookmarks option will open the bookmarks help modal
-        $(document).on('click', '.bookmarks-option.disabled', function(event) {
+        $(document).on('click', '.bookmarks-option.disabled', function (event) {
             event.preventDefault();
 
             $this.fluidbook.menu.quickCloseView();
@@ -66,8 +66,8 @@ FluidbookPrint.prototype = {
             isLastPage = (this.fluidbook.currentPage == this.fluidbook.datas.pages),
             isSinglePageMode = (this.fluidbook.resize.orientation == 'portrait'),
             buttonLabels = {
-                'print' : __('print'),
-                'download' : __('download')
+                'print': __('print'),
+                'download': __('download')
             },
             view = '';
 
@@ -102,7 +102,7 @@ FluidbookPrint.prototype = {
             if (!isFirstPage) {
                 view += '<div class="thumb left blank"><div class="blank-mask"></div></div>';
             }
-            view += '<div class="thumb '+ (isFirstPage ? 'left' : 'right') +'">'; // Only shows 1 page when on first page
+            view += '<div class="thumb ' + (isFirstPage ? 'left' : 'right') + '">'; // Only shows 1 page when on first page
             view += this.fluidbook.loader.getThumbImage(rightPageNumber, null, true);
             view += '</div>'; // .thumb
             view += '</div>'; // .doubleThumb
@@ -145,18 +145,18 @@ FluidbookPrint.prototype = {
 
         // Bookmarks
         if (this.fluidbook.datas.bookmark) {
-          var hasBookmarks = this.fluidbook.bookmarks.hasBookmarkedPages(),
-          bookmarksDisabled = hasBookmarks ? '' : 'disabled';
-
-          view += '<div class="print-option bookmarks-option '+ bookmarksDisabled +'">';
-          view += '<label for="bookmarkedPages">';
-          view += '<div class="doubleThumb bookmarks">';
-          view += this.fluidbook.bookmarks.getPrintPreview();
-          view += '</div>'; // .doubleThumb
-          view += '</label>';
-          view += '<input type="radio" name="pageChoice" value="bookmarks" id="bookmarkedPages" '+ bookmarksDisabled +'>'
-          view += '<label for="bookmarkedPages" class="print-label-text">' + __('bookmarks') + '</label>';
-          view += '</div>'; // .print-option
+            var hasBookmarks = this.fluidbook.bookmarks.hasBookmarkedPages(),
+                bookmarksDisabled = hasBookmarks ? '' : 'disabled';
+
+            view += '<div class="print-option bookmarks-option ' + bookmarksDisabled + '">';
+            view += '<label for="bookmarkedPages">';
+            view += '<div class="doubleThumb bookmarks">';
+            view += this.fluidbook.bookmarks.getPrintPreview();
+            view += '</div>'; // .doubleThumb
+            view += '</label>';
+            view += '<input type="radio" name="pageChoice" value="bookmarks" id="bookmarkedPages" ' + bookmarksDisabled + '>'
+            view += '<label for="bookmarkedPages" class="print-label-text">' + __('bookmarks') + '</label>';
+            view += '</div>'; // .print-option
         }
 
         view += '<div class="print-option"></div>'; // Extra empty div to ensure flexbox space-between works as expected
@@ -165,12 +165,23 @@ FluidbookPrint.prototype = {
 
         // Action buttons
         view += '<div class="fonctions">';
-        view += '<a id="confirmChoice" href="#" data-mode="'+ mode +'">'+ buttonLabels[mode] +'</a>';
+        view += '<a id="confirmChoice" href="#" data-mode="' + mode + '">' + buttonLabels[mode] + '</a>';
         view += '</div>'; // .fonctions
 
         view += '</div>'; // .content
 
         return view;
+    },
+
+    advancedPrint: function () {
+        if (this.fluidbook.datas.phonegap !== false) {
+            return false;
+        }
+        if (this.fluidbook.support.offline && !this.fluidbook.datas.offlineEnableAdvancedPrinting) {
+            return false;
+        }
+
+        return true;
     }
 };