Updated SubmitOnReturn

This commit is contained in:
Sarven Capadisli 2009-10-30 14:31:57 +01:00
parent 53e91f22d2
commit 1ddf69f30e

View File

@ -56,18 +56,7 @@ $(document).ready(function(){
counter(null); counter(null);
} }
function submitonreturn(event) {
if (event.keyCode == 13 || event.keyCode == 10) {
// iPhone sends \n not \r for 'return'
$("#form_notice").submit();
event.preventDefault();
event.stopPropagation();
$("#notice_data-text").blur();
$("body").focus();
return false;
}
return true;
}
// define maxLength if it wasn't defined already // define maxLength if it wasn't defined already
@ -82,7 +71,9 @@ $(document).ready(function(){
counter(); counter();
} }
$("#notice_data-text").bind("keydown", submitonreturn); $('#'+SN.C.S.NoticeDataText).bind('keydown', function(e) {
SN.U.SubmitOnReturn(e, $('#'+SN.C.S.FormNotice));
});
if($('body')[0].id != 'conversation') { if($('body')[0].id != 'conversation') {
$("#notice_data-text").focus(); $("#notice_data-text").focus();
@ -130,6 +121,18 @@ var SN = { // StatusNet
}, },
U: { // Utils U: { // Utils
SubmitOnReturn: function(event, el) {
if (event.keyCode == 13 || event.keyCode == 10) {
el.submit();
event.preventDefault();
event.stopPropagation();
$('#'+SN.U.NoticeDataText).blur();
$('body').focus();
return false;
}
return true;
},
FormXHR: function(f) { FormXHR: function(f) {
f.bind('submit', function(e) { f.bind('submit', function(e) {
form_id = $(this)[0].id; form_id = $(this)[0].id;