]> _ Git - fluidbook-toolbox-quiz.git/commitdiff
wip #6400 @0.75
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 11 Oct 2023 16:18:17 +0000 (18:18 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 11 Oct 2023 16:18:17 +0000 (18:18 +0200)
js/quiz.match.js

index cbc1689c7261ffcc4b43632da65f9b32a052c84f..59471e6e5198aea6585dfec8ce0d42fd89134ec3 100644 (file)
@@ -82,25 +82,25 @@ QuizMatch.prototype = {
         this.animateContent()
     },
 
-    animateContent: function() {
+    animateContent: function () {
         let slidesNext = this.swiperBottomEl.find(".swiper-slide-active").nextAll()
         let slidesPrev = this.swiperBottomEl.find(".swiper-slide-active").prevAll()
         let slideActive = this.swiperBottomEl.find(".swiper-slide-active")
         const rules = {
-            opacity: function(index) {
+            opacity: function (index) {
                 let opacity = 0
-                if(index === 0) {
+                if (index === 0) {
                     opacity = 0.8
-                }else if(index === 1) {
+                } else if (index === 1) {
                     opacity = 0.6
-                }else if(index === 2) {
+                } else if (index === 2) {
                     opacity = 0.4
                 }
                 return opacity
             },
             ease: "power1.inOut",
             stagger: .15,
-            onComplete: function() {
+            onComplete: function () {
                 $(this.target).removeClass("not-visible")
             }
         }
@@ -109,18 +109,18 @@ QuizMatch.prototype = {
         this.timeline.to(".active-screen .top-slider-container", {
             opacity: 1
         })
-        .to(".active-screen .bottom-slider", {
-            opacity: 1
-        })
-        .to(slideActive, {
-            opacity: 1
-        })
-        .to(slidesNext, {
-            ...rules
-        }, ">-0.5")
-        .to(slidesPrev, {
-            ...rules
-        }, "<")
+            .to(".active-screen .bottom-slider", {
+                opacity: 1
+            })
+            .to(slideActive, {
+                opacity: 1
+            })
+            .to(slidesNext, {
+                ...rules
+            }, ">-0.5")
+            .to(slidesPrev, {
+                ...rules
+            }, "<")
 
     },
 
@@ -151,7 +151,7 @@ QuizMatch.prototype = {
         $(slide).css({transform: 'rotate(' + angle + 'deg) translateY(' + top + 'px)'});
         if (this.timeline) {
             if (this.timeline.progress() > 0) {
-                $(slide).css('opacity',opacity)
+                $(slide).css('opacity', opacity)
             }
         }
     },
@@ -164,16 +164,20 @@ QuizMatch.prototype = {
         this.swiperBottom.update()
 
         if (this.swiperTop.activeIndex === lastIndex) {
-            this.switchMatchValidateButton()
+            this.validateAnswers()
             return false;
         }
 
-        this.swiperTop.slideNext()
+        this.swiperTop.slideNext();
     },
 
-    switchMatchValidateButton: function () {
-        let btn = $(".active-screen").find(".confirmMatch"), text = this.quiz.l10n.__('Validate answer');
-        btn.removeClass("confirmMatch").addClass("action validate").find('.text').text(text)
+    validateAnswers: function () {
+        let btn = $(".active-screen").find(".confirmMatch");
+        btn.removeClass("confirmMatch").addClass("action validate");
+        setTimeout(function () {
+            $(".active-screen").find(".validate").get(0).click();
+        }, 100);
+
     },
 
     reset: function () {