Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings defaults and changing suffix is wrong #20

Open
mzahidriaz opened this issue Mar 23, 2013 · 0 comments
Open

Settings defaults and changing suffix is wrong #20

mzahidriaz opened this issue Mar 23, 2013 · 0 comments

Comments

@mzahidriaz
Copy link

Hi

Ways mentioned in the documentation/website are wrong to set default options. Because if you do this

$.fn.timeago.defaults = {
selector: 'time.timeago',
attr: 'datetime',
dir: 'up',
suffix: 'ago'
};

this will replace whole default options written in the pluggin.js file.
You have to manually change single item like

$.fn.timeago.defaults.selector = 'abbr.timeago';
$.fn.timeago.defaults.attr = 'title';

This will do the trick.

Secondly

If you change the direction to down and suffix to "from now" like mentioned on the website. This doesn't change any suffix at all. Becuase in plugin js file you are getting the suffix information from the "options.lang.suffix"

To fix this either pass the suffix like

element.timeago({
dir: 'down',
lang : {
suffix: 'from now'
}
});

but this will cause another problem because the extend you use in plugin is not recursive. You also have to change this and pass true as first argument.

TimeAgo.prototype.init = function(element, options) {
this.$element = $(element);
this.options = $.extend(true, {}, $.fn.timeago.defaults, options);
this.updateTime();
return this.startTimer();
};

Or you can change the plugin to change the location of suffix. Instead of taking this from lang you can place it outside lang.

Or you can add a separate prefix for future tense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant