summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorcsarven <csarven@controlyourself.ca>2008-11-20 18:26:55 -0500
committercsarven <csarven@controlyourself.ca>2008-11-20 18:26:55 -0500
commit171bedf24bca7bd195dd4a8ee79cb3f04e6de5d5 (patch)
treec4b84cffe4fcd70e7906d18cab288cc221e1019a /js
parent41f29ab662a5587b1505303ff6d39efb4b6b77c9 (diff)
(Un)Subscribe form using ajaxForm()
darcs-hash:20081120232655-eefa4-cf6a71e246828793d3bfa413db724ab33bc58bcf.gz
Diffstat (limited to 'js')
-rw-r--r--js/util.js30
1 files changed, 29 insertions, 1 deletions
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) {