]> _ Git - fluidbook-html5.git/commitdiff
wip #4102 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 30 Nov 2020 15:40:20 +0000 (16:40 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 30 Nov 2020 15:40:20 +0000 (16:40 +0100)
js/libs/fluidbook/fluidbook.links.js

index 690b3f3a54aabfc533817cb8a76c0842d9106e0d..970f857683f0e2837afbbb5c0af057d8f74b91bd 100644 (file)
@@ -187,6 +187,11 @@ FluidbookLinks.prototype = {
             return false;
         });
 
+        $(document).on('click touchend', 'a.triggerlink[data-trigger-event="click"]', function () {
+            $this.triggerLinkById($(this).data('trigger-id'));
+            return false;
+        });
+
         $(document).on('click touchend', '[data-action]', function () {
             var map = {'pdf': 'print', 'fullScreen': "fullscreen", 'locales': 'localesContainers', 'basket': 'cart'};
             var action = $(this).data('action');
@@ -384,11 +389,17 @@ FluidbookLinks.prototype = {
         var $this = this;
 
         $(".contentLink[data-animations]").each(function () {
-            $this.animateContentLink($(this));
+            $this.animateContentLink($(this), true);
         });
     },
 
-    animateContentLink: function (link) {
+    animateContentLink: function (link, autostart) {
+        if ($(link).data('animation-started') === true) {
+            return;
+        }
+        if (autostart === undefined) {
+            autostart = false;
+        }
         var animations = $(link).data('animations');
         var $this = this;
 
@@ -398,6 +409,16 @@ FluidbookLinks.prototype = {
         if (animations.length === 0) {
             return;
         }
+        if (animations[0]["autostart"] === undefined) {
+            animations[0]["autostart"] = true;
+        }
+        if (animations[0]['autostart'] == '0' || animations[0]['autostart'] == 'false') {
+            animations[0]['autostart'] = false;
+        }
+
+        if (autostart && !animations[0]['autostart']) {
+            return;
+        }
 
         $.each(defaults, function (k, v) {
             if (animations[0][v] !== undefined) {
@@ -405,6 +426,8 @@ FluidbookLinks.prototype = {
             }
         });
 
+        $(link).data('animation-started', true);
+
         $.each(animations, function (k, animation) {
             $this.executeAnimation(link, $.extend({}, firstDefaults, animation));
         });
@@ -735,8 +758,14 @@ FluidbookLinks.prototype = {
     },
 
     triggerLinkById: function (id) {
-        var a = $('.link[data-id="' + id + '"] a:eq(0)');
-        a.get(0).click();
+        var link = $('.link[data-id="' + id + '"]');
+
+        if ($(link).is('[data-animations]')) {
+            this.animateContentLink($(link), false);
+        } else {
+            var a = $(link).find('a:eq(0)');
+            a.get(0).click();
+        }
     },
 
     initInlineSlideshows: function () {