mirror of
https://github.com/wahyd4/cdnjs.git
synced 2026-08-09 04:46:00 +10:00
add old versions of jquery.age
This commit is contained in:
@@ -0,0 +1,146 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Gridly
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age, Helper,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Helper = (function() {
|
||||
function Helper() {}
|
||||
|
||||
Helper.after = function() {};
|
||||
|
||||
return Helper;
|
||||
|
||||
})();
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "a hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
setInterval(this.reformat, this.settings.interval);
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
return this.$el.html(this.text());
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
var attribute;
|
||||
attribute = this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time');
|
||||
return new Date(attribute);
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: Math.round(Math.abs(interval / 1000.)),
|
||||
minutes: Math.round(Math.abs(interval / (1000 * 60))),
|
||||
hours: Math.round(Math.abs(interval / (1000 * 60 * 60))),
|
||||
days: Math.round(Math.abs(interval / (1000 * 60 * 60 * 24))),
|
||||
weeks: Math.round(Math.abs(interval / (1000 * 60 * 60 * 24 * 7))),
|
||||
months: Math.round(Math.abs(interval / (1000 * 60 * 60 * 24 * 30))),
|
||||
years: Math.round(Math.abs(interval / (1000 * 60 * 60 * 24 * 365)))
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.text = function() {
|
||||
var amount, format, formatting, interval, suffix, unit;
|
||||
interval = this.date() - new Date;
|
||||
suffix = this.suffix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,n,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,n=function(){function t(){}return t.after=function(){},t}(),s=function(){function s(n,i){null==i&&(i={}),this.text=e(this.text,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=n,this.settings=t.extend({},s.settings,i),this.reformat(),setInterval(this.reformat,this.settings.interval)}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"a hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){return this.$el.html(this.text())},s.prototype.date=function(){var t;return t=this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"),new Date(t)},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.formatting=function(t){return{seconds:Math.round(Math.abs(t/1e3)),minutes:Math.round(Math.abs(t/6e4)),hours:Math.round(Math.abs(t/36e5)),days:Math.round(Math.abs(t/864e5)),weeks:Math.round(Math.abs(t/6048e5)),months:Math.round(Math.abs(t/2592e6)),years:Math.round(Math.abs(t/31536e6))}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var n;return null!=(n=this.settings.formats[t===this.settings.singular?"singular":"plural"])?n[s]:void 0},s.prototype.text=function(){var t,s,n,e,i,a;return e=this.date()-new Date,i=this.suffix(e),n=this.formatting(e),t=this.amount(n),a=this.unit(n),s=this.format(t,a),s?""+s.replace("{{unit}}",a).replace("{{amount}}",t)+" "+i:this.settings.formats.now},s}(),t.fn.extend({age:function(n){return null==n&&(n={}),this.each(function(){return new s(t(this),n)})}})}).call(this);
|
||||
@@ -0,0 +1,137 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Gridly
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "a hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
setInterval(this.reformat, this.settings.interval);
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
return this.$el.html(this.text());
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
var attribute;
|
||||
attribute = this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time');
|
||||
return new Date(attribute);
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: Math.round(Math.abs(interval / 1000.)),
|
||||
minutes: Math.round(Math.abs(interval / (1000 * 60))),
|
||||
hours: Math.round(Math.abs(interval / (1000 * 60 * 60))),
|
||||
days: Math.round(Math.abs(interval / (1000 * 60 * 60 * 24))),
|
||||
weeks: Math.round(Math.abs(interval / (1000 * 60 * 60 * 24 * 7))),
|
||||
months: Math.round(Math.abs(interval / (1000 * 60 * 60 * 24 * 30))),
|
||||
years: Math.round(Math.abs(interval / (1000 * 60 * 60 * 24 * 365)))
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.text = function() {
|
||||
var amount, format, formatting, interval, suffix, unit;
|
||||
interval = this.date() - new Date;
|
||||
suffix = this.suffix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(n,i){null==i&&(i={}),this.text=e(this.text,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=n,this.settings=t.extend({},s.settings,i),this.reformat(),setInterval(this.reformat,this.settings.interval)}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"a hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){return this.$el.html(this.text())},s.prototype.date=function(){var t;return t=this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"),new Date(t)},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.formatting=function(t){return{seconds:Math.round(Math.abs(t/1e3)),minutes:Math.round(Math.abs(t/6e4)),hours:Math.round(Math.abs(t/36e5)),days:Math.round(Math.abs(t/864e5)),weeks:Math.round(Math.abs(t/6048e5)),months:Math.round(Math.abs(t/2592e6)),years:Math.round(Math.abs(t/31536e6))}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.settings.singular?"singular":"plural"])?e[s]:void 0},s.prototype.text=function(){var t,s,e,n,i,a;return n=this.date()-new Date,i=this.suffix(n),e=this.formatting(n),t=this.amount(e),a=this.unit(e),s=this.format(t,a),s?""+s.replace("{{unit}}",a).replace("{{amount}}",t)+" "+i:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,138 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.singular = 1;
|
||||
|
||||
Age.settings = {
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "a hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
setInterval(this.reformat, this.settings.interval);
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
return this.$el.html(this.text());
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
var attribute;
|
||||
attribute = this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time');
|
||||
return new Date(attribute);
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: Math.round(Math.abs(interval / 1000.)),
|
||||
minutes: Math.round(Math.abs(interval / (1000 * 60))),
|
||||
hours: Math.round(Math.abs(interval / (1000 * 60 * 60))),
|
||||
days: Math.round(Math.abs(interval / (1000 * 60 * 60 * 24))),
|
||||
weeks: Math.round(Math.abs(interval / (1000 * 60 * 60 * 24 * 7))),
|
||||
months: Math.round(Math.abs(interval / (1000 * 60 * 60 * 24 * 30))),
|
||||
years: Math.round(Math.abs(interval / (1000 * 60 * 60 * 24 * 365)))
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.text = function() {
|
||||
var amount, format, formatting, interval, suffix, unit;
|
||||
interval = this.date() - new Date;
|
||||
suffix = this.suffix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(n,i){null==i&&(i={}),this.text=e(this.text,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=n,this.settings=t.extend({},s.settings,i),this.reformat(),setInterval(this.reformat,this.settings.interval)}return s.singular=1,s.settings={interval:1e3,suffixes:{past:"ago",future:"until"},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"a hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){return this.$el.html(this.text())},s.prototype.date=function(){var t;return t=this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"),new Date(t)},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.formatting=function(t){return{seconds:Math.round(Math.abs(t/1e3)),minutes:Math.round(Math.abs(t/6e4)),hours:Math.round(Math.abs(t/36e5)),days:Math.round(Math.abs(t/864e5)),weeks:Math.round(Math.abs(t/6048e5)),months:Math.round(Math.abs(t/2592e6)),years:Math.round(Math.abs(t/31536e6))}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.singular?"singular":"plural"])?e[s]:void 0},s.prototype.text=function(){var t,s,e,n,i,a;return n=this.date()-new Date,i=this.suffix(n),e=this.formatting(n),t=this.amount(e),a=this.unit(e),s=this.format(t,a),s?""+s.replace("{{unit}}",a).replace("{{amount}}",t)+" "+i:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,142 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "a hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
setInterval(this.reformat, this.settings.interval);
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
return this.$el.html(this.text());
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
var attribute;
|
||||
attribute = this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time');
|
||||
return new Date(attribute);
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.round(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 30 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.setting.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.text = function() {
|
||||
var amount, format, formatting, interval, suffix, unit;
|
||||
interval = this.date() - new Date;
|
||||
suffix = this.suffix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(n,i){null==i&&(i={}),this.text=e(this.text,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=n,this.settings=t.extend({},s.settings,i),this.reformat(),setInterval(this.reformat,this.settings.interval)}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"a hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){return this.$el.html(this.text())},s.prototype.date=function(){var t;return t=this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"),new Date(t)},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.adjust=function(t,s){return Math.round(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,94608e7)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.setting.singular?"singular":"plural"])?e[s]:void 0},s.prototype.text=function(){var t,s,e,n,i,a;return n=this.date()-new Date,i=this.suffix(n),e=this.formatting(n),t=this.amount(e),a=this.unit(e),s=this.format(t,a),s?""+s.replace("{{unit}}",a).replace("{{amount}}",t)+" "+i:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,142 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "a hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
setInterval(this.reformat, this.settings.interval);
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
return this.$el.html(this.text());
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
var attribute;
|
||||
attribute = this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time');
|
||||
return new Date(attribute);
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.round(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 30 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.setting.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.text = function() {
|
||||
var amount, format, formatting, interval, suffix, unit;
|
||||
interval = this.date() - new Date;
|
||||
suffix = this.suffix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(n,i){null==i&&(i={}),this.text=e(this.text,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=n,this.settings=t.extend({},s.settings,i),this.reformat(),setInterval(this.reformat,this.settings.interval)}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"a hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){return this.$el.html(this.text())},s.prototype.date=function(){var t;return t=this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"),new Date(t)},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.adjust=function(t,s){return Math.round(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,94608e7)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.setting.singular?"singular":"plural"])?e[s]:void 0},s.prototype.text=function(){var t,s,e,n,i,a;return n=this.date()-new Date,i=this.suffix(n),e=this.formatting(n),t=this.amount(e),a=this.unit(e),s=this.format(t,a),s?""+s.replace("{{unit}}",a).replace("{{amount}}",t)+" "+i:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,142 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "a hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
setInterval(this.reformat, this.settings.interval);
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
return this.$el.html(this.text());
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
var attribute;
|
||||
attribute = this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time');
|
||||
return new Date(attribute);
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.round(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 30 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.text = function() {
|
||||
var amount, format, formatting, interval, suffix, unit;
|
||||
interval = this.date() - new Date;
|
||||
suffix = this.suffix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(n,i){null==i&&(i={}),this.text=e(this.text,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=n,this.settings=t.extend({},s.settings,i),this.reformat(),setInterval(this.reformat,this.settings.interval)}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"a hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){return this.$el.html(this.text())},s.prototype.date=function(){var t;return t=this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"),new Date(t)},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.adjust=function(t,s){return Math.round(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,94608e7)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.settings.singular?"singular":"plural"])?e[s]:void 0},s.prototype.text=function(){var t,s,e,n,i,a;return n=this.date()-new Date,i=this.suffix(n),e=this.formatting(n),t=this.amount(e),a=this.unit(e),s=this.format(t,a),s?""+s.replace("{{unit}}",a).replace("{{amount}}",t)+" "+i:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,142 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "a hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
setInterval(this.reformat, this.settings.interval);
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
return this.$el.html(this.text());
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
var attribute;
|
||||
attribute = this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time');
|
||||
return new Date(attribute);
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.round(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 30 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.text = function() {
|
||||
var amount, format, formatting, interval, suffix, unit;
|
||||
interval = this.date() - new Date;
|
||||
suffix = this.suffix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(n,i){null==i&&(i={}),this.text=e(this.text,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=n,this.settings=t.extend({},s.settings,i),this.reformat(),setInterval(this.reformat,this.settings.interval)}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"a hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){return this.$el.html(this.text())},s.prototype.date=function(){var t;return t=this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"),new Date(t)},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.adjust=function(t,s){return Math.round(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,94608e7)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.settings.singular?"singular":"plural"])?e[s]:void 0},s.prototype.text=function(){var t,s,e,n,i,a;return n=this.date()-new Date,i=this.suffix(n),e=this.formatting(n),t=this.amount(e),a=this.unit(e),s=this.format(t,a),s?""+s.replace("{{unit}}",a).replace("{{amount}}",t)+" "+i:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,153 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "a hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.interval = __bind(this.interval, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
var interval;
|
||||
interval = this.interval();
|
||||
this.$el.html(this.text(interval));
|
||||
interval = Math.abs(interval);
|
||||
if (interval < this.settings.interval) {
|
||||
interval = this.settings.interval;
|
||||
}
|
||||
return setTimeout(this.reformat, interval);
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
return new Date(this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time'));
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.round(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.interval = function() {
|
||||
return this.date() - new Date;
|
||||
};
|
||||
|
||||
Age.prototype.text = function(interval) {
|
||||
var amount, format, formatting, suffix, unit;
|
||||
if (interval == null) {
|
||||
interval = this.interval();
|
||||
}
|
||||
suffix = this.suffix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(i,n){null==n&&(n={}),this.text=e(this.text,this),this.interval=e(this.interval,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=i,this.settings=t.extend({},s.settings,n),this.reformat()}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"a hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){var t;return t=this.interval(),this.$el.html(this.text(t)),t=Math.abs(t),t<this.settings.interval&&(t=this.settings.interval),setTimeout(this.reformat,t)},s.prototype.date=function(){return new Date(this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"))},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.adjust=function(t,s){return Math.round(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,31536e6)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.settings.singular?"singular":"plural"])?e[s]:void 0},s.prototype.interval=function(){return this.date()-new Date},s.prototype.text=function(t){var s,e,i,n,r;return null==t&&(t=this.interval()),n=this.suffix(t),i=this.formatting(t),s=this.amount(i),r=this.unit(i),e=this.format(s,r),e?""+e.replace("{{unit}}",r).replace("{{amount}}",s)+" "+n:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,153 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "a hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.interval = __bind(this.interval, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
var interval;
|
||||
interval = this.interval();
|
||||
this.$el.html(this.text(interval));
|
||||
interval = Math.abs(interval);
|
||||
if (interval < this.settings.interval) {
|
||||
interval = this.settings.interval;
|
||||
}
|
||||
return setTimeout(this.reformat, interval);
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
return new Date(this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time'));
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.round(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.interval = function() {
|
||||
return this.date() - new Date;
|
||||
};
|
||||
|
||||
Age.prototype.text = function(interval) {
|
||||
var amount, format, formatting, suffix, unit;
|
||||
if (interval == null) {
|
||||
interval = this.interval();
|
||||
}
|
||||
suffix = this.suffix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(i,n){null==n&&(n={}),this.text=e(this.text,this),this.interval=e(this.interval,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=i,this.settings=t.extend({},s.settings,n),this.reformat()}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"a hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){var t;return t=this.interval(),this.$el.html(this.text(t)),t=Math.abs(t),t<this.settings.interval&&(t=this.settings.interval),setTimeout(this.reformat,t)},s.prototype.date=function(){return new Date(this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"))},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.adjust=function(t,s){return Math.round(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,31536e6)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.settings.singular?"singular":"plural"])?e[s]:void 0},s.prototype.interval=function(){return this.date()-new Date},s.prototype.text=function(t){var s,e,i,n,r;return null==t&&(t=this.interval()),n=this.suffix(t),i=this.formatting(t),s=this.amount(i),r=this.unit(i),e=this.format(s,r),e?""+e.replace("{{unit}}",r).replace("{{amount}}",s)+" "+n:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,153 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "a hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.interval = __bind(this.interval, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
var interval;
|
||||
interval = this.interval();
|
||||
this.$el.html(this.text(interval));
|
||||
interval = Math.abs(interval);
|
||||
if (interval < this.settings.interval) {
|
||||
interval = this.settings.interval;
|
||||
}
|
||||
return setTimeout(this.reformat, interval);
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
return new Date(this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time'));
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.round(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.interval = function() {
|
||||
return this.date() - new Date;
|
||||
};
|
||||
|
||||
Age.prototype.text = function(interval) {
|
||||
var amount, format, formatting, suffix, unit;
|
||||
if (interval == null) {
|
||||
interval = this.interval();
|
||||
}
|
||||
suffix = this.suffix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(i,n){null==n&&(n={}),this.text=e(this.text,this),this.interval=e(this.interval,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=i,this.settings=t.extend({},s.settings,n),this.reformat()}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"a hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){var t;return t=this.interval(),this.$el.html(this.text(t)),t=Math.abs(t),t<this.settings.interval&&(t=this.settings.interval),setTimeout(this.reformat,t)},s.prototype.date=function(){return new Date(this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"))},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.adjust=function(t,s){return Math.round(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,31536e6)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.settings.singular?"singular":"plural"])?e[s]:void 0},s.prototype.interval=function(){return this.date()-new Date},s.prototype.text=function(t){var s,e,i,n,r;return null==t&&(t=this.interval()),n=this.suffix(t),i=this.formatting(t),s=this.amount(i),r=this.unit(i),e=this.format(s,r),e?""+e.replace("{{unit}}",r).replace("{{amount}}",s)+" "+n:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,154 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
1.1.0
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "a hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.interval = __bind(this.interval, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
var interval;
|
||||
interval = this.interval();
|
||||
this.$el.html(this.text(interval));
|
||||
interval = Math.abs(interval);
|
||||
if (interval < this.settings.interval) {
|
||||
interval = this.settings.interval;
|
||||
}
|
||||
return setTimeout(this.reformat, interval);
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
return new Date(this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time'));
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.round(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.interval = function() {
|
||||
return this.date() - new Date;
|
||||
};
|
||||
|
||||
Age.prototype.text = function(interval) {
|
||||
var amount, format, formatting, suffix, unit;
|
||||
if (interval == null) {
|
||||
interval = this.interval();
|
||||
}
|
||||
suffix = this.suffix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(i,n){null==n&&(n={}),this.text=e(this.text,this),this.interval=e(this.interval,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=i,this.settings=t.extend({},s.settings,n),this.reformat()}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"a hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){var t;return t=this.interval(),this.$el.html(this.text(t)),t=Math.abs(t),t<this.settings.interval&&(t=this.settings.interval),setTimeout(this.reformat,t)},s.prototype.date=function(){return new Date(this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"))},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.adjust=function(t,s){return Math.round(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,31536e6)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.settings.singular?"singular":"plural"])?e[s]:void 0},s.prototype.interval=function(){return this.date()-new Date},s.prototype.text=function(t){var s,e,i,n,r;return null==t&&(t=this.interval()),n=this.suffix(t),i=this.formatting(t),s=this.amount(i),r=this.unit(i),e=this.format(s,r),e?""+e.replace("{{unit}}",r).replace("{{amount}}",s)+" "+n:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,154 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
1.1.1
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "a hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.interval = __bind(this.interval, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
var interval;
|
||||
interval = this.interval();
|
||||
this.$el.html(this.text(interval));
|
||||
interval = Math.abs(interval);
|
||||
if (interval < this.settings.interval) {
|
||||
interval = this.settings.interval;
|
||||
}
|
||||
return setTimeout(this.reformat, interval);
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
return new Date(this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time'));
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.round(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.interval = function() {
|
||||
return this.date() - new Date;
|
||||
};
|
||||
|
||||
Age.prototype.text = function(interval) {
|
||||
var amount, format, formatting, suffix, unit;
|
||||
if (interval == null) {
|
||||
interval = this.interval();
|
||||
}
|
||||
suffix = this.suffix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(i,n){null==n&&(n={}),this.text=e(this.text,this),this.interval=e(this.interval,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=i,this.settings=t.extend({},s.settings,n),this.reformat()}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"a hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){var t;return t=this.interval(),this.$el.html(this.text(t)),t=Math.abs(t),t<this.settings.interval&&(t=this.settings.interval),setTimeout(this.reformat,t)},s.prototype.date=function(){return new Date(this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"))},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.adjust=function(t,s){return Math.round(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,31536e6)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.settings.singular?"singular":"plural"])?e[s]:void 0},s.prototype.interval=function(){return this.date()-new Date},s.prototype.text=function(t){var s,e,i,n,r;return null==t&&(t=this.interval()),n=this.suffix(t),i=this.formatting(t),s=this.amount(i),r=this.unit(i),e=this.format(s,r),e?""+e.replace("{{unit}}",r).replace("{{amount}}",s)+" "+n:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,154 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
1.1.2
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "a hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.interval = __bind(this.interval, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
var interval;
|
||||
interval = this.interval();
|
||||
this.$el.html(this.text(interval));
|
||||
interval = Math.abs(interval);
|
||||
if (interval < this.settings.interval) {
|
||||
interval = this.settings.interval;
|
||||
}
|
||||
return setTimeout(this.reformat, interval);
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
return new Date(this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time'));
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.round(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.interval = function() {
|
||||
return this.date() - new Date;
|
||||
};
|
||||
|
||||
Age.prototype.text = function(interval) {
|
||||
var amount, format, formatting, suffix, unit;
|
||||
if (interval == null) {
|
||||
interval = this.interval();
|
||||
}
|
||||
suffix = this.suffix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(i,n){null==n&&(n={}),this.text=e(this.text,this),this.interval=e(this.interval,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=i,this.settings=t.extend({},s.settings,n),this.reformat()}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"a hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){var t;return t=this.interval(),this.$el.html(this.text(t)),t=Math.abs(t),t<this.settings.interval&&(t=this.settings.interval),setTimeout(this.reformat,t)},s.prototype.date=function(){return new Date(this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"))},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.adjust=function(t,s){return Math.round(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,31536e6)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.settings.singular?"singular":"plural"])?e[s]:void 0},s.prototype.interval=function(){return this.date()-new Date},s.prototype.text=function(t){var s,e,i,n,r;return null==t&&(t=this.interval()),n=this.suffix(t),i=this.formatting(t),s=this.amount(i),r=this.unit(i),e=this.format(s,r),e?""+e.replace("{{unit}}",r).replace("{{amount}}",s)+" "+n:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,154 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
1.1.3
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "a hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.interval = __bind(this.interval, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
var interval;
|
||||
interval = this.interval();
|
||||
this.$el.html(this.text(interval));
|
||||
interval = Math.abs(interval);
|
||||
if (interval < this.settings.interval) {
|
||||
interval = this.settings.interval;
|
||||
}
|
||||
return setTimeout(this.reformat, interval);
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
return new Date(this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time'));
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.round(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.interval = function() {
|
||||
return this.date() - new Date;
|
||||
};
|
||||
|
||||
Age.prototype.text = function(interval) {
|
||||
var amount, format, formatting, suffix, unit;
|
||||
if (interval == null) {
|
||||
interval = this.interval();
|
||||
}
|
||||
suffix = this.suffix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(i,n){null==n&&(n={}),this.text=e(this.text,this),this.interval=e(this.interval,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=i,this.settings=t.extend({},s.settings,n),this.reformat()}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"a hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){var t;return t=this.interval(),this.$el.html(this.text(t)),t=Math.abs(t),t<this.settings.interval&&(t=this.settings.interval),setTimeout(this.reformat,t)},s.prototype.date=function(){return new Date(this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"))},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.adjust=function(t,s){return Math.round(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,31536e6)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.settings.singular?"singular":"plural"])?e[s]:void 0},s.prototype.interval=function(){return this.date()-new Date},s.prototype.text=function(t){var s,e,i,n,r;return null==t&&(t=this.interval()),n=this.suffix(t),i=this.formatting(t),s=this.amount(i),r=this.unit(i),e=this.format(s,r),e?""+e.replace("{{unit}}",r).replace("{{amount}}",s)+" "+n:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,169 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
1.1.4
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
prefixes: {
|
||||
past: "",
|
||||
future: ""
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "a hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.interval = __bind(this.interval, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.prefix = __bind(this.prefix, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
var interval;
|
||||
interval = this.interval();
|
||||
this.$el.html(this.text(interval));
|
||||
interval = Math.abs(interval);
|
||||
if (interval < this.settings.interval) {
|
||||
interval = this.settings.interval;
|
||||
}
|
||||
return setTimeout(this.reformat, interval);
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
return new Date(this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time'));
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.prefix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.prefixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.prefixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.round(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.interval = function() {
|
||||
return this.date() - new Date;
|
||||
};
|
||||
|
||||
Age.prototype.text = function(interval) {
|
||||
var amount, format, formatting, prefix, suffix, unit;
|
||||
if (interval == null) {
|
||||
interval = this.interval();
|
||||
}
|
||||
suffix = this.suffix(interval);
|
||||
prefix = this.prefix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + prefix + " " + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(i,n){null==n&&(n={}),this.text=e(this.text,this),this.interval=e(this.interval,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.prefix=e(this.prefix,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=i,this.settings=t.extend({},s.settings,n),this.reformat()}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},prefixes:{past:"",future:""},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"a hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){var t;return t=this.interval(),this.$el.html(this.text(t)),t=Math.abs(t),t<this.settings.interval&&(t=this.settings.interval),setTimeout(this.reformat,t)},s.prototype.date=function(){return new Date(this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"))},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.prefix=function(t){return 0>t?this.settings.prefixes.past:t>0?this.settings.prefixes.future:void 0},s.prototype.adjust=function(t,s){return Math.round(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,31536e6)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.settings.singular?"singular":"plural"])?e[s]:void 0},s.prototype.interval=function(){return this.date()-new Date},s.prototype.text=function(t){var s,e,i,n,r,u;return null==t&&(t=this.interval()),r=this.suffix(t),n=this.prefix(t),i=this.formatting(t),s=this.amount(i),u=this.unit(i),e=this.format(s,u),e?""+n+" "+e.replace("{{unit}}",u).replace("{{amount}}",s)+" "+r:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,169 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
1.1.5
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
prefixes: {
|
||||
past: "",
|
||||
future: ""
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "an hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.interval = __bind(this.interval, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.prefix = __bind(this.prefix, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
var interval;
|
||||
interval = this.interval();
|
||||
this.$el.html(this.text(interval));
|
||||
interval = Math.abs(interval);
|
||||
if (interval < this.settings.interval) {
|
||||
interval = this.settings.interval;
|
||||
}
|
||||
return setTimeout(this.reformat, interval);
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
return new Date(this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time'));
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.prefix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.prefixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.prefixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.round(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.interval = function() {
|
||||
return this.date() - new Date;
|
||||
};
|
||||
|
||||
Age.prototype.text = function(interval) {
|
||||
var amount, format, formatting, prefix, suffix, unit;
|
||||
if (interval == null) {
|
||||
interval = this.interval();
|
||||
}
|
||||
suffix = this.suffix(interval);
|
||||
prefix = this.prefix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + prefix + " " + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(i,n){null==n&&(n={}),this.text=e(this.text,this),this.interval=e(this.interval,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.prefix=e(this.prefix,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=i,this.settings=t.extend({},s.settings,n),this.reformat()}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},prefixes:{past:"",future:""},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"an hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){var t;return t=this.interval(),this.$el.html(this.text(t)),t=Math.abs(t),t<this.settings.interval&&(t=this.settings.interval),setTimeout(this.reformat,t)},s.prototype.date=function(){return new Date(this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"))},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.prefix=function(t){return 0>t?this.settings.prefixes.past:t>0?this.settings.prefixes.future:void 0},s.prototype.adjust=function(t,s){return Math.round(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,31536e6)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.settings.singular?"singular":"plural"])?e[s]:void 0},s.prototype.interval=function(){return this.date()-new Date},s.prototype.text=function(t){var s,e,i,n,r,u;return null==t&&(t=this.interval()),r=this.suffix(t),n=this.prefix(t),i=this.formatting(t),s=this.amount(i),u=this.unit(i),e=this.format(s,u),e?""+n+" "+e.replace("{{unit}}",u).replace("{{amount}}",s)+" "+r:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,165 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
1.1.6
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
prefixes: {
|
||||
past: "",
|
||||
future: ""
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "an hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.interval = __bind(this.interval, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.prefix = __bind(this.prefix, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
var interval;
|
||||
interval = this.interval();
|
||||
this.$el.html(this.text(interval));
|
||||
return setTimeout(this.reformat, this.settings.interval);
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
return new Date(this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time'));
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.prefix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.prefixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.prefixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.round(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.interval = function() {
|
||||
return this.date() - new Date;
|
||||
};
|
||||
|
||||
Age.prototype.text = function(interval) {
|
||||
var amount, format, formatting, prefix, suffix, unit;
|
||||
if (interval == null) {
|
||||
interval = this.interval();
|
||||
}
|
||||
suffix = this.suffix(interval);
|
||||
prefix = this.prefix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + prefix + " " + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(i,n){null==n&&(n={}),this.text=e(this.text,this),this.interval=e(this.interval,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.prefix=e(this.prefix,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=i,this.settings=t.extend({},s.settings,n),this.reformat()}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},prefixes:{past:"",future:""},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"an hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){var t;return t=this.interval(),this.$el.html(this.text(t)),setTimeout(this.reformat,this.settings.interval)},s.prototype.date=function(){return new Date(this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"))},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.prefix=function(t){return 0>t?this.settings.prefixes.past:t>0?this.settings.prefixes.future:void 0},s.prototype.adjust=function(t,s){return Math.round(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,31536e6)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.settings.singular?"singular":"plural"])?e[s]:void 0},s.prototype.interval=function(){return this.date()-new Date},s.prototype.text=function(t){var s,e,i,n,r,u;return null==t&&(t=this.interval()),r=this.suffix(t),n=this.prefix(t),i=this.formatting(t),s=this.amount(i),u=this.unit(i),e=this.format(s,u),e?""+n+" "+e.replace("{{unit}}",u).replace("{{amount}}",s)+" "+r:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,165 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
1.1.7
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
prefixes: {
|
||||
past: "",
|
||||
future: ""
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "an hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.interval = __bind(this.interval, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.prefix = __bind(this.prefix, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
var interval;
|
||||
interval = this.interval();
|
||||
this.$el.html(this.text(interval));
|
||||
return setTimeout(this.reformat, this.settings.interval);
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
return new Date(this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time'));
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.prefix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.prefixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.prefixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.round(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.interval = function() {
|
||||
return this.date() - new Date;
|
||||
};
|
||||
|
||||
Age.prototype.text = function(interval) {
|
||||
var amount, format, formatting, prefix, suffix, unit;
|
||||
if (interval == null) {
|
||||
interval = this.interval();
|
||||
}
|
||||
suffix = this.suffix(interval);
|
||||
prefix = this.prefix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + prefix + " " + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(i,n){null==n&&(n={}),this.text=e(this.text,this),this.interval=e(this.interval,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.prefix=e(this.prefix,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=i,this.settings=t.extend({},s.settings,n),this.reformat()}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},prefixes:{past:"",future:""},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"an hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){var t;return t=this.interval(),this.$el.html(this.text(t)),setTimeout(this.reformat,this.settings.interval)},s.prototype.date=function(){return new Date(this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"))},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.prefix=function(t){return 0>t?this.settings.prefixes.past:t>0?this.settings.prefixes.future:void 0},s.prototype.adjust=function(t,s){return Math.round(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,31536e6)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.settings.singular?"singular":"plural"])?e[s]:void 0},s.prototype.interval=function(){return this.date()-new Date},s.prototype.text=function(t){var s,e,i,n,r,u;return null==t&&(t=this.interval()),r=this.suffix(t),n=this.prefix(t),i=this.formatting(t),s=this.amount(i),u=this.unit(i),e=this.format(s,u),e?""+n+" "+e.replace("{{unit}}",u).replace("{{amount}}",s)+" "+r:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,165 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
1.1.8
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
prefixes: {
|
||||
past: "",
|
||||
future: ""
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "an hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.interval = __bind(this.interval, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.prefix = __bind(this.prefix, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
var interval;
|
||||
interval = this.interval();
|
||||
this.$el.html(this.text(interval));
|
||||
return setTimeout(this.reformat, this.settings.interval);
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
return new Date(this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time'));
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.prefix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.prefixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.prefixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.floor(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref;
|
||||
return (_ref = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.interval = function() {
|
||||
return this.date() - new Date;
|
||||
};
|
||||
|
||||
Age.prototype.text = function(interval) {
|
||||
var amount, format, formatting, prefix, suffix, unit;
|
||||
if (interval == null) {
|
||||
interval = this.interval();
|
||||
}
|
||||
suffix = this.suffix(interval);
|
||||
prefix = this.prefix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + prefix + " " + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(i,n){null==n&&(n={}),this.text=e(this.text,this),this.interval=e(this.interval,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.prefix=e(this.prefix,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=i,this.settings=t.extend({},s.settings,n),this.reformat()}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},prefixes:{past:"",future:""},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"an hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"}}},s.prototype.reformat=function(){var t;return t=this.interval(),this.$el.html(this.text(t)),setTimeout(this.reformat,this.settings.interval)},s.prototype.date=function(){return new Date(this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"))},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.prefix=function(t){return 0>t?this.settings.prefixes.past:t>0?this.settings.prefixes.future:void 0},s.prototype.adjust=function(t,s){return Math.floor(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,31536e6)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e;return null!=(e=this.settings.formats[t===this.settings.singular?"singular":"plural"])?e[s]:void 0},s.prototype.interval=function(){return this.date()-new Date},s.prototype.text=function(t){var s,e,i,n,r,u;return null==t&&(t=this.interval()),r=this.suffix(t),n=this.prefix(t),i=this.formatting(t),s=this.amount(i),u=this.unit(i),e=this.format(s,u),e?""+n+" "+e.replace("{{unit}}",u).replace("{{amount}}",s)+" "+r:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,177 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
1.1.9
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
prefixes: {
|
||||
past: "",
|
||||
future: ""
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "an hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
},
|
||||
tiny: {
|
||||
seconds: "{{amount}}s",
|
||||
minutes: "{{amount}}m",
|
||||
hours: "{{amount}}h",
|
||||
days: "{{amount}}d",
|
||||
weeks: "{{amount}}w",
|
||||
months: "{{amount}}m",
|
||||
years: "{{amount}}y"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.interval = __bind(this.interval, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.prefix = __bind(this.prefix, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
var interval;
|
||||
interval = this.interval();
|
||||
this.$el.html(this.text(interval));
|
||||
return setTimeout(this.reformat, this.settings.interval);
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
return new Date(this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time'));
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.prefix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.prefixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.prefixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.floor(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref, _ref1;
|
||||
if (this.settings.style != null) {
|
||||
return (_ref = this.settings.formats[this.settings.style]) != null ? _ref[unit] : void 0;
|
||||
}
|
||||
return (_ref1 = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref1[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.interval = function() {
|
||||
return this.date() - new Date;
|
||||
};
|
||||
|
||||
Age.prototype.text = function(interval) {
|
||||
var amount, format, formatting, prefix, suffix, unit;
|
||||
if (interval == null) {
|
||||
interval = this.interval();
|
||||
}
|
||||
suffix = this.suffix(interval);
|
||||
prefix = this.prefix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return "" + prefix + " " + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix;
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(i,n){null==n&&(n={}),this.text=e(this.text,this),this.interval=e(this.interval,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.prefix=e(this.prefix,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=i,this.settings=t.extend({},s.settings,n),this.reformat()}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},prefixes:{past:"",future:""},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"an hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"},tiny:{seconds:"{{amount}}s",minutes:"{{amount}}m",hours:"{{amount}}h",days:"{{amount}}d",weeks:"{{amount}}w",months:"{{amount}}m",years:"{{amount}}y"}}},s.prototype.reformat=function(){var t;return t=this.interval(),this.$el.html(this.text(t)),setTimeout(this.reformat,this.settings.interval)},s.prototype.date=function(){return new Date(this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"))},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.prefix=function(t){return 0>t?this.settings.prefixes.past:t>0?this.settings.prefixes.future:void 0},s.prototype.adjust=function(t,s){return Math.floor(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,31536e6)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e,i;return null!=this.settings.style?null!=(e=this.settings.formats[this.settings.style])?e[s]:void 0:null!=(i=this.settings.formats[t===this.settings.singular?"singular":"plural"])?i[s]:void 0},s.prototype.interval=function(){return this.date()-new Date},s.prototype.text=function(t){var s,e,i,n,r,u;return null==t&&(t=this.interval()),r=this.suffix(t),n=this.prefix(t),i=this.formatting(t),s=this.amount(i),u=this.unit(i),e=this.format(s,u),e?""+n+" "+e.replace("{{unit}}",u).replace("{{amount}}",s)+" "+r:this.settings.formats.now},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,183 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
1.2.1
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
prefixes: {
|
||||
past: "",
|
||||
future: ""
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "an hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
},
|
||||
tiny: {
|
||||
seconds: "{{amount}}s",
|
||||
minutes: "{{amount}}m",
|
||||
hours: "{{amount}}h",
|
||||
days: "{{amount}}d",
|
||||
weeks: "{{amount}}w",
|
||||
months: "{{amount}}m",
|
||||
years: "{{amount}}y"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.interval = __bind(this.interval, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.prefix = __bind(this.prefix, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
var interval;
|
||||
interval = this.interval();
|
||||
this.$el.html(this.text(interval));
|
||||
return setTimeout(this.reformat, this.settings.interval);
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
return new Date(this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time'));
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.prefix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.prefixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.prefixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.floor(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref, _ref1;
|
||||
if (this.settings.style != null) {
|
||||
return (_ref = this.settings.formats[this.settings.style]) != null ? _ref[unit] : void 0;
|
||||
}
|
||||
return (_ref1 = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref1[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.interval = function() {
|
||||
return this.date() - new Date;
|
||||
};
|
||||
|
||||
Age.prototype.text = function(interval) {
|
||||
var amount, format, formatting, prefix, suffix, unit;
|
||||
if (interval == null) {
|
||||
interval = this.interval();
|
||||
}
|
||||
if (interval > 0 && (this.settings.pending != null)) {
|
||||
return this.settings.pending;
|
||||
}
|
||||
if (interval < 0 && (this.settings.expired != null)) {
|
||||
return this.settings.expired;
|
||||
}
|
||||
suffix = this.suffix(interval);
|
||||
prefix = this.prefix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return ("" + prefix + " " + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix).trim();
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(i,n){null==n&&(n={}),this.text=e(this.text,this),this.interval=e(this.interval,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.prefix=e(this.prefix,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=i,this.settings=t.extend({},s.settings,n),this.reformat()}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},prefixes:{past:"",future:""},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"an hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"},tiny:{seconds:"{{amount}}s",minutes:"{{amount}}m",hours:"{{amount}}h",days:"{{amount}}d",weeks:"{{amount}}w",months:"{{amount}}m",years:"{{amount}}y"}}},s.prototype.reformat=function(){var t;return t=this.interval(),this.$el.html(this.text(t)),setTimeout(this.reformat,this.settings.interval)},s.prototype.date=function(){return new Date(this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"))},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.prefix=function(t){return 0>t?this.settings.prefixes.past:t>0?this.settings.prefixes.future:void 0},s.prototype.adjust=function(t,s){return Math.floor(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,31536e6)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e,i;return null!=this.settings.style?null!=(e=this.settings.formats[this.settings.style])?e[s]:void 0:null!=(i=this.settings.formats[t===this.settings.singular?"singular":"plural"])?i[s]:void 0},s.prototype.interval=function(){return this.date()-new Date},s.prototype.text=function(t){var s,e,i,n,r,u;return null==t&&(t=this.interval()),t>0&&null!=this.settings.pending?this.settings.pending:0>t&&null!=this.settings.expired?this.settings.expired:(r=this.suffix(t),n=this.prefix(t),i=this.formatting(t),s=this.amount(i),u=this.unit(i),e=this.format(s,u),e?(""+n+" "+e.replace("{{unit}}",u).replace("{{amount}}",s)+" "+r).trim():this.settings.formats.now)},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,183 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
1.2.2
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
prefixes: {
|
||||
past: "",
|
||||
future: ""
|
||||
},
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "an hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
},
|
||||
tiny: {
|
||||
seconds: "{{amount}}s",
|
||||
minutes: "{{amount}}m",
|
||||
hours: "{{amount}}h",
|
||||
days: "{{amount}}d",
|
||||
weeks: "{{amount}}w",
|
||||
months: "{{amount}}m",
|
||||
years: "{{amount}}y"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.interval = __bind(this.interval, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.prefix = __bind(this.prefix, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
var interval;
|
||||
interval = this.interval();
|
||||
this.$el.html(this.text(interval));
|
||||
return setTimeout(this.reformat, this.settings.interval);
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
return new Date(this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time'));
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.prefix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.prefixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.prefixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.floor(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting.years || formatting.months || formatting.weeks || formatting.days || formatting.hours || formatting.minutes || formatting.seconds || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
return (formatting.years && "years") || (formatting.months && "months") || (formatting.weeks && "weeks") || (formatting.days && "days") || (formatting.hours && "hours") || (formatting.minutes && "minutes") || (formatting.seconds && "seconds") || void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref, _ref1;
|
||||
if (this.settings.style != null) {
|
||||
return (_ref = this.settings.formats[this.settings.style]) != null ? _ref[unit] : void 0;
|
||||
}
|
||||
return (_ref1 = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref1[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.interval = function() {
|
||||
return this.date() - new Date;
|
||||
};
|
||||
|
||||
Age.prototype.text = function(interval) {
|
||||
var amount, format, formatting, prefix, suffix, unit;
|
||||
if (interval == null) {
|
||||
interval = this.interval();
|
||||
}
|
||||
if (interval > 0 && (this.settings.pending != null)) {
|
||||
return this.settings.pending;
|
||||
}
|
||||
if (interval < 0 && (this.settings.expired != null)) {
|
||||
return this.settings.expired;
|
||||
}
|
||||
suffix = this.suffix(interval);
|
||||
prefix = this.prefix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return ("" + prefix + " " + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix).trim();
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,e=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(i,n){null==n&&(n={}),this.text=e(this.text,this),this.interval=e(this.interval,this),this.format=e(this.format,this),this.unit=e(this.unit,this),this.amount=e(this.amount,this),this.formatting=e(this.formatting,this),this.adjust=e(this.adjust,this),this.prefix=e(this.prefix,this),this.suffix=e(this.suffix,this),this.date=e(this.date,this),this.reformat=e(this.reformat,this),this.$el=i,this.settings=t.extend({},s.settings,n),this.reformat()}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},prefixes:{past:"",future:""},formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"an hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"},tiny:{seconds:"{{amount}}s",minutes:"{{amount}}m",hours:"{{amount}}h",days:"{{amount}}d",weeks:"{{amount}}w",months:"{{amount}}m",years:"{{amount}}y"}}},s.prototype.reformat=function(){var t;return t=this.interval(),this.$el.html(this.text(t)),setTimeout(this.reformat,this.settings.interval)},s.prototype.date=function(){return new Date(this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"))},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.prefix=function(t){return 0>t?this.settings.prefixes.past:t>0?this.settings.prefixes.future:void 0},s.prototype.adjust=function(t,s){return Math.floor(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,31536e6)}},s.prototype.amount=function(t){return t.years||t.months||t.weeks||t.days||t.hours||t.minutes||t.seconds||0},s.prototype.unit=function(t){return t.years&&"years"||t.months&&"months"||t.weeks&&"weeks"||t.days&&"days"||t.hours&&"hours"||t.minutes&&"minutes"||t.seconds&&"seconds"||void 0},s.prototype.format=function(t,s){var e,i;return null!=this.settings.style?null!=(e=this.settings.formats[this.settings.style])?e[s]:void 0:null!=(i=this.settings.formats[t===this.settings.singular?"singular":"plural"])?i[s]:void 0},s.prototype.interval=function(){return this.date()-new Date},s.prototype.text=function(t){var s,e,i,n,r,u;return null==t&&(t=this.interval()),t>0&&null!=this.settings.pending?this.settings.pending:0>t&&null!=this.settings.expired?this.settings.expired:(r=this.suffix(t),n=this.prefix(t),i=this.formatting(t),s=this.amount(i),u=this.unit(i),e=this.format(s,u),e?(""+n+" "+e.replace("{{unit}}",u).replace("{{amount}}",s)+" "+r).trim():this.settings.formats.now)},s}(),t.fn.extend({age:function(e){return null==e&&(e={}),this.each(function(){return new s(t(this),e)})}})}).call(this);
|
||||
@@ -0,0 +1,192 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/*
|
||||
jQuery Age
|
||||
Copyright 2013 Kevin Sylvestre
|
||||
1.2.3
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var $, Age,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Age = (function() {
|
||||
Age.settings = {
|
||||
singular: 1,
|
||||
interval: 1000,
|
||||
suffixes: {
|
||||
past: "ago",
|
||||
future: "until"
|
||||
},
|
||||
prefixes: {
|
||||
past: "",
|
||||
future: ""
|
||||
},
|
||||
units: ["years", "months", "weeks", "days", "hours", "minutes", "seconds"],
|
||||
formats: {
|
||||
now: "now",
|
||||
singular: {
|
||||
seconds: "a second",
|
||||
minutes: "a minute",
|
||||
hours: "an hour",
|
||||
days: "a day",
|
||||
weeks: "a week",
|
||||
months: "a month",
|
||||
years: "a year"
|
||||
},
|
||||
plural: {
|
||||
seconds: "{{amount}} seconds",
|
||||
minutes: "{{amount}} minutes",
|
||||
hours: "{{amount}} hours",
|
||||
days: "{{amount}} days",
|
||||
weeks: "{{amount}} weeks",
|
||||
months: "{{amount}} months",
|
||||
years: "{{amount}} years"
|
||||
},
|
||||
tiny: {
|
||||
seconds: "{{amount}}s",
|
||||
minutes: "{{amount}}m",
|
||||
hours: "{{amount}}h",
|
||||
days: "{{amount}}d",
|
||||
weeks: "{{amount}}w",
|
||||
months: "{{amount}}m",
|
||||
years: "{{amount}}y"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Age($el, settings) {
|
||||
if (settings == null) {
|
||||
settings = {};
|
||||
}
|
||||
this.text = __bind(this.text, this);
|
||||
this.interval = __bind(this.interval, this);
|
||||
this.format = __bind(this.format, this);
|
||||
this.unit = __bind(this.unit, this);
|
||||
this.amount = __bind(this.amount, this);
|
||||
this.formatting = __bind(this.formatting, this);
|
||||
this.adjust = __bind(this.adjust, this);
|
||||
this.prefix = __bind(this.prefix, this);
|
||||
this.suffix = __bind(this.suffix, this);
|
||||
this.date = __bind(this.date, this);
|
||||
this.reformat = __bind(this.reformat, this);
|
||||
this.$el = $el;
|
||||
this.settings = $.extend({}, Age.settings, settings);
|
||||
this.reformat();
|
||||
}
|
||||
|
||||
Age.prototype.reformat = function() {
|
||||
var interval;
|
||||
interval = this.interval();
|
||||
this.$el.html(this.text(interval));
|
||||
return setTimeout(this.reformat, this.settings.interval);
|
||||
};
|
||||
|
||||
Age.prototype.date = function() {
|
||||
return new Date(this.$el.attr('datetime') || this.$el.attr('date') || this.$el.attr('time'));
|
||||
};
|
||||
|
||||
Age.prototype.suffix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.suffixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.suffixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.prefix = function(interval) {
|
||||
if (interval < 0) {
|
||||
return this.settings.prefixes.past;
|
||||
}
|
||||
if (interval > 0) {
|
||||
return this.settings.prefixes.future;
|
||||
}
|
||||
};
|
||||
|
||||
Age.prototype.adjust = function(interval, scale) {
|
||||
return Math.floor(Math.abs(interval / scale));
|
||||
};
|
||||
|
||||
Age.prototype.formatting = function(interval) {
|
||||
return {
|
||||
seconds: this.adjust(interval, 1000),
|
||||
minutes: this.adjust(interval, 1000 * 60),
|
||||
hours: this.adjust(interval, 1000 * 60 * 60),
|
||||
days: this.adjust(interval, 1000 * 60 * 60 * 24),
|
||||
weeks: this.adjust(interval, 1000 * 60 * 60 * 24 * 7),
|
||||
months: this.adjust(interval, 1000 * 60 * 60 * 24 * 30),
|
||||
years: this.adjust(interval, 1000 * 60 * 60 * 24 * 365)
|
||||
};
|
||||
};
|
||||
|
||||
Age.prototype.amount = function(formatting) {
|
||||
return formatting[this.unit(formatting)] || 0;
|
||||
};
|
||||
|
||||
Age.prototype.unit = function(formatting) {
|
||||
var unit, _i, _len, _ref;
|
||||
_ref = this.settings.units;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
unit = _ref[_i];
|
||||
if (formatting[unit] > 0) {
|
||||
return unit;
|
||||
}
|
||||
}
|
||||
return void 0;
|
||||
};
|
||||
|
||||
Age.prototype.format = function(amount, unit) {
|
||||
var _ref, _ref1;
|
||||
if (this.settings.style != null) {
|
||||
return (_ref = this.settings.formats[this.settings.style]) != null ? _ref[unit] : void 0;
|
||||
}
|
||||
return (_ref1 = this.settings.formats[amount === this.settings.singular ? 'singular' : 'plural']) != null ? _ref1[unit] : void 0;
|
||||
};
|
||||
|
||||
Age.prototype.interval = function() {
|
||||
return this.date() - new Date;
|
||||
};
|
||||
|
||||
Age.prototype.text = function(interval) {
|
||||
var amount, format, formatting, prefix, suffix, unit;
|
||||
if (interval == null) {
|
||||
interval = this.interval();
|
||||
}
|
||||
if (interval > 0 && (this.settings.pending != null)) {
|
||||
return this.settings.pending;
|
||||
}
|
||||
if (interval < 0 && (this.settings.expired != null)) {
|
||||
return this.settings.expired;
|
||||
}
|
||||
suffix = this.suffix(interval);
|
||||
prefix = this.prefix(interval);
|
||||
formatting = this.formatting(interval);
|
||||
amount = this.amount(formatting);
|
||||
unit = this.unit(formatting);
|
||||
format = this.format(amount, unit);
|
||||
if (!format) {
|
||||
return this.settings.formats.now;
|
||||
}
|
||||
return ("" + prefix + " " + (format.replace('{{unit}}', unit).replace('{{amount}}', amount)) + " " + suffix).trim();
|
||||
};
|
||||
|
||||
return Age;
|
||||
|
||||
})();
|
||||
|
||||
$.fn.extend({
|
||||
age: function(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
return this.each(function() {
|
||||
return new Age($(this), options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
(function(){"use strict";var t,s,i=function(t,s){return function(){return t.apply(s,arguments)}};t=jQuery,s=function(){function s(e,n){null==n&&(n={}),this.text=i(this.text,this),this.interval=i(this.interval,this),this.format=i(this.format,this),this.unit=i(this.unit,this),this.amount=i(this.amount,this),this.formatting=i(this.formatting,this),this.adjust=i(this.adjust,this),this.prefix=i(this.prefix,this),this.suffix=i(this.suffix,this),this.date=i(this.date,this),this.reformat=i(this.reformat,this),this.$el=e,this.settings=t.extend({},s.settings,n),this.reformat()}return s.settings={singular:1,interval:1e3,suffixes:{past:"ago",future:"until"},prefixes:{past:"",future:""},units:["years","months","weeks","days","hours","minutes","seconds"],formats:{now:"now",singular:{seconds:"a second",minutes:"a minute",hours:"an hour",days:"a day",weeks:"a week",months:"a month",years:"a year"},plural:{seconds:"{{amount}} seconds",minutes:"{{amount}} minutes",hours:"{{amount}} hours",days:"{{amount}} days",weeks:"{{amount}} weeks",months:"{{amount}} months",years:"{{amount}} years"},tiny:{seconds:"{{amount}}s",minutes:"{{amount}}m",hours:"{{amount}}h",days:"{{amount}}d",weeks:"{{amount}}w",months:"{{amount}}m",years:"{{amount}}y"}}},s.prototype.reformat=function(){var t;return t=this.interval(),this.$el.html(this.text(t)),setTimeout(this.reformat,this.settings.interval)},s.prototype.date=function(){return new Date(this.$el.attr("datetime")||this.$el.attr("date")||this.$el.attr("time"))},s.prototype.suffix=function(t){return 0>t?this.settings.suffixes.past:t>0?this.settings.suffixes.future:void 0},s.prototype.prefix=function(t){return 0>t?this.settings.prefixes.past:t>0?this.settings.prefixes.future:void 0},s.prototype.adjust=function(t,s){return Math.floor(Math.abs(t/s))},s.prototype.formatting=function(t){return{seconds:this.adjust(t,1e3),minutes:this.adjust(t,6e4),hours:this.adjust(t,36e5),days:this.adjust(t,864e5),weeks:this.adjust(t,6048e5),months:this.adjust(t,2592e6),years:this.adjust(t,31536e6)}},s.prototype.amount=function(t){return t[this.unit(t)]||0},s.prototype.unit=function(t){var s,i,e,n;for(n=this.settings.units,i=0,e=n.length;e>i;i++)if(s=n[i],t[s]>0)return s;return void 0},s.prototype.format=function(t,s){var i,e;return null!=this.settings.style?null!=(i=this.settings.formats[this.settings.style])?i[s]:void 0:null!=(e=this.settings.formats[t===this.settings.singular?"singular":"plural"])?e[s]:void 0},s.prototype.interval=function(){return this.date()-new Date},s.prototype.text=function(t){var s,i,e,n,r,u;return null==t&&(t=this.interval()),t>0&&null!=this.settings.pending?this.settings.pending:0>t&&null!=this.settings.expired?this.settings.expired:(r=this.suffix(t),n=this.prefix(t),e=this.formatting(t),s=this.amount(e),u=this.unit(e),i=this.format(s,u),i?(""+n+" "+i.replace("{{unit}}",u).replace("{{amount}}",s)+" "+r).trim():this.settings.formats.now)},s}(),t.fn.extend({age:function(i){return null==i&&(i={}),this.each(function(){return new s(t(this),i)})}})}).call(this);
|
||||
Reference in New Issue
Block a user