mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-21 22:04:31 -04:00
rjs -> webpack
This commit is contained in:
+28
-40
@@ -1,41 +1,29 @@
|
||||
define(
|
||||
[
|
||||
'moment',
|
||||
'backgrid',
|
||||
'Shared/UiSettingsModel',
|
||||
'Shared/FormatHelpers'
|
||||
], function (moment, Backgrid, UiSettings) {
|
||||
return Backgrid.Cell.extend({
|
||||
var moment = require('moment');
|
||||
var Backgrid = require('backgrid');
|
||||
var UiSettings = require('../Shared/UiSettingsModel');
|
||||
require('../Shared/FormatHelpers');
|
||||
|
||||
className: 'age-cell',
|
||||
|
||||
render: function () {
|
||||
var age = this.model.get('age');
|
||||
var ageHours = this.model.get('ageHours');
|
||||
var published = moment(this.model.get('publishDate'));
|
||||
var publishedFormatted = published.format('{0} {1}'.format(UiSettings.get('shortDateFormat'), UiSettings.time(true, true)));
|
||||
var formatted = age;
|
||||
var suffix = this.plural(age, 'day');
|
||||
|
||||
if (age === 0) {
|
||||
formatted = ageHours.toFixed(1);
|
||||
suffix = this.plural(Math.round(ageHours), 'hour');
|
||||
}
|
||||
|
||||
this.$el.html('<div title="{2}">{0} {1}</div>'.format(formatted, suffix, publishedFormatted));
|
||||
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
},
|
||||
|
||||
plural: function (input, unit) {
|
||||
if (input === 1) {
|
||||
return unit;
|
||||
}
|
||||
|
||||
return unit + 's';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
'use strict';
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
className : 'age-cell',
|
||||
render : function(){
|
||||
var age = this.model.get('age');
|
||||
var ageHours = this.model.get('ageHours');
|
||||
var published = moment(this.model.get('publishDate'));
|
||||
var publishedFormatted = published.format('{0} {1}'.format(UiSettings.get('shortDateFormat'), UiSettings.time(true, true)));
|
||||
var formatted = age;
|
||||
var suffix = this.plural(age, 'day');
|
||||
if(age === 0) {
|
||||
formatted = ageHours.toFixed(1);
|
||||
suffix = this.plural(Math.round(ageHours), 'hour');
|
||||
}
|
||||
this.$el.html('<div title="{2}">{0} {1}</div>'.format(formatted, suffix, publishedFormatted));
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
},
|
||||
plural : function(input, unit){
|
||||
if(input === 1) {
|
||||
return unit;
|
||||
}
|
||||
return unit + 's';
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user