Merge branch '1.0.x' into profile-fixups

This commit is contained in:
Zach Copley 2011-03-08 14:10:06 -08:00
commit 3bbe481695
15 changed files with 48 additions and 46 deletions

View File

@ -228,6 +228,9 @@ var SN = { // StatusNet
* will be extracted and copied in, replacing the original form.
* If there's no form, the first paragraph will be used.
*
* This will automatically be applied on the 'submit' event for
* any form with the 'ajax' class.
*
* @fixme can sometimes explode confusingly if returnd data is bogus
* @fixme error handling is pretty vague
* @fixme can't submit file uploads
@ -633,17 +636,6 @@ var SN = { // StatusNet
}
},
/**
* Setup function -- DOES NOT apply immediately.
*
* Sets up event handlers for favor/disfavor forms to submit via XHR.
* Uses 'live' rather than 'bind', so applies to future as well as present items.
*/
NoticeFavor: function() {
$('.form_favor').live('click', function() { SN.U.FormXHR($(this)); return false; });
$('.form_disfavor').live('click', function() { SN.U.FormXHR($(this)); return false; });
},
NoticeInlineReplyPlaceholder: function(notice) {
var list = notice.find('ul.threaded-replies');
var placeholder = $('<li class="notice-reply-placeholder">' +
@ -1331,7 +1323,6 @@ var SN = { // StatusNet
if (masterForm.length > 0) {
SN.C.I.NoticeFormMaster = document._importNode(masterForm[0], true);
}
SN.U.NoticeFavor();
SN.U.NoticeRepeat();
SN.U.NoticeReply();
SN.U.NoticeInlineReplySetup();
@ -1348,12 +1339,6 @@ var SN = { // StatusNet
*/
EntityActions: function() {
if ($('body.user_in').length > 0) {
$('.form_user_subscribe').live('click', function() { SN.U.FormXHR($(this)); return false; });
$('.form_user_unsubscribe').live('click', function() { SN.U.FormXHR($(this)); return false; });
$('.form_group_join').live('click', function() { SN.U.FormXHR($(this)); return false; });
$('.form_group_leave').live('click', function() { SN.U.FormXHR($(this)); return false; });
$('.form_user_nudge').live('click', function() { SN.U.FormXHR($(this)); return false; });
SN.U.NewDirectMessage();
}
},
@ -1380,6 +1365,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 +1411,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();

2
js/util.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -147,6 +147,6 @@ class DisfavorForm extends Form
*/
function formClass()
{
return 'form_disfavor';
return 'form_disfavor ajax';
}
}

View File

@ -146,6 +146,6 @@ class FavorForm extends Form
*/
function formClass()
{
return 'form_favor';
return 'form_favor ajax';
}
}

View File

@ -172,7 +172,13 @@ class Form extends Widget
}
/**
* Class of the form.
* Class of the form. May include space-separated list of multiple classes.
*
* If 'ajax' is included, the form will automatically be submitted with
* an 'ajax=1' parameter added, and the resulting form or error message
* will replace the form after submission.
*
* It's up to you to make sure that the target action supports this!
*
* @return string the form's class
*/

View File

@ -88,7 +88,7 @@ class JoinForm extends Form
function formClass()
{
return 'form_group_join';
return 'form_group_join ajax';
}
/**

View File

@ -88,7 +88,7 @@ class LeaveForm extends Form
function formClass()
{
return 'form_group_leave';
return 'form_group_leave ajax';
}
/**

View File

@ -89,7 +89,7 @@ class NudgeForm extends Form
function formClass()
{
return 'form_user_nudge';
return 'form_user_nudge ajax';
}

View File

@ -89,7 +89,7 @@ class SubscribeForm extends Form
function formClass()
{
return 'form_user_subscribe';
return 'form_user_subscribe ajax';
}

View File

@ -89,7 +89,7 @@ class UnsubscribeForm extends Form
function formClass()
{
return 'form_user_unsubscribe';
return 'form_user_unsubscribe ajax';
}
/**

View File

@ -83,7 +83,7 @@ class PollResponseForm extends Form
function formClass()
{
return 'form_settings';
return 'form_settings ajax';
}
/**

View File

@ -83,7 +83,7 @@ class PollResultForm extends Form
function formClass()
{
return 'form_settings';
return 'form_settings ajax';
}
/**

View File

@ -145,8 +145,23 @@ class RespondPollAction extends Action
return;
}
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);
}
}
/**
* Show the Poll form

View File

@ -180,21 +180,6 @@ class UserFlagPlugin extends Plugin
}
}
/**
* Initialize any flagging buttons on the page
*
* @param Action $action action being shown
*
* @return boolean hook result
*/
function onEndShowScripts($action)
{
$action->inlineScript('if ($(".form_entity_flag").length > 0) { '.
'$(".form_entity_flag").bind("click", function() {'.
'SN.U.FormXHR($(this)); return false; }); }');
return true;
}
/**
* Check whether a user has one of our defined rights
*

View File

@ -54,7 +54,7 @@ class FlagProfileForm extends ProfileActionForm
*/
function formClass()
{
return 'form_entity_flag';
return 'form_entity_flag ajax';
}
/**