Reputation: 47377
I'm trying to "tweek" the TimeAgo plugin so that I can remove the suffix "ago" on a case by case basis.
Here's what I've tried
$("time.timeago-nosuffix").timeago({suffixAgo: ""});
and
$("time.timeago-nosuffix").timeago({ settings: { strings: { suffixAgo: null}} });
as well as
$(document).ready(function () {
$("time.timeago").timeago();
$("time.timeago-nosuffix").timeago(function () {
suffixAgo: ""
});
});
with out any luck.
Upvotes: 4
Views: 2877
Reputation: 239914
Disclaimer: I'm the author of timeago.
Unfortunately, as PetersenDidIt pointed out, timeago doesn't currently support runtime options. There's been an open issue on GitHub to address this, but I haven't had the time to look into it. PetersenDidIt, Thanks for the pull-request. I'll take a look as soon as I can.
Meanwhile, here's one of several possible workarounds...
First, set the suffix to an empty string by default:
$.timeago.settings.strings.suffixAgo = "";
Next, run timeago like you normally would:
$("time.timeago").timeago()
Lastly, instead of adding a "nosuffix" qualifier, add a class to each timestamp for which you want a suffix and add the suffix to all of those timestamps once:
$("time.timeago.suffix").after(" ago")
Upvotes: 7
Reputation: 25620
Just set suffixAgo
to a blank string
$("time.timeago-nosuffix").timeago({strings: {suffixAgo: ""}});
UPDATE Looks like the current version of the plugin doesn't handle runtime options. I created a fork of the git repository and created a version that does:
https://github.com/petersendidit/jquery-timeago/blob/master/jquery.timeago.js
Upvotes: 4