counter in notice/message form uses global variable for max length
This commit is contained in:
parent
eb309f788b
commit
6dcded4129
30
js/util.js
30
js/util.js
|
@ -19,7 +19,9 @@
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
// count character on keyup
|
// count character on keyup
|
||||||
function counter(event){
|
function counter(event){
|
||||||
var maxLength = 140;
|
if (maxLength <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var currentLength = $("#notice_data-text").val().length;
|
var currentLength = $("#notice_data-text").val().length;
|
||||||
var remaining = maxLength - currentLength;
|
var remaining = maxLength - currentLength;
|
||||||
var counter = $("#notice_text-count");
|
var counter = $("#notice_text-count");
|
||||||
|
@ -42,12 +44,20 @@ $(document).ready(function(){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($("#notice_data-text").length) {
|
// define maxLength if it wasn't defined already
|
||||||
$("#notice_data-text").bind("keyup", counter);
|
|
||||||
$("#notice_data-text").bind("keydown", submitonreturn);
|
|
||||||
|
|
||||||
// run once in case there's something in there
|
if (typeof(maxLength) == "undefined") {
|
||||||
counter();
|
maxLength = 140;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($("#notice_data-text").length) {
|
||||||
|
if (maxLength > 0) {
|
||||||
|
$("#notice_data-text").bind("keyup", counter);
|
||||||
|
// run once in case there's something in there
|
||||||
|
counter();
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#notice_data-text").bind("keydown", submitonreturn);
|
||||||
|
|
||||||
if($('body')[0].id != 'conversation') {
|
if($('body')[0].id != 'conversation') {
|
||||||
$("#notice_data-text").focus();
|
$("#notice_data-text").focus();
|
||||||
|
@ -185,7 +195,9 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$("#notice_data-text").val("");
|
$("#notice_data-text").val("");
|
||||||
counter();
|
if (maxLength > 0) {
|
||||||
|
counter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,7 +237,9 @@ $(document).ready(function(){
|
||||||
$("#notice_data-attach").val("");
|
$("#notice_data-attach").val("");
|
||||||
$("#notice_in-reply-to").val("");
|
$("#notice_in-reply-to").val("");
|
||||||
$('#notice_data-attach_selected').remove();
|
$('#notice_data-attach_selected').remove();
|
||||||
counter();
|
if (maxLength > 0) {
|
||||||
|
counter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$("#form_notice").removeClass("processing");
|
$("#form_notice").removeClass("processing");
|
||||||
$("#notice_action-submit").removeAttr("disabled");
|
$("#notice_action-submit").removeAttr("disabled");
|
||||||
|
|
Loading…
Reference in New Issue