summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-08-21 07:22:53 -0400
committerEvan Prodromou <evan@controlyourself.ca>2009-08-21 07:22:53 -0400
commit6dcded4129cebf2e492499cd258bf14a6e25eff9 (patch)
tree087ffed063232791ff340c2bb1a5f7049ad0b747
parenteb309f788bc9e52fd7108e024e58594b425de426 (diff)
counter in notice/message form uses global variable for max length
-rw-r--r--js/util.js28
1 files changed, 21 insertions, 7 deletions
diff --git a/js/util.js b/js/util.js
index f3ed918cf..3a0a8d9a7 100644
--- a/js/util.js
+++ b/js/util.js
@@ -19,7 +19,9 @@
$(document).ready(function(){
// count character on keyup
function counter(event){
- var maxLength = 140;
+ if (maxLength <= 0) {
+ return;
+ }
var currentLength = $("#notice_data-text").val().length;
var remaining = maxLength - currentLength;
var counter = $("#notice_text-count");
@@ -42,12 +44,20 @@ $(document).ready(function(){
return true;
}
+ // define maxLength if it wasn't defined already
+
+ if (typeof(maxLength) == "undefined") {
+ maxLength = 140;
+ }
+
if ($("#notice_data-text").length) {
- $("#notice_data-text").bind("keyup", counter);
- $("#notice_data-text").bind("keydown", submitonreturn);
+ if (maxLength > 0) {
+ $("#notice_data-text").bind("keyup", counter);
+ // run once in case there's something in there
+ counter();
+ }
- // run once in case there's something in there
- counter();
+ $("#notice_data-text").bind("keydown", submitonreturn);
if($('body')[0].id != 'conversation') {
$("#notice_data-text").focus();
@@ -185,7 +195,9 @@ $(document).ready(function(){
}
else {
$("#notice_data-text").val("");
- counter();
+ if (maxLength > 0) {
+ counter();
+ }
}
}
}
@@ -225,7 +237,9 @@ $(document).ready(function(){
$("#notice_data-attach").val("");
$("#notice_in-reply-to").val("");
$('#notice_data-attach_selected').remove();
- counter();
+ if (maxLength > 0) {
+ counter();
+ }
}
$("#form_notice").removeClass("processing");
$("#notice_action-submit").removeAttr("disabled");