forked from urish/angular-moment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
angular-moment.min.js
1 lines (1 loc) · 1.25 KB
/
angular-moment.min.js
1
angular.module("angularMoment",[]).constant("amTimeAgoConfig",{withoutSuffix:!1}).directive("amTimeAgo",["$window","amTimeAgoConfig",function(a,b){"use strict";return function(c,d,e){function f(){k&&(a.clearTimeout(k),k=null)}function g(c){d.text(c.fromNow(b.withoutSuffix));var e=a.moment().diff(c,"minute"),f=3600;1>e?f=1:60>e?f=30:180>e&&(f=300),k=a.setTimeout(function(){g(c)},1e3*f)}function h(){f(),g(a.moment(i,j))}var i,j,k=null;c.$watch(e.amTimeAgo,function(a){return"undefined"==typeof a||null===a||""===a?(f(),i&&(d.text(""),i=null),void 0):(angular.isNumber(a)&&(a=new Date(a)),i=a,h(),void 0)}),e.$observe("amFormat",function(a){j=a,i&&h()}),c.$on("$destroy",function(){f()})}}]).filter("amCalendar",["$window",function(a){"use strict";return function(b){return"undefined"==typeof b||null===b?"":(!isNaN(parseFloat(b))&&isFinite(b)&&(b=new Date(parseInt(b,10))),a.moment(b).calendar())}}]).filter("amDateFormat",["$window",function(a){"use strict";return function(b,c){return"undefined"==typeof b||null===b?"":(!isNaN(parseFloat(b))&&isFinite(b)&&(b=new Date(parseInt(b,10))),a.moment(b).format(c))}}]).filter("amDurationFormat",["$window",function(a){"use strict";return function(b,c,d){return"undefined"==typeof b||null===b?"":a.moment.duration(b,c).humanize(d)}}]);