diff js/core.js @ 3063:6b95437ae672

Close #109
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Tue, 31 Oct 2017 16:21:58 +0000
parents 01ca365f350d
children a504a17dcf9f
line wrap: on
line diff
--- a/js/core.js	Tue Oct 31 15:55:07 2017 +0000
+++ b/js/core.js	Tue Oct 31 16:21:58 2017 +0000
@@ -2711,6 +2711,12 @@
             this.textArea.style.width = boxwidth - 6 + "px";
         };
         this.resize();
+        this.check = function () {
+            if (this.specification.mandatory && this.textArea.value.length == 0) {
+                return false;
+            }
+            return true;
+        }
     };
 
     this.radioBox = function (commentQuestion) {
@@ -2785,6 +2791,15 @@
             }
             this.holder.style.width = boxwidth + "px";
         };
+        this.check = function () {
+            var anyChecked = this.options.some(function (a) {
+                return a.checked;
+            });
+            if (this.specification.mandatory && anyChecked == false) {
+                return false;
+            }
+            return true;
+        }
         this.resize();
     };
 
@@ -2851,6 +2866,15 @@
             }
             this.holder.style.width = boxwidth + "px";
         };
+        this.check = function () {
+            var anyChecked = this.options.some(function (a) {
+                return a.checked;
+            });
+            if (this.specification.mandatory && anyChecked == false) {
+                return false;
+            }
+            return true;
+        };
         this.resize();
     };
 
@@ -2908,6 +2932,9 @@
             this.holder.style.width = boxwidth + "px";
             this.slider.style.width = boxwidth - 24 + "px";
         };
+        this.check = function () {
+            return true;
+        }
         this.resize();
     };
 
@@ -2930,6 +2957,19 @@
         this.commentQuestions = [];
     };
 
+    this.checkCommentQuestions = function () {
+        var errored = this.commentQuestions.reduce(function (a, cq) {
+            if (cq.check() == false) {
+                a.push(cq);
+            }
+            return a;
+        }, []);
+        if (errored.length == 0) {
+            return true;
+        }
+        interfaceContext.lightbox.post("Message", "Not all the mandatory comment boxes below have been filled.");
+    }
+
     this.outsideReferenceDOM = function (audioObject, index, inject) {
         this.parent = audioObject;
         this.outsideReferenceHolder = document.createElement('button');