$(document).ready(function(){ /** ----------------------------------------- /** Volunteer Board /** -----------------------------------------*/ // Expand opportunity description $(".serving-op:not(.single)").click(function(event){ $(this).siblings().children(".op-desc").slideUp("fast"); $(this).children(".op-desc").slideToggle("normal"); }); // Click Serve, Open Signup Modal $(".op-links a").click(function (){ if ($(this).parents(".serving-op").hasClass('filled')){ return false; } var $opID = $(this).attr("id"); $("#opID").val($opID); var $opTitle = $(this).parent().siblings(".op-title").html(); $("#opTitle").val($opTitle); var $opDesc = $(this).parent().siblings(".op-desc").html(); $("#opDesc").val($opDesc); $filledObj = $(this).parents(".serving-op").children(".op-stats").children(".op-filled"); $("#op-card h3").html($opTitle); $("#op-card").css("display","block"); $("#overlay").css("display","block"); $("#op-card").animate({ opacity: 1 }, 400); $("#overlay").animate({ opacity: 0.5 }, 400 ); return false; }); // Show and Animate Modal, Seperate function for timing purposes $("#overlay, #clear").click(function (){ //alert($("#opID").val()); $("#op-card").animate({ opacity: 0, }, 250 ); $("#overlay").animate({ opacity: 0 }, 250,'linear',hideModals ); // $filledObj.css("background","yellow"); // window.setTimeout("serveIncrement()",2000); }); // Send opportunity form data over ajax, return values, animate change $("form#op-form").submit(function() { if ($('#name').val() == '' || $('#email').val() == '' || $('#phone').val() == '') { alert('All fields are required. Please complete the form before submitting.'); return false; } else { $.post("/serve/submit", { name: $("#name").val(), email: $("#email").val(), phone: $("#phone").val(), opID: $("#opID").val(), opTitle: $("#opTitle").val(), opDesc: $("#opDesc").val() }, function(data) { $('#op-card').html(data); $("#clear").unbind("click").bind("click", function(){ $("#op-card").animate({ opacity: 0, }, 250 ); $("#overlay").animate({ opacity: 0 }, 250,'linear',hideModals ); $filledObj.css("background","yellow"); window.setTimeout("serveIncrement()",2000); $('#op-card').load("/serve/opcard"); }); }); return false; } }); // Send small groups info request over ajax $("form#form-smallgroups").submit(function() { if ($('#name').val() == 'name' || $('#email').val() == 'email' || $('#name').val() == '') { alert('All fields are required. Please complete the form before submitting.'); return false; } else { $.post("/smallgroups/submit", { name: $("#name").val(), email: $("#email").val(), phone: $("#phone").val(), type: $("#type").val(), comments: $("#comments").val() }, function(data) {$('#form-smallgroups').html(data);}); return false; } }); });