comparison 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
comparison
equal deleted inserted replaced
3062:e441e3d5c7e7 3063:6b95437ae672
2709 } 2709 }
2710 this.holder.style.width = boxwidth + "px"; 2710 this.holder.style.width = boxwidth + "px";
2711 this.textArea.style.width = boxwidth - 6 + "px"; 2711 this.textArea.style.width = boxwidth - 6 + "px";
2712 }; 2712 };
2713 this.resize(); 2713 this.resize();
2714 this.check = function () {
2715 if (this.specification.mandatory && this.textArea.value.length == 0) {
2716 return false;
2717 }
2718 return true;
2719 }
2714 }; 2720 };
2715 2721
2716 this.radioBox = function (commentQuestion) { 2722 this.radioBox = function (commentQuestion) {
2717 this.specification = commentQuestion; 2723 this.specification = commentQuestion;
2718 // Create document objects to hold the comment boxes 2724 // Create document objects to hold the comment boxes
2783 } else if (boxwidth < 400) { 2789 } else if (boxwidth < 400) {
2784 boxwidth = 400; 2790 boxwidth = 400;
2785 } 2791 }
2786 this.holder.style.width = boxwidth + "px"; 2792 this.holder.style.width = boxwidth + "px";
2787 }; 2793 };
2794 this.check = function () {
2795 var anyChecked = this.options.some(function (a) {
2796 return a.checked;
2797 });
2798 if (this.specification.mandatory && anyChecked == false) {
2799 return false;
2800 }
2801 return true;
2802 }
2788 this.resize(); 2803 this.resize();
2789 }; 2804 };
2790 2805
2791 this.checkboxBox = function (commentQuestion) { 2806 this.checkboxBox = function (commentQuestion) {
2792 this.specification = commentQuestion; 2807 this.specification = commentQuestion;
2849 } else if (boxwidth < 400) { 2864 } else if (boxwidth < 400) {
2850 boxwidth = 400; 2865 boxwidth = 400;
2851 } 2866 }
2852 this.holder.style.width = boxwidth + "px"; 2867 this.holder.style.width = boxwidth + "px";
2853 }; 2868 };
2869 this.check = function () {
2870 var anyChecked = this.options.some(function (a) {
2871 return a.checked;
2872 });
2873 if (this.specification.mandatory && anyChecked == false) {
2874 return false;
2875 }
2876 return true;
2877 };
2854 this.resize(); 2878 this.resize();
2855 }; 2879 };
2856 2880
2857 this.sliderBox = function (commentQuestion) { 2881 this.sliderBox = function (commentQuestion) {
2858 this.specification = commentQuestion; 2882 this.specification = commentQuestion;
2906 boxwidth = 400; 2930 boxwidth = 400;
2907 } 2931 }
2908 this.holder.style.width = boxwidth + "px"; 2932 this.holder.style.width = boxwidth + "px";
2909 this.slider.style.width = boxwidth - 24 + "px"; 2933 this.slider.style.width = boxwidth - 24 + "px";
2910 }; 2934 };
2935 this.check = function () {
2936 return true;
2937 }
2911 this.resize(); 2938 this.resize();
2912 }; 2939 };
2913 2940
2914 this.createCommentQuestion = function (element) { 2941 this.createCommentQuestion = function (element) {
2915 var node; 2942 var node;
2927 }; 2954 };
2928 2955
2929 this.deleteCommentQuestions = function () { 2956 this.deleteCommentQuestions = function () {
2930 this.commentQuestions = []; 2957 this.commentQuestions = [];
2931 }; 2958 };
2959
2960 this.checkCommentQuestions = function () {
2961 var errored = this.commentQuestions.reduce(function (a, cq) {
2962 if (cq.check() == false) {
2963 a.push(cq);
2964 }
2965 return a;
2966 }, []);
2967 if (errored.length == 0) {
2968 return true;
2969 }
2970 interfaceContext.lightbox.post("Message", "Not all the mandatory comment boxes below have been filled.");
2971 }
2932 2972
2933 this.outsideReferenceDOM = function (audioObject, index, inject) { 2973 this.outsideReferenceDOM = function (audioObject, index, inject) {
2934 this.parent = audioObject; 2974 this.parent = audioObject;
2935 this.outsideReferenceHolder = document.createElement('button'); 2975 this.outsideReferenceHolder = document.createElement('button');
2936 this.outsideReferenceHolder.className = 'outside-reference'; 2976 this.outsideReferenceHolder.className = 'outside-reference';