Skip to content

Commit ce7d24d

Browse files
committed
Updating with personal customizations
1 parent ea26675 commit ce7d24d

File tree

1 file changed

+39
-10
lines changed

1 file changed

+39
-10
lines changed

jquery.timeago.js

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,23 @@
4141
refreshMillis: 60000,
4242
allowFuture: false,
4343
localeTitle: false,
44-
cutoff: 0,
44+
cutoff: 172800000,
4545
strings: {
4646
prefixAgo: null,
4747
prefixFromNow: null,
4848
suffixAgo: "ago",
4949
suffixFromNow: "from now",
50-
seconds: "less than a minute",
51-
minute: "about a minute",
50+
seconds: "Mere seconds",
51+
minute: "A minute",
5252
minutes: "%d minutes",
53-
hour: "about an hour",
54-
hours: "about %d hours",
55-
day: "a day",
53+
hour: "An hour",
54+
hours: "%d hours",
55+
day: "A day",
5656
days: "%d days",
57-
month: "about a month",
57+
month: "A month",
5858
months: "%d months",
59-
year: "about a year",
60-
years: "%d years",
59+
year: "A year",
60+
years: "Over a year",
6161
wordSeparator: " ",
6262
numbers: []
6363
}
@@ -124,6 +124,7 @@
124124
// functions are called with context of a single element
125125
var functions = {
126126
init: function(){
127+
$(this).data("origtime",$(this).html());
127128
var refresh_el = $.proxy(refresh, this);
128129
refresh_el();
129130
var $s = $t.settings;
@@ -159,9 +160,37 @@
159160

160161
if (!isNaN(data.datetime)) {
161162
if ( $s.cutoff == 0 || distance(data.datetime) < $s.cutoff) {
162-
$(this).text(inWords(data.datetime));
163+
164+
$(this).text(inWords(data.datetime)).hover(
165+
function(){
166+
var $this = $(this);
167+
var d = data.datetime,
168+
daysago = (new Date().getDate() - d.getDate()),
169+
exacttime = [(d.getHours() > 12 ? d.getHours() - 12 : d.getHours()),d.getMinutes()].join(":") + (d.getHours() >= 12 ? "pm" : "am"),
170+
realdate;
171+
switch (daysago) {
172+
case 0:
173+
realdate = "At " + exacttime;
174+
break;
175+
case 1:
176+
realdate = "Yesterday at " + exacttime;
177+
break;
178+
default:
179+
realdate = d.toLocaleDateString() + " at " + exacttime;
180+
}
181+
$this.stop().fadeOut(100,function(){
182+
$this.data("orig",$this.text()).text(realdate).stop().fadeIn(100);
183+
});
184+
}, function() {
185+
var $this = $(this);
186+
$this.fadeOut(100,function(){
187+
$this.text($this.data("orig")).stop().fadeIn(100);
188+
});
189+
}
190+
);
163191
}
164192
}
193+
$(this).fadeIn('slow');
165194
return this;
166195
}
167196

0 commit comments

Comments
 (0)