Welcome to mirror list, hosted at ThFree Co, Russian Federation.

timeago.min.js « js « assets - github.com/uPagge/uBlogger.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cbc56ca044622e9a90ec796c606a037c78a24351 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/*
 MIT License - http://www.opensource.org/licenses/mit-license.php

 For usage and examples, visit:
 http://timeago.yarp.com/

 Copyright (c) 2008-2019, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
*/
(function(b){"function"===typeof define&&define.amd?define(["jquery"],b):"object"===typeof module&&"object"===typeof module.exports?b(require("jquery")):b(jQuery)})(function(b){function l(){var a=e.settings;if(a.autoDispose&&!b.contains(document.documentElement,this))return b(this).timeago("dispose"),this;var c=b(this);if(!c.data("timeago")){c.data("timeago",{datetime:e.datetime(c)});var d=b.trim(c.text());e.settings.localeTitle?c.attr("title",c.data("timeago").datetime.toLocaleString()):!(0<d.length)||
e.isTime(c)&&c.attr("title")||c.attr("title",d)}c=c.data("timeago");isNaN(c.datetime)||(0===a.cutoff||Math.abs(g(c.datetime))<a.cutoff?b(this).text(e.inWords(g(c.datetime))):0<b(this).attr("title").length&&b(this).text(b(this).attr("title")));return this}function g(a){return(new Date).getTime()-a.getTime()}b.timeago=function(a){return a instanceof Date?e.inWords(g(a)):"string"===typeof a?e.inWords(g(b.timeago.parse(a))):"number"===typeof a?e.inWords(g(new Date(a))):e.inWords(g(b.timeago.datetime(a)))};
var e=b.timeago;b.extend(b.timeago,{settings:{refreshMillis:6E4,allowPast:!0,allowFuture:!1,localeTitle:!1,cutoff:0,autoDispose:!0,strings:{prefixAgo:null,prefixFromNow:null,suffixAgo:"ago",suffixFromNow:"from now",inPast:"any moment now",seconds:"less than a minute",minute:"about a minute",minutes:"%d minutes",hour:"about an hour",hours:"about %d hours",day:"a day",days:"%d days",month:"about a month",months:"%d months",year:"about a year",years:"%d years",wordSeparator:" ",numbers:[]}},inWords:function(a){function c(m,
n){return(b.isFunction(m)?m(n,a):m).replace(/%d/i,d.numbers&&d.numbers[n]||n)}if(!this.settings.allowPast&&!this.settings.allowFuture)throw"timeago allowPast and allowFuture settings can not both be set to false.";var d=this.settings.strings,q=d.prefixAgo,r=d.suffixAgo;this.settings.allowFuture&&0>a&&(q=d.prefixFromNow,r=d.suffixFromNow);if(!this.settings.allowPast&&0<=a)return this.settings.strings.inPast;var h=Math.abs(a)/1E3,f=h/60,k=f/60,t=k/24;h=45>h&&c(d.seconds,Math.round(h))||90>h&&c(d.minute,
1)||45>f&&c(d.minutes,Math.round(f))||90>f&&c(d.hour,1)||24>k&&c(d.hours,Math.round(k))||42>k&&c(d.day,1)||5>t&&c(d.days,Math.round(t))||c(d);f=d.wordSeparator||"";void 0===d.wordSeparator&&(f=" ");return b.trim([q,h,r].join(f))},parse:function(a){a=b.trim(a);a=a.replace(/\.\d+/,"");a=a.replace(/-/,"/").replace(/-/,"/");a=a.replace(/T/," ").replace(/Z/," UTC");a=a.replace(/([\+\-]\d\d):?(\d\d)/," $1$2");a=a.replace(/([\+\-]\d\d)$/," $100");return new Date(a)},datetime:function(a){a=e.isTime(a)?b(a).attr("datetime"):
b(a).attr("title");return e.parse(a)},isTime:function(a){return"time"===b(a).get(0).tagName.toLowerCase()}});var p={init:function(){p.dispose.call(this);var a=b.proxy(l,this);a();var c=e.settings;0<c.refreshMillis&&(this._timeagoInterval=setInterval(a,c.refreshMillis))},update:function(a){a=a instanceof Date?a:e.parse(a);b(this).data("timeago",{datetime:a});e.settings.localeTitle&&b(this).attr("title",a.toLocaleString());l.apply(this)},updateFromDOM:function(){b(this).data("timeago",{datetime:e.parse(e.isTime(this)?
b(this).attr("datetime"):b(this).attr("title"))});l.apply(this)},dispose:function(){this._timeagoInterval&&(window.clearInterval(this._timeagoInterval),this._timeagoInterval=null)}};b.fn.timeago=function(a,c){var d=a?p[a]:p.init;if(!d)throw Error("Unknown function name '"+a+"' for timeago");this.each(function(){d.call(this,c)});return this};document.createElement("abbr");document.createElement("time")});