We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 90f1cfcf authored by Brion Vibber's avatar Brion Vibber

Poll plugin: make the polling response form submit via AJAX and return the results.

Now, any form marked with 'ajax' class will get the simple FormXHR treatment. Should help cut down on code that just adds that into individual forms.
parent ba1ada28
......@@ -1380,6 +1380,16 @@ var SN = { // StatusNet
});
},
/**
* Set up any generic 'ajax' form so it submits via AJAX with auto-replacement.
*/
AjaxForms: function() {
$('form.ajax').live('submit', function() {
SN.U.FormXHR($(this));
return false;
});
},
/**
* Add logic to any file upload forms to handle file size limits,
* on browsers that support basic FileAPI.
......@@ -1416,6 +1426,7 @@ var SN = { // StatusNet
* don't start them loading until after DOM-ready time!
*/
$(document).ready(function(){
SN.Init.AjaxForms();
SN.Init.UploadForms();
if ($('.'+SN.C.S.FormNotice).length > 0) {
SN.Init.NoticeForm();
......
This diff is collapsed.
......@@ -83,7 +83,7 @@ class PollResponseForm extends Form
function formClass()
{
return 'form_settings';
return 'form_settings ajax';
}
/**
......
......@@ -83,7 +83,7 @@ class PollResultForm extends Form
function formClass()
{
return 'form_settings';
return 'form_settings ajax';
}
/**
......
......@@ -145,7 +145,22 @@ class RespondPollAction extends Action
return;
}
common_redirect($this->poll->bestUrl(), 303);
if ($this->arg('ajax')) {
header('Content-Type: text/xml;charset=utf-8');
$this->xw->startDocument('1.0', 'UTF-8');
$this->elementStart('html');
$this->elementStart('head');
// TRANS: Page title after sending a poll response.
$this->element('title', null, _m('Poll results'));
$this->elementEnd('head');
$this->elementStart('body');
$form = new PollResultForm($this->poll, $this);
$form->show();
$this->elementEnd('body');
$this->elementEnd('html');
} else {
common_redirect($this->poll->bestUrl(), 303);
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment