diff options
Diffstat (limited to 'js/util.js')
-rw-r--r-- | js/util.js | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/js/util.js b/js/util.js index 2165957c3..b079388e4 100644 --- a/js/util.js +++ b/js/util.js @@ -21,7 +21,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"); @@ -67,12 +69,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(); @@ -218,7 +228,9 @@ $(document).ready(function(){ } else { $("#notice_data-text").val(""); - counter(); + if (maxLength > 0) { + counter(); + } } } } @@ -229,6 +241,9 @@ $(document).ready(function(){ alert(result); } else { + if($('body')[0].id == 'bookmarklet') { + self.close(); + } if ($("#command_result", xml).length > 0) { var result = document._importNode($("p", xml).get(0), true); result = result.textContent || result.innerHTML; @@ -258,7 +273,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"); |