1$(document).ready(function() { 2 $('#submitEvent').on('click', function() { 3 get_form(); 4 }); 5 6}); 7 8function create_post() { 9 $.ajax({ 10 url : "/calendar/ajax/submit-my-event/", // the endpoint 11 type : "POST", // http method 12 data : $('#submit-my-event-form').serialize(), // data sent with the post request 13 14 // handle a successful response 15 success : function(returned_html) { 16 $('#submit-my-event-form .modal-body').html(returned_html); // add the error to the dom 17 }, 18 19 // handle a non-successful response 20 error : function(xhr,errmsg,err) { 21 $('#submit-my-event-form .modal-body').html("<div class='alert-box alert radius' data-alert>Oops! We have encountered an error. Please email your event information to: [email protected] </div>"); // add the error to the dom 22 }, 23 24 complete : function (returned_html) { 25 $('button#submit-my-event-data').hide(); 26 } 27 }); 28} 29 30function get_form() { 31 $.ajax({ 32 url : "/calendar/ajax/submit-my-event/", 33 type : "GET", 34 dataType : 'html', 35 success : function(returned_html) { 36 $('#submit-event-modal-wrapper').html(returned_html); 37 $('#submit-event-form').modal('show'); 38 initSubmitListener(); 39 $(".mask-phone").mask("(999) 999-9999"); 40 $.datetimepicker.setLocale('en'); 41 $('.date-time-picker').datetimepicker({ 42 format: 'm/d/Y g:i A', 43 formatTime:'g:i A', 44 step: 15, 45 minDate: 0 46 }); 47 } 48 }); 49} 50 51function initSubmitListener() { 52 $('#submit-my-event-form').unbind('submit').bind('submit',function() { 53 event.preventDefault(); 54 var title = $('#id_title'), 55 name = $('#id_submitted_by_name'), 56 email = $('#id_submitted_by_email'), 57 phone = $('#id_submitted_by_phone'), 58 errors = '', 59 errorContainer = $('.empty-error-container'); 60 61 if(!title.val() || !name.val()) { 62 if (!title.val()) { 63 errors += '<p>Title is required.</p>'; 64 } 65 if (!name.val()) { 66 errors += '<p>Your name is required.</p>'; 67 } 68 69 if(!email.val() && !phone.val()) { 70 errors += '<p>An email address or phone number is required.</p>'; 71 } 72 73 $(errorContainer).html('<div class="error-container">' + errors + '</div><br/>'); 74 75 return false; 76 } else if(!email.val() && !phone.val()) { 77 errors += '<p>An email address or phone number is required.</p>'; 78 $(errorContainer).html('<div class="error-container">' + errors + '</div><br/>'); 79 return false; 80 } 81 else { 82 create_post(); 83 } 84 }); 85}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.