From 171bedf24bca7bd195dd4a8ee79cb3f04e6de5d5 Mon Sep 17 00:00:00 2001 From: csarven Date: Thu, 20 Nov 2008 18:26:55 -0500 Subject: (Un)Subscribe form using ajaxForm() darcs-hash:20081120232655-eefa4-cf6a71e246828793d3bfa413db724ab33bc58bcf.gz --- js/util.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/util.js b/js/util.js index 53fc58011..b3165647f 100644 --- a/js/util.js +++ b/js/util.js @@ -90,7 +90,35 @@ $(document).ready(function(){ success: function(xml) { $("#nudge").replaceWith(document._importNode($("#nudge_response", xml).get(0),true)); } }); $("#nudge").each(addAjaxHidden); - $("#nudge .submit").bind('click', function(e) { $(this).addClass("processing"); }); + $("#nudge .submit").bind('click', function(e) { $(this).addClass("processing"); }); + + + var Subscribe = { dataType: 'xml', + success: function(xml) { var form_unsubscribe = document._importNode($('form', xml).get(0), true); + var form_unsubscribe_id = form_unsubscribe.id; + var form_subscribe_id = form_unsubscribe_id.replace('unsubscribe', 'subscribe'); + $("form#"+form_subscribe_id).replaceWith(form_unsubscribe); + $("form#"+form_unsubscribe_id).ajaxForm(UnSubscribe).each(addAjaxHidden); + $("#profile_actions").append(document._importNode($('#profile_send_a_new_message', xml).get(0), true)); + $("#profile_actions").append(document._importNode($('#profile_nudge', xml).get(0), true)); + } + }; + + var UnSubscribe = { dataType: 'xml', + success: function(xml) { var form_subscribe = document._importNode($('form', xml).get(0), true); + var form_subscribe_id = form_subscribe.id; + var form_unsubscribe_id = form_subscribe_id.replace('subscribe', 'unsubscribe'); + $("form#"+form_unsubscribe_id).replaceWith(form_subscribe); + $("form#"+form_subscribe_id).ajaxForm(Subscribe).each(addAjaxHidden); + $("#profile_send_a_new_message").remove(); + $("#profile_nudge").remove(); + } + }; + + $("form.subscribe").ajaxForm(Subscribe); + $("form.unsubscribe").ajaxForm(UnSubscribe); + $("form.subscribe").each(addAjaxHidden); + $("form.unsubscribe").each(addAjaxHidden); }); function doreply(nick,id) { -- cgit v1.2.3-54-g00ecf