MS DH; update timeago if a timeago element on the page exists.
This commit is contained in:
parent
82ca293825
commit
7363bf3499
1 changed files with 11 additions and 3 deletions
|
|
@ -9,14 +9,22 @@ Diaspora.widgets.add("timeago", function() {
|
||||||
Diaspora.widgets.subscribe("stream/scrolled", this.updateTimeAgo);
|
Diaspora.widgets.subscribe("stream/scrolled", this.updateTimeAgo);
|
||||||
Diaspora.widgets.subscribe("stream/reloaded", this.updateTimeAgo);
|
Diaspora.widgets.subscribe("stream/reloaded", this.updateTimeAgo);
|
||||||
|
|
||||||
|
if(this.timeAgoElement().length) {
|
||||||
|
this.updateTimeAgo();
|
||||||
|
}
|
||||||
|
|
||||||
if(Diaspora.widgets.i18n.language !== "en") {
|
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);
|
$.timeago.settings.strings[index] = Diaspora.widgets.i18n.t("timeago." + index);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.updateTimeAgo = function(selector) {
|
this.timeAgoElement = function(selector) {
|
||||||
$((typeof selector === "string") ? selector : Diaspora.widgets.timeago.selector).timeago();
|
return $((typeof selector === "string") ? selector : this.selector);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.updateTimeAgo = function() {
|
||||||
|
this.timeAgoElement().timeago();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue