]> _ Git - fluidbook-html5.git/commitdiff
wait #4375 @2.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 29 Mar 2021 17:14:12 +0000 (19:14 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 29 Mar 2021 17:14:12 +0000 (19:14 +0200)
js/libs/fluidbook/fluidbook.contentlock.js
js/libs/fluidbook/special/mirakleaster2021.js [new file with mode: 0644]
style/special/mirakleaster2021.less [new file with mode: 0644]

index f91cca5ed2b487123dc1ebc59bcccb7e38dfafa9..c6f7d167423bc6fd2b69dc87ccb28a21470b9e03 100644 (file)
@@ -156,12 +156,13 @@ FluidbookContentLock.prototype = {
             if (unlockEvenPages && lockPage % 2 === 1) {
                 lockPage--;
             }
-            if (currentPage !== lockPage) {
+            if (currentPage < lockPage) {
                 return;
             }
+            console.log('unlock '+lockPage+'('+currentPage+')');
             $this.locks[k].unlocked = 1;
             change = true;
-            return true;
+
         });
 
         if (change) {
diff --git a/js/libs/fluidbook/special/mirakleaster2021.js b/js/libs/fluidbook/special/mirakleaster2021.js
new file mode 100644 (file)
index 0000000..dcb5584
--- /dev/null
@@ -0,0 +1,57 @@
+var MiraklEaster2021 = {
+    init: function () {
+        var $this = this;
+        $(document).on('click', '[data-answers]', function () {
+            var answers = $(this).data('answers').toString().toLowerCase().trim().split(';');
+            $.confirm({
+                escapeKey: true,
+                backgroundDismiss:true,
+                title: '',
+                content: '' +
+                    '<form action="" class="formName">' +
+                    '<div class="form-group">' +
+                    '<label>Your answer:</label>' +
+                    '<input type="text" value="" placeholder="" class="name form-control" required autofocus />' +
+                    '</div>' +
+                    '</form>',
+                buttons: {
+                    formSubmit: {
+                        text: 'OK',
+                        btnClass: 'btn-ok',
+                        action: function () {
+                            var c = this.$content.find('.name').val().toString().trim().toLowerCase();
+                            if (answers.indexOf(c) >= 0) {
+                                console.log(':)');
+                                fluidbook.contentlock.unlockCurrentPage();
+                                fluidbook.goNextPage();
+                            } else {
+                                console.log(':(');
+                                fluidbook.links.triggerLinkById('wrong');
+                            }
+                            return true;
+                        }
+                    },
+                    cancel: function () {
+                        return true;
+                        //close
+                    },
+                },
+                onContentReady: function () {
+                    // bind to events
+                    var jc = this;
+                    this.$content.find('form').on('submit', function (e) {
+                        // if the user submits the form by pressing enter in the field.
+                        e.preventDefault();
+                        jc.$$formSubmit.trigger('click'); // reference the button and click it
+                    });
+                }
+            });
+            return false;
+        });
+    }
+}
+
+$(function () {
+    $(document).on('fluidbook.init', MiraklEaster2021.init);
+});
+
diff --git a/style/special/mirakleaster2021.less b/style/special/mirakleaster2021.less
new file mode 100644 (file)
index 0000000..12cea3a
--- /dev/null
@@ -0,0 +1,44 @@
+@import url('https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@500&display=swap');
+
+.jconfirm .jconfirm-box {
+  .form-group {
+    label {
+      text-align: center;
+      font-size: 30px;
+      display: block;
+      color: #052b4c;
+      margin-bottom: 30px;
+    }
+
+    input {
+      color: #052b4c;
+      border-color: #052b4c;
+      font-size: 30px;
+      border-width: 2px;
+      padding:8px;
+    }
+  }
+
+  .jconfirm-buttons {
+    float: none !important;
+
+    .btn-default {
+      display: none;
+    }
+
+    button.btn-ok {
+      font-family: "Roboto Slab";
+      background-color: #3fa9f5;
+      height: 70px;
+      border-radius: 35px;
+      font-size: 30px;
+      width: 150px;
+      margin: 15px auto;
+      display: block;
+      font-weight: 500;
+      &:hover{
+        background-color: darken(#3fa9f5,10%);
+      }
+    }
+  }
+}