From 5e2d5f0acc54ca2d932d91659f1ca06008f696e0 Mon Sep 17 00:00:00 2001 From: albert Date: Thu, 6 Oct 2011 19:17:49 -0400 Subject: [PATCH] fixed rel tag js --- app/assets/javascripts/related_tag.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/related_tag.js b/app/assets/javascripts/related_tag.js index 4da57ef76..373ab7e69 100644 --- a/app/assets/javascripts/related_tag.js +++ b/app/assets/javascripts/related_tag.js @@ -35,7 +35,7 @@ // 8. | abc def -> abc -- not supported by this code but a pretty rare case var $field = $("#upload_tag_string,#post_tag_string"); - var string = $field.val(); + var string = $field.val().trim(); var n = string.length; var a = $field.get(0).selectionStart; var b = $field.get(0).selectionStart; @@ -46,27 +46,24 @@ while ((b < n) && (string[b] !== " ")) { b++; - console.log("1. a=%s b=%s", a, b); } } else { while ((a > 0) && ((string[a] === " ") || (string[a] === undefined))) { a--; b--; - console.log("2. a=%s b=%s", a, b); } while ((a > 0) && (string[a - 1] !== " ")) { a--; b--; - console.log("3. a=%s b=%s", a, b); } while ((b < (n - 1)) && (string[b] !== " ")) { b++; - console.log("4. a=%s b=%s", a, b); } } - + + b++; return string.slice(a, b); }