(Un)subscribe AJAX forms

This commit is contained in:
sarven 2009-01-21 04:08:05 +00:00
parent 21eecc5d89
commit db4993970e
3 changed files with 18 additions and 16 deletions

View File

@ -64,12 +64,13 @@ class SubscribeAction extends Action
} }
if ($this->boolean('ajax')) { if ($this->boolean('ajax')) {
common_start_html('text/xml;charset=utf-8', true); $this->startHTML('text/xml;charset=utf-8', true);
$this->elementStart('head'); $this->elementStart('head');
$this->element('title', null, _('Subscribed')); $this->element('title', null, _('Subscribed'));
$this->elementEnd('head'); $this->elementEnd('head');
$this->elementStart('body'); $this->elementStart('body');
common_unsubscribe_form($other->getProfile()); $unsubscribe = new UnsubscribeForm($this, $other->getProfile());
$unsubscribe->show();
$this->elementEnd('body'); $this->elementEnd('body');
$this->elementEnd('html'); $this->elementEnd('html');
} else { } else {

View File

@ -66,12 +66,13 @@ class UnsubscribeAction extends Action
} }
if ($this->boolean('ajax')) { if ($this->boolean('ajax')) {
common_start_html('text/xml;charset=utf-8', true); $this->startHTML('text/xml;charset=utf-8', true);
$this->elementStart('head'); $this->elementStart('head');
$this->element('title', null, _('Unsubscribed')); $this->element('title', null, _('Unsubscribed'));
$this->elementEnd('head'); $this->elementEnd('head');
$this->elementStart('body'); $this->elementStart('body');
common_subscribe_form($other); $subscribe = new SubscribeForm($this, $other);
$subscribe->show();
$this->elementEnd('body'); $this->elementEnd('body');
$this->elementEnd('html'); $this->elementEnd('html');
} else { } else {

View File

@ -98,8 +98,8 @@ $(document).ready(function(){
$("#nudge").each(addAjaxHidden); $("#nudge").each(addAjaxHidden);
var Subscribe = { dataType: 'xml', var Subscribe = { dataType: 'xml',
beforeSubmit: function(formData, jqForm, options) { $("form.subscribe input[type=submit]").attr("disabled", "disabled"); beforeSubmit: function(formData, jqForm, options) { $(".form_user_subscribe input[type=submit]").attr("disabled", "disabled");
$("form.subscribe input[type=submit]").addClass("disabled"); $(".form_user_subscribe input[type=submit]").addClass("disabled");
}, },
success: function(xml) { var form_unsubscribe = document._importNode($('form', xml).get(0), true); success: function(xml) { var form_unsubscribe = document._importNode($('form', xml).get(0), true);
var form_unsubscribe_id = form_unsubscribe.id; var form_unsubscribe_id = form_unsubscribe.id;
@ -107,14 +107,14 @@ $(document).ready(function(){
$("form#"+form_subscribe_id).replaceWith(form_unsubscribe); $("form#"+form_subscribe_id).replaceWith(form_unsubscribe);
$("form#"+form_unsubscribe_id).ajaxForm(UnSubscribe).each(addAjaxHidden); $("form#"+form_unsubscribe_id).ajaxForm(UnSubscribe).each(addAjaxHidden);
$("dd.subscribers").text(parseInt($("dd.subscribers").text())+1); $("dd.subscribers").text(parseInt($("dd.subscribers").text())+1);
$("form.subscribe input[type=submit]").removeAttr("disabled"); $(".form_user_subscribe input[type=submit]").removeAttr("disabled");
$("form.subscribe input[type=submit]").removeClass("disabled"); $(".form_user_subscribe input[type=submit]").removeClass("disabled");
} }
}; };
var UnSubscribe = { dataType: 'xml', var UnSubscribe = { dataType: 'xml',
beforeSubmit: function(formData, jqForm, options) { $("form.unsubscribe input[type=submit]").attr("disabled", "disabled"); beforeSubmit: function(formData, jqForm, options) { $(".form_user_unsubscribe input[type=submit]").attr("disabled", "disabled");
$("form.unsubscribe input[type=submit]").addClass("disabled"); $(".form_user_unsubscribe input[type=submit]").addClass("disabled");
}, },
success: function(xml) { var form_subscribe = document._importNode($('form', xml).get(0), true); success: function(xml) { var form_subscribe = document._importNode($('form', xml).get(0), true);
var form_subscribe_id = form_subscribe.id; var form_subscribe_id = form_subscribe.id;
@ -124,15 +124,15 @@ $(document).ready(function(){
$("#profile_send_a_new_message").remove(); $("#profile_send_a_new_message").remove();
$("#profile_nudge").remove(); $("#profile_nudge").remove();
$("dd.subscribers").text(parseInt($("dd.subscribers").text())-1); $("dd.subscribers").text(parseInt($("dd.subscribers").text())-1);
$("form.unsubscribe input[type=submit]").removeAttr("disabled"); $(".form_user_unsubscribe input[type=submit]").removeAttr("disabled");
$("form.unsubscribe input[type=submit]").removeClass("disabled"); $(".form_user_unsubscribe input[type=submit]").removeClass("disabled");
} }
}; };
$("form.subscribe").ajaxForm(Subscribe); $(".form_user_subscribe").ajaxForm(Subscribe);
$("form.unsubscribe").ajaxForm(UnSubscribe); $(".form_user_unsubscribe").ajaxForm(UnSubscribe);
$("form.subscribe").each(addAjaxHidden); $(".form_user_subscribe").each(addAjaxHidden);
$("form.unsubscribe").each(addAjaxHidden); $(".form_user_unsubscribe").each(addAjaxHidden);
var PostNotice = { dataType: 'xml', var PostNotice = { dataType: 'xml',