]> _ Git - fluidbook-html5.git/commitdiff
wip #4083 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 20 Nov 2020 19:52:28 +0000 (20:52 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 20 Nov 2020 19:52:28 +0000 (20:52 +0100)
js/libs/fluidbook/fluidbook.links.js
js/libs/fluidbook/slideshow/fluidbook.slideshow.dummy.js
js/libs/fluidbook/slideshow/fluidbook.slideshow.js
js/libs/fluidbook/slideshow/fluidbook.slideshow.splide.js
js/libs/fluidbook/slideshow/fluidbook.slideshow.vacheron.js
style/slideshow/dummy.less [new file with mode: 0644]
style/slideshow/vacheron.less [new file with mode: 0644]

index efb655d4d18b084919f91ceb9ca1f05aafe92768..710c73414f0e729a93145b43e8faab0f7f33824c 100644 (file)
@@ -20,7 +20,6 @@ function FluidbookLinks(fluidbook) {
     } catch (e) {
 
     }
-    this.initInlineSlideshowsIntervals = [];
     this.lowdef = false;
     this.init();
 }
@@ -741,56 +740,21 @@ FluidbookLinks.prototype = {
     },
 
     initInlineSlideshows: function () {
-        var $__this = this;
-
-        $.each(this.initInlineSlideshowsInterval, function (k, interval) {
-            clearInterval(interval);
-        });
+        var $this = this;
         $(".inlineslideshow").each(function () {
             if ($(this).is(':visible')) {
-                $__this.initSlideshow($(this));
+                $this.fluidbook.slideshow.initInlineSlideshow($(this));
             } else {
                 var $s = $(this);
                 $(this).closest('.link').on('fluidbook.link.show', function () {
                     if (!$s.data('init')) {
-                        $__this.initSlideshow($s);
+                        $this.fluidbook.slideshow.initInlineSlideshow($s);
                     }
                 });
             }
         });
     },
 
-    initSlideshow: function (s) {
-        var $this = this;
-        s.data('init', true);
-        var dir = 'data/links/' + $(s).data('dir') + '/';
-        $.each($(s).data('images'), function (k, i) {
-            var h = '<div class="slide" style="background-image: url(\'' + dir + i + '\');"></div>';
-            s.append(h);
-        });
-
-        // Move first to end
-        s.append(s.find('.slide:eq(0)'));
-
-        this.initInlineSlideshowsIntervals.push(setInterval(function () {
-            var current = s.find('.slide.show').eq(0);
-            var next = $(current).nextAll('.slide:not(.show):eq(0)');
-            if ($(next).length === 0) {
-                next = s.find('.slide:eq(0)');
-            }
-
-            $(next).css({display: 'block', zIndex: 2});
-
-            setTimeout(function () {
-                $(next).addClass('show').one($this.fluidbook.support.getTransitionEndEvent(), function () {
-                    $(current).removeClass('show').css('display', 'none');
-                    $(this).css({zIndex: ''});
-                });
-            }, 100);
-
-        }, parseFloat(this.fluidbook.settings.inlineSlideshowDuration) * 1000));
-    },
-
     resize: function () {
         var $this = this;
         $("#links .link.iframe").each(function () {
index eb8423b55301550e1da28b2704a48737092991a8..08d24a14ae8d09bb6381b5305a95389911e96bc8 100644 (file)
@@ -1,8 +1,37 @@
-function FluidbookVacheronSlideshow(fluidbook) {
+function FluidbookDummySlideshow(fluidbook) {
     this.fluidbook = fluidbook;
+    this.intervals = [];
 }
 
-FluidbookVacheronSlideshow.prototype = {
-    initSlideshow: function (id) {
-    }
+FluidbookDummySlideshow.prototype = {
+    initSlideshow: function (s) {
+        var $this = this;
+        s.data('init', true);
+        var dir = 'data/links/' + $(s).data('dir') + '/';
+        $.each($(s).data('images'), function (k, i) {
+            var h = '<div class="slide" style="background-image: url(\'' + dir + i + '\');"></div>';
+            s.append(h);
+        });
+
+        // Move first to end
+        s.append(s.find('.slide:eq(0)'));
+
+        this.intervals.push(setInterval(function () {
+            var current = s.find('.slide.show').eq(0);
+            var next = $(current).nextAll('.slide:not(.show):eq(0)');
+            if ($(next).length === 0) {
+                next = s.find('.slide:eq(0)');
+            }
+
+            $(next).css({display: 'block', zIndex: 2});
+
+            setTimeout(function () {
+                $(next).addClass('show').one($this.fluidbook.support.getTransitionEndEvent(), function () {
+                    $(current).removeClass('show').css('display', 'none');
+                    $(this).css({zIndex: ''});
+                });
+            }, 100);
+
+        }, parseFloat(this.fluidbook.settings.inlineSlideshowDuration) * 1000));
+    },
 };
index 962f54afa6b7b2e7fabed0a4d07c62612c9ed7fe..1379a2147ab94294e9e6c0965c10b54646571776 100644 (file)
@@ -5,18 +5,24 @@ function FluidbookSlideshow(fluidbook) {
     var $this = this;
 
     $.each(this.instances, function (k, v) {
-        var s = (k === 'inline' ? $this.fluidbook.settings.slideshowInlineLibrary : $this.fluidbook.settings.slideshowPopupLibrary);
+        var s = (k === 'inline' ? $this.fluidbook.settings.inlineSlideshowLibrary : $this.fluidbook.settings.popupSlideshowLibrary);
         switch (s) {
             case 'dummy':
-                $this.instances[k] = new FluidbookDummySlideshow($this.fluidbook);
+                if (window.FluidbookDummySlideshow !== undefined) {
+                    $this.instances[k] = new FluidbookDummySlideshow($this.fluidbook);
+                }
             case 'vacheron':
-                $this.instances[k] = new FluidbookVacheronSlideshow($this.fluidbook);
+                if (window.FluidbookVacheronSlideshow !== undefined) {
+                    $this.instances[k] = new FluidbookVacheronSlideshow($this.fluidbook);
+                }
                 break;
             case undefined:
             case null:
             case 'splide':
             default:
-                $this.instances[k] = new FluidbookSplideSlideshow($this.fluidbook);
+                if (window.FluidbookSplideSlideshow !== undefined) {
+                    $this.instances[k] = new FluidbookSplideSlideshow($this.fluidbook);
+                }
                 break;
         }
     });
@@ -26,18 +32,28 @@ function FluidbookSlideshow(fluidbook) {
 }
 
 FluidbookSlideshow.prototype = {
-    initPopupSlideshow: function (id) {
-        this.popupInstance.initSlideshow(id);
+    normalizeSlideshowElement: function (s) {
+        if ($(s).attr('id') == null) {
+            $(s).attr('id', 'slideshow_' + Math.round(Math.random() * 11000000));
+        }
+        return $(s);
+    },
+
+    initPopupSlideshow: function (s) {
+        var s = this.normalizeSlideshowElement(s);
+        this.popupInstance.initSlideshow(s);
     },
 
-    initInlineSlideshow: function (id) {
-        this.inlineInstance.initSlideshow(id);
+    initInlineSlideshow: function (s) {
+        var s = this.normalizeSlideshowElement(s);
+        this.inlineInstance.initSlideshow(s);
     },
-    initSlideshow: function (id, context) {
+    initSlideshow: function (s, context) {
+        var s = this.normalizeSlideshowElement(s);
         if (context === 'popup') {
-            this.initPopupSlideshow(id);
+            this.initPopupSlideshow(s);
         } else if (context === 'inline') {
-            this.initInlineSlideshow(id);
+            this.initInlineSlideshow(s);
         }
     }
 };
index 66b3bfb59314c8d36acaba138917aae83afbe4e5..a89dc2ca05396c4e8b8fed6a57049b8bbb21046b 100644 (file)
@@ -3,9 +3,9 @@ function FluidbookSplideSlideshow(fluidbook) {
 }
 
 FluidbookSplideSlideshow.prototype = {
-    initSlideshow: function (id) {
-        this.slideshowID = '#' + id;
-        this.$slideshow = $(this.slideshowID);
+    initSlideshow: function (s) {
+        this.$slideshow = $(s);
+        this.slideshowID = this.$slideshow.attr('id');
         this.$wrapper = this.$slideshow.parent();
         this.thumbnailsID = this.slideshowID + '_thumbnails';
         this.$thumbnails = $(this.thumbnailsID);
index 1017856770e202fc4d6d1df90512f1be8869f9bc..eb8423b55301550e1da28b2704a48737092991a8 100644 (file)
@@ -1,8 +1,8 @@
-function FluidbookDummySlideshow(fluidbook) {
+function FluidbookVacheronSlideshow(fluidbook) {
     this.fluidbook = fluidbook;
 }
 
-FluidbookDummySlideshow.prototype = {
+FluidbookVacheronSlideshow.prototype = {
     initSlideshow: function (id) {
     }
 };
diff --git a/style/slideshow/dummy.less b/style/slideshow/dummy.less
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/style/slideshow/vacheron.less b/style/slideshow/vacheron.less
new file mode 100644 (file)
index 0000000..e69de29