Cleanup & minification for migration to reusable notice form in inline replies. Yay!
This commit is contained in:
parent
a1002cc107
commit
2fa95144ed
71
js/util.js
71
js/util.js
|
@ -615,77 +615,6 @@ var SN = { // StatusNet
|
|||
|
||||
nextStep();
|
||||
});
|
||||
/*
|
||||
replyItem = $('<li class="notice-reply">' +
|
||||
'<form class="notice-reply-form" method="post">' +
|
||||
'<textarea name="status_textarea"></textarea>' +
|
||||
'<div class="controls">' +
|
||||
'<input type="hidden" name="token">' +
|
||||
'<input type="hidden" name="inreplyto">' +
|
||||
'<input type="submit" class="submit">' +
|
||||
'</div>' +
|
||||
'</form>' +
|
||||
'</li>');
|
||||
var baseForm = $('#form_notice');
|
||||
replyForm = replyItem.find('form');
|
||||
replyForm.attr('action', baseForm.attr('action'));
|
||||
replyForm.find('input[name="token"]').val(baseForm.find('input[name=token]').val());
|
||||
replyForm.find('input[type="submit"]').val(SN.msg('reply_submit'));
|
||||
list.append(replyItem);
|
||||
|
||||
replyForm.find('textarea').blur(function() {
|
||||
var textarea = $(this);
|
||||
var txt = $.trim(textarea.val());
|
||||
if (txt == '' || txt == textarea.data('initialText')) {
|
||||
// Nothing to say? Begone!
|
||||
replyItem.remove();
|
||||
if (list.find('li').length > 0) {
|
||||
SN.U.NoticeInlineReplyPlaceholder(parentNotice);
|
||||
} else {
|
||||
list.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
replyForm.submit(function(event) {
|
||||
var form = replyForm;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'xml',
|
||||
url: SN.U.RewriteAjaxAction(form.attr('action')),
|
||||
data: form.serialize() + '&ajax=1',
|
||||
beforeSend: function(xhr) {
|
||||
form
|
||||
.addClass(SN.C.S.Processing)
|
||||
.find('.submit')
|
||||
.addClass(SN.C.S.Disabled)
|
||||
.attr(SN.C.S.Disabled, SN.C.S.Disabled)
|
||||
.end()
|
||||
.find('textarea')
|
||||
.addClass(SN.C.S.Disabled)
|
||||
.attr(SN.C.S.Disabled, SN.C.S.Disabled);
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
alert(errorThrown || textStatus);
|
||||
},
|
||||
success: function(data, textStatus) {
|
||||
var orig_li = $('li', data)[0];
|
||||
if (orig_li) {
|
||||
var li = document._importNode(orig_li, true);
|
||||
var id = $(li).attr('id');
|
||||
if ($("#"+id).length == 0) {
|
||||
replyItem.replaceWith(li);
|
||||
SN.U.NoticeInlineReplyPlaceholder(parentNotice);
|
||||
} else {
|
||||
// Realtime came through before us...
|
||||
replyItem.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
2
js/util.min.js
vendored
2
js/util.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user