From fa782167af747ded42dd1278441035e0be0c36ea Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Mon, 13 Mar 2017 18:05:57 -0700 Subject: show RSVP field when replying to events closes #71 --- views/new-post.php | 59 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 16 deletions(-) (limited to 'views') diff --git a/views/new-post.php b/views/new-post.php index ab98097..6e6eb0f 100644 --- a/views/new-post.php +++ b/views/new-post.php @@ -25,6 +25,17 @@ Reply + +
140
@@ -544,25 +555,37 @@ $(function(){ $("#note_content").val(mentions); } - $(".reply-context .content").text(data.entry.content.text); - if(data.entry.name) { - $(".reply-context .post-name").text(data.entry.name).removeClass('hidden'); - } else { - $(".reply-context .post-name").addClass('hidden'); - } - if(data.entry.author) { - $(".reply-context .author .name").text(data.entry.author.name); - $(".reply-context .author .url").text(data.entry.author.url); - $(".reply-context img.author-img").attr('src', data.entry.author.photo); - } - if(data.entry.photo) { - $(".reply-context img.post-img").attr('src', data.entry.photo[0]).removeClass('hidden'); - } else { - $(".reply-context img.post-img").addClass('hidden'); + if(data.entry) { + $(".reply-context .content").text(data.entry.content.text); + if(data.entry.name) { + $(".reply-context .post-name").text(data.entry.name).removeClass('hidden'); + } else { + $(".reply-context .post-name").addClass('hidden'); + } + if(data.entry.author) { + $(".reply-context .author .name").text(data.entry.author.name); + $(".reply-context .author .url").text(data.entry.author.url); + $(".reply-context img.author-img").attr('src', data.entry.author.photo); + $(".reply-context .reply-author").removeClass("hidden"); + } else { + $(".reply-context .reply-author").addClass("hidden"); + } + if(data.entry.photo) { + $(".reply-context img.post-img").attr('src', data.entry.photo[0]).removeClass('hidden'); + } else { + $(".reply-context img.post-img").addClass('hidden'); + } + if(data.entry.type == "event") { + $("#form_rsvp").removeClass("hidden"); + } else { + $("#form_rsvp").addClass("hidden"); + } + + $(".reply-context").removeClass("hidden"); } $(".reply-section .loading").addClass("hidden"); - $(".reply-context").removeClass("hidden"); + }); }); @@ -624,6 +647,10 @@ $(function(){ formData.append("user->micropub_slug_field ?>", v); entry["user->micropub_slug_field ?>"] = v; } + if(!$("#form_rsvp").hasClass("hidden") && $("#note_rsvp").val()) { + formData.append("rsvp", $("#note_rsvp").val()); + entry["rsvp"] = $("#note_rsvp").val(); + } function appendPhotoToFormData(photo, prop) { if(photo.external) { -- cgit v1.2.3