From 2d62359adf671d5a75201a2314825039adc7291a Mon Sep 17 00:00:00 2001 From: adityacp Date: Mon, 15 May 2017 15:03:21 +0530 Subject: Change course.js and course_detail.html - Allow moderator to send emails to students enrollded in a course - Add validations to check email data in course.js --- yaksh/static/yaksh/js/course.js | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'yaksh/static') diff --git a/yaksh/static/yaksh/js/course.js b/yaksh/static/yaksh/js/course.js index 5b79e68..3e214be 100644 --- a/yaksh/static/yaksh/js/course.js +++ b/yaksh/static/yaksh/js/course.js @@ -35,4 +35,49 @@ $(".reject").change( function(){ }); } }); + +$(function() { + $('textarea#email_body').froalaEditor({ + heightMin: 100, + heightMax: 200 + }) + }); + +var status; +var btn_name; + +$("#send_mail").click(function(){ + btn_name = "send_mail"; + var subject = $("#subject").val(); + var body = $('#email_body').val(); + if (subject == '' || body == ''){ + status = false; + $("#error_msg").html("Please enter email details"); + $("#dialog").dialog(); + } + else{ + status = true; + } +}); + +$('#reject-form').submit(function(eventObj) { + if (btn_name == 'send_mail'){ + if(status == false){ + return false; + } + } + var selected = []; + $('#reject input:checked').each(function() { + selected.push($(this).attr('value')); + }); + if(selected.length > 0){ + return true; + } + else{ + $("#error_msg").html("Please select atleast one user"); + $( "#dialog" ).dialog(); + return false; + } +}); + }); -- cgit