MS DH; update timeago if a timeago element on the page exists.

This commit is contained in:
Dan Hansen 2011-06-02 12:09:06 -05:00
parent 82ca293825
commit 7363bf3499

View file

@ -9,14 +9,22 @@ Diaspora.widgets.add("timeago", function() {
Diaspora.widgets.subscribe("stream/scrolled", this.updateTimeAgo);
Diaspora.widgets.subscribe("stream/reloaded", this.updateTimeAgo);
if(this.timeAgoElement().length) {
this.updateTimeAgo();
}
if(Diaspora.widgets.i18n.language !== "en") {
$.each($.timeago.settings.strings, function(index, element) {
$.each($.timeago.settings.strings, function(index) {
$.timeago.settings.strings[index] = Diaspora.widgets.i18n.t("timeago." + index);
});
}
};
this.updateTimeAgo = function(selector) {
$((typeof selector === "string") ? selector : Diaspora.widgets.timeago.selector).timeago();
this.timeAgoElement = function(selector) {
return $((typeof selector === "string") ? selector : this.selector);
};
this.updateTimeAgo = function() {
this.timeAgoElement().timeago();
};
});