Skip to content

Settings defaults and changing suffix is wrong #20

Description

@mzahidriaz

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions