forked from GNUsocial/gnu-social
Replace explicit FormXHR setup for a bunch of simple AJAX form submissions with adding the 'ajax' class on them.
This avoids having to add extra custom JS bits just to initialize forms using the common AJAX submission path.
This commit is contained in:
21
js/util.js
21
js/util.js
@@ -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();
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user