From 20b254077925d3bc2642a6ff623432b3fb5bdd07 Mon Sep 17 00:00:00 2001 From: Tom Adams Date: Tue, 4 Aug 2009 01:22:40 +0100 Subject: Only warn when chars remaining < 0, not <= 0. --- js/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index f3ed918cf..fd30336b9 100644 --- a/js/util.js +++ b/js/util.js @@ -25,7 +25,7 @@ $(document).ready(function(){ var counter = $("#notice_text-count"); counter.text(remaining); - if (remaining <= 0) { + if (remaining < 0) { $("#form_notice").addClass("warning"); } else { $("#form_notice").removeClass("warning"); -- cgit v1.2.3-54-g00ecf From 2b00990d27b55644ff133355628f948ddca6df70 Mon Sep 17 00:00:00 2001 From: Tom Adams Date: Tue, 4 Aug 2009 01:58:45 +0100 Subject: Prepend replyto string to message, don't destroy user input! --- js/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index fd30336b9..d4db8b72a 100644 --- a/js/util.js +++ b/js/util.js @@ -257,7 +257,7 @@ function NoticeReplySet(nick,id) { if (nick.match(rgx_username)) { replyto = "@" + nick + " "; if ($("#notice_data-text").length) { - $("#notice_data-text").val(replyto); + $("#notice_data-text").val(replyto + $("#notice_data-text").val()); $("#form_notice input#notice_in-reply-to").val(id); $("#notice_data-text").focus(); return false; -- cgit v1.2.3-54-g00ecf From 39c420b51fb57f98780d583efaaaebd79de12db9 Mon Sep 17 00:00:00 2001 From: Tom Adams Date: Tue, 4 Aug 2009 09:22:37 +0100 Subject: Set focus to end of field. --- js/util.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index d4db8b72a..0409dc601 100644 --- a/js/util.js +++ b/js/util.js @@ -256,10 +256,19 @@ function NoticeReplySet(nick,id) { rgx_username = /^[0-9a-zA-Z\-_.]*$/; if (nick.match(rgx_username)) { replyto = "@" + nick + " "; - if ($("#notice_data-text").length) { - $("#notice_data-text").val(replyto + $("#notice_data-text").val()); + var text = $("#notice_data-text"); + if (text.length) { + text.val(replyto + text.val()); $("#form_notice input#notice_in-reply-to").val(id); - $("#notice_data-text").focus(); + if (text.get(0).setSelectionRange) { + var len = text.val().length; + text.get(0).setSelectionRange(len,len); + text.get(0).focus(); + } else if (text.get(0).createTextRange) { + var range = text.createTextRange(); + range.collapse(false); + range.select(); + } return false; } } -- cgit v1.2.3-54-g00ecf From ffa1d662a759a729151f2444bdf759749d59045e Mon Sep 17 00:00:00 2001 From: Tom Adams Date: Tue, 4 Aug 2009 16:15:36 +0100 Subject: Didn't test that JS in IE. Revert a little. --- js/util.js | 4 ---- 1 file changed, 4 deletions(-) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index 0409dc601..9d6e52b2d 100644 --- a/js/util.js +++ b/js/util.js @@ -264,10 +264,6 @@ function NoticeReplySet(nick,id) { var len = text.val().length; text.get(0).setSelectionRange(len,len); text.get(0).focus(); - } else if (text.get(0).createTextRange) { - var range = text.createTextRange(); - range.collapse(false); - range.select(); } return false; } -- cgit v1.2.3-54-g00ecf From 3a6e7d68fce1ef66f959071299dbe86aa91f495a Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 4 Aug 2009 15:54:02 +0000 Subject: Ticket 1758 Multiple replies in web interface on "profile" page appends own username --- js/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index 9d6e52b2d..ef147bef4 100644 --- a/js/util.js +++ b/js/util.js @@ -244,7 +244,7 @@ function NoticeReply() { $('#content .notice').each(function() { var notice = $(this)[0]; $($('.notice_reply', notice)[0]).click(function() { - var nickname = ($('.author .nickname', notice).length > 0) ? $($('.author .nickname', notice)[0]) : $('.author .nickname'); + var nickname = ($('.author .nickname', notice).length > 0) ? $($('.author .nickname', notice)[0]) : $('.author .nickname.uid'); NoticeReplySet(nickname.text(), $($('.notice_id', notice)[0]).text()); return false; }); -- cgit v1.2.3-54-g00ecf From b2e9d23b843ab799e2601607f3a9580b1f82ac5d Mon Sep 17 00:00:00 2001 From: Tom Adams Date: Thu, 6 Aug 2009 23:13:05 +0100 Subject: Set counter text only when it differs from the new remaining count. This speeds up keyboard navigation around the textarea field. --- js/util.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index ef147bef4..1ab711cd1 100644 --- a/js/util.js +++ b/js/util.js @@ -23,7 +23,9 @@ $(document).ready(function(){ var currentLength = $("#notice_data-text").val().length; var remaining = maxLength - currentLength; var counter = $("#notice_text-count"); - counter.text(remaining); + if (counter.text() != String(remaining)) { + counter.text(remaining); + } if (remaining < 0) { $("#form_notice").addClass("warning"); -- cgit v1.2.3-54-g00ecf From 534d0d804c6b92d8498fbd37a947e3712aaa9e3e Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Sat, 8 Aug 2009 10:44:28 +0000 Subject: Fix for removing the first occurance of the duplicate nickname in textarea when NoticeReply() is used. --- js/util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index 1ab711cd1..0ffa92ca9 100644 --- a/js/util.js +++ b/js/util.js @@ -257,10 +257,10 @@ function NoticeReply() { function NoticeReplySet(nick,id) { rgx_username = /^[0-9a-zA-Z\-_.]*$/; if (nick.match(rgx_username)) { - replyto = "@" + nick + " "; var text = $("#notice_data-text"); if (text.length) { - text.val(replyto + text.val()); + replyto = "@" + nick + " "; + text.val(replyto + text.val().replace(RegExp(replyto, 'i'), '')); $("#form_notice input#notice_in-reply-to").val(id); if (text.get(0).setSelectionRange) { var len = text.val().length; -- cgit v1.2.3-54-g00ecf From c6d2e54a7159174736f0184b7b9bc8b7e08bb9df Mon Sep 17 00:00:00 2001 From: brion Date: Sat, 8 Aug 2009 17:54:57 -0700 Subject: Throttles updating of the character counter to reduce the performance impact on typing, especially on slower devices (mobiles, netbooks). http://laconi.ca/trac/ticket/1462 --- js/util.js | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index 0ffa92ca9..440701937 100644 --- a/js/util.js +++ b/js/util.js @@ -17,21 +17,41 @@ */ $(document).ready(function(){ + var counterBlackout = false; + // count character on keyup function counter(event){ var maxLength = 140; var currentLength = $("#notice_data-text").val().length; var remaining = maxLength - currentLength; var counter = $("#notice_text-count"); - if (counter.text() != String(remaining)) { - counter.text(remaining); - } + + if (remaining.toString() != counter.text()) { + if (!counterBlackout || remaining == 0) { + if (counter.text() != String(remaining)) { + counter.text(remaining); + } - if (remaining < 0) { - $("#form_notice").addClass("warning"); - } else { - $("#form_notice").removeClass("warning"); - } + if (remaining < 0) { + $("#form_notice").addClass("warning"); + } else { + $("#form_notice").removeClass("warning"); + } + // Skip updates for the next 500ms. + // On slower hardware, updating on every keypress is unpleasant. + if (!counterBlackout) { + counterBlackout = true; + window.setTimeout(clearCounterBlackout, 500); + } + } + } + } + + function clearCounterBlackout() { + // Allow keyup events to poke the counter again + counterBlackout = false; + // Check if the string changed since we last looked + counter(null); } function submitonreturn(event) { -- cgit v1.2.3-54-g00ecf From a1a97930f3c6c48f2e68ea4855a9e02cacc74064 Mon Sep 17 00:00:00 2001 From: brion Date: Sun, 9 Aug 2009 18:39:51 -0700 Subject: Workaround for bug 1317 '"What's up" textarea on iPhone missing proper submit button' http://laconi.ca/trac/ticket/1317 Mobile Safari shows a 'return' button for making newlines in a