Permalink
Browse files

Interpret null wordSeparator as empty string

  • Loading branch information...
1 parent 7a05219 commit bd42f80c1731208b7c8e925ae4b7a724df7fa15f @jamesbebbington jamesbebbington committed Dec 27, 2012
Showing with 22 additions and 1 deletion.
  1. +10 −1 jquery.timeago.js
  2. +5 −0 test/index.html
  3. +7 −0 test/test_helpers.js
View
@@ -86,7 +86,16 @@
years < 1.5 && substitute($l.year, 1) ||
substitute($l.years, Math.round(years));
- var separator = $l.wordSeparator === undefined ? " " : $l.wordSeparator;
+ switch ($l.wordSeparator) {
+ case undefined:
+ var separator = " ";
+ break;
+ case null:
+ var separator = "";
+ break;
+ default:
+ var separator = $l.wordSeparator;
+ }
return $.trim([prefix, words, suffix].join(separator));
},
parse: function(iso8601) {
View
@@ -139,6 +139,7 @@ <h2 id="qunit-userAgent"></h2>
<li><abbr id="testYoungOldSettings2" class="toyoungold" title="2018304000"></abbr> [23360 days]</li>
<li><abbr id="testNoSpaces1" class="nospaces" title="120"></abbr> [120 sec]</li>
+ <li><abbr id="testNullSpaces1" class="nullspaces" title="120"></abbr> [120 sec]</li>
<li><abbr id="testLatinSettings1" class="tolatin" title="-7200"></abbr> [-120 min]</li>
<li><abbr id="testLatinSettings2" class="tolatin" title="-60"></abbr> [-60 sec]</li>
@@ -243,6 +244,9 @@ <h2 id="qunit-userAgent"></h2>
loadNoSpaces();
$("abbr.nospaces").each(toWords);
+ loadNullSpaces();
+ $("abbr.nullspaces").each(toWords);
+
loadPigLatin();
$("abbr.tolatin").each(toWords);
@@ -562,6 +566,7 @@ <h2 id="qunit-userAgent"></h2>
test("wordSeparator", function () {
ok($("#testNoSpaces1").html().match(/^2minutesago$/), "Settings correctly applied");
+ ok($("#testNullSpaces1").html().match(/^2minutesago$/), "Settings correctly applied");
});
})(jQuery);
//]]>
@@ -102,6 +102,13 @@ function loadNoSpaces() {
});
}
+function loadNullSpaces() {
+ jQuery.extend(jQuery.timeago.settings.strings, {
+ minutes: "%dminutes",
+ wordSeparator: null
+ });
+}
+
function loadYoungOldYears() {
jQuery.extend(jQuery.timeago.settings.strings, {
years: function(value) { return (value < 21) ? "%d young years" : "%d old years"; }

0 comments on commit bd42f80

Please sign in to comment.