]> _ Git - fluidbook-html5.git/commitdiff
wip #2227 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 4 Oct 2018 12:47:30 +0000 (14:47 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 4 Oct 2018 12:47:30 +0000 (14:47 +0200)
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.scorm.js
js/libs/scorm/scorm.js
js/main.js

index 74b34d843ea10bdf1fc7a5f45f22db519f7b2cf5..48e01b94e9f31e70e0a5500fcb07c1a9d527ea3b 100644 (file)
@@ -33,9 +33,7 @@ Fluidbook.prototype = {
         this.loader = new FluidbookLoader(this);
         this.search = new FluidbookSearch(this);
         this.pad = new FluidbookPad(this);
-        if (this.datas.scorm_enable) {
-            this.scorm = new FluidbookScorm(this);
-        }
+        this.scorm = new FluidbookScorm(this);
         this.links = new FluidbookLinks(this);
         this.waiters = [];
         this.viewport = new FluidbookViewport(this);
index ac47b9bb2f57baa6989b5d9e2a115ebda50ca322..b32b9e130eca9ad8c48bb085fbee558c40725425 100644 (file)
@@ -21,6 +21,22 @@ FluidbookScorm.prototype = {
             }
             return true;
         });
+
+        console.log('init scorm');
+
+        $(this.fluidbook).on('fluidbook.links.ready', function () {
+            $this.hideScormLinks();
+        });
+    },
+
+    hideScormLinks: function () {
+        console.log('hide scorm links');
+        if (this.isActive()) {
+            console.log('scorm is active');
+            return;
+        }
+
+        $('.link[data-scorm="1"]').hide();
     },
 
     completeLink: function (id) {
@@ -34,6 +50,20 @@ FluidbookScorm.prototype = {
         return (this.linksToComplete.length == 0);
     },
 
+    isActive: function () {
+        if (!this.fluidbook.datas.scorm_enable) {
+            console.log('scorm not enabled (settings)');
+            return false;
+        }
+        if (undefined !== window.FORCE_SCORM
+               && window.FORCE_SCORM) {
+            console.log('scorm forced');
+            return true;
+        }
+        console.log('scorm api : ', pipwerks.SCORM.API.isFound);
+        return pipwerks.SCORM.API.isFound;
+    },
+
     openLinkIfCompleteOrDisplayImage: function (openLink, openImage) {
         var $this = this;
         var id = this.linksCompleted() ? openLink : openImage;
@@ -43,6 +73,7 @@ FluidbookScorm.prototype = {
         $.each(id, function (k, v) {
             $this.fluidbook.links.triggerLinkById(v);
         });
-
     },
+
+
 };
\ No newline at end of file
index 95af14efa9a8f229f383cd8cf150a61bfc19f8fa..6076d1da99a47bb87fe96e895ad80b9aa8a3ded2 100644 (file)
@@ -68,7 +68,7 @@ function initScormEvents() {
         finishScorm();
     });
 
-    $(fluidbook).on('fluidbook.splash.hide',function(){
+    $(fluidbook).on('fluidbook.splash.hide', function () {
         console.log('init scorm events');
         var currentLocation = getScormValue('location');
         try {
@@ -100,7 +100,6 @@ function initScormEvents() {
     });
 
 
-
     // Commit data once a minute
     setInterval(function () {
         pipwerks.SCORM.save();
index bf85ffe53809ce18c187b0a5ac84c8047ec6fd38..b4b9e2aa084c35f166479f6c8e5b23e461448042 100644 (file)
@@ -388,16 +388,16 @@ try {
             resize();
         }, 1000);
 
-        fluidbook.onReady(function() {
+        fluidbook.onReady(function () {
             if (!startAfterLoading) {
                 fluidbook.changeAddress();
             }
         });
 
         //console.log('fluidbook.ready');
-      setTimeout(function(){
-          fluidbook.ready();
-      }, 3000);
+        setTimeout(function () {
+            fluidbook.ready();
+        }, 3000);
     }
 } catch (err) {
     console.log(err);