mirror of
https://github.com/scratchfoundation/jquery-timeago.git
synced 2025-03-28 05:09:40 -04:00
Interpret null wordSeparator as empty string
This commit is contained in:
parent
7a05219f6e
commit
bd42f80c17
3 changed files with 22 additions and 1 deletions
|
@ -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) {
|
||||
|
|
|
@ -139,6 +139,7 @@
|
|||
<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 @@
|
|||
loadNoSpaces();
|
||||
$("abbr.nospaces").each(toWords);
|
||||
|
||||
loadNullSpaces();
|
||||
$("abbr.nullspaces").each(toWords);
|
||||
|
||||
loadPigLatin();
|
||||
$("abbr.tolatin").each(toWords);
|
||||
|
||||
|
@ -562,6 +566,7 @@
|
|||
|
||||
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"; }
|
||||
|
|
Loading…
Add table
Reference in a new issue