From: Vincent Vanwaelscappel Date: Mon, 30 Nov 2020 15:40:20 +0000 (+0100) Subject: wip #4102 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=a185cee11f37c81bc0a91e2565f47fb0f40752e3;p=fluidbook-html5.git wip #4102 @2 --- diff --git a/js/libs/fluidbook/fluidbook.links.js b/js/libs/fluidbook/fluidbook.links.js index 690b3f3a..970f8576 100644 --- a/js/libs/fluidbook/fluidbook.links.js +++ b/js/libs/fluidbook/fluidbook.links.js @@ -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 () {