parent
1fb944976e
commit
626d48c8ea
@ -1,24 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
Handlebars.registerHelper('partial', function (templateName) {
|
||||
//TODO: We should be able to pass in the context, either an object or a property
|
||||
|
||||
var templateFunction = Marionette.TemplateCache.get(templateName);
|
||||
return new Handlebars.SafeString(templateFunction(this));
|
||||
});
|
||||
|
||||
Handlebars.registerHelper("debug", function(optionalValue) {
|
||||
console.log("Current Context");
|
||||
console.log("====================");
|
||||
console.log(this);
|
||||
|
||||
if (optionalValue) {
|
||||
console.log("Value");
|
||||
console.log("====================");
|
||||
console.log(optionalValue);
|
||||
}
|
||||
});
|
||||
|
||||
Handlebars.registerHelper("fileSize", function(size) {
|
||||
return size.bytes(1);
|
||||
});
|
@ -1,29 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
//TODO: global function, not good!
|
||||
function bestDateString(sourceDate) {
|
||||
if (!sourceDate) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var date = Date.create(sourceDate);
|
||||
|
||||
if (date.isYesterday()) {
|
||||
return 'Yesterday';
|
||||
}
|
||||
if (date.isToday()) {
|
||||
return 'Today';
|
||||
}
|
||||
if (date.isTomorrow()) {
|
||||
return 'Tomorrow';
|
||||
}
|
||||
if (date.isAfter(Date.create('tomorrow')) && date.isBefore(Date.create().addDays(7))) {
|
||||
return date.format('{Weekday}');
|
||||
}
|
||||
|
||||
if (date.isAfter(Date.create().addDays(6))) {
|
||||
return date.relative().replace(' from now', '');
|
||||
}
|
||||
|
||||
return date.format('{MM}/{dd}/{yyyy}');
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
|
||||
define(['app'], function () {
|
||||
NzbDrone.Shared.FormatHelpers.FileSizeHelper = function (sourceSize) {
|
||||
var size = Number(sourceSize);
|
||||
this.$el.html(size.bytes(1));
|
||||
return this;
|
||||
};
|
||||
|
||||
NzbDrone.Shared.FormatHelpers.DateHelper = function (sourceDate) {
|
||||
if (!sourceDate) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var date = Date.create(sourceDate);
|
||||
|
||||
if (date.isYesterday()) {
|
||||
return 'Yesterday';
|
||||
}
|
||||
if (date.isToday()) {
|
||||
return 'Today';
|
||||
}
|
||||
if (date.isTomorrow()) {
|
||||
return 'Tomorrow';
|
||||
}
|
||||
if (date.isAfter(Date.create('tomorrow')) && date.isBefore(Date.create().addDays(7))) {
|
||||
return date.format('{Weekday}');
|
||||
}
|
||||
|
||||
if (date.isAfter(Date.create().addDays(6))) {
|
||||
return date.relative().replace(' from now', '');
|
||||
}
|
||||
|
||||
return date.format('{MM}/{dd}/{yyyy}');
|
||||
};
|
||||
});
|
@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
|
||||
define(['app'], function () {
|
||||
Handlebars.registerHelper('partial', function (templateName) {
|
||||
//TODO: We should be able to pass in the context, either an object or a property
|
||||
|
||||
var templateFunction = Marionette.TemplateCache.get(templateName);
|
||||
return new Handlebars.SafeString(templateFunction(this));
|
||||
});
|
||||
|
||||
Handlebars.registerHelper("debug", function(optionalValue) {
|
||||
console.log("Current Context");
|
||||
console.log("====================");
|
||||
console.log(this);
|
||||
|
||||
if (optionalValue) {
|
||||
console.log("Value");
|
||||
console.log("====================");
|
||||
console.log(optionalValue);
|
||||
}
|
||||
});
|
||||
|
||||
Handlebars.registerHelper("fileSize", function(size) {
|
||||
return NzbDrone.Shared.FormatHelpers.FileSizeHelper(size);
|
||||
});
|
||||
|
||||
Handlebars.registerHelper("date", function(date) {
|
||||
//TODO: show actual date in tooltip
|
||||
if (!date) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var shortDate = Date.create(date).short();
|
||||
var formattedDate = NzbDrone.Shared.FormatHelpers.DateHelper(date);
|
||||
var result = '<div title="' + shortDate + '">' + formattedDate + '</div >';
|
||||
|
||||
return new Handlebars.SafeString(result);
|
||||
});
|
||||
});
|
Loading…
Reference in new issue