|
|
@ -1,43 +1,48 @@
|
|
|
|
'use strict';
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
define(['app','handlebars','Shared/FormatHelpers'], function (App,Handlebars) {
|
|
|
|
define(
|
|
|
|
Handlebars.registerHelper('partial', function (templateName) {
|
|
|
|
[
|
|
|
|
//TODO: We should be able to pass in the context, either an object or a property
|
|
|
|
'app',
|
|
|
|
|
|
|
|
'handlebars',
|
|
|
|
var templateFunction = Marionette.TemplateCache.get(templateName);
|
|
|
|
'Shared/FormatHelpers'
|
|
|
|
return new Handlebars.SafeString(templateFunction(this));
|
|
|
|
], function (App, Handlebars) {
|
|
|
|
});
|
|
|
|
Handlebars.registerHelper('partial', function (templateName) {
|
|
|
|
|
|
|
|
//TODO: We should be able to pass in the context, either an object or a property
|
|
|
|
Handlebars.registerHelper('debug', function (optionalValue) {
|
|
|
|
|
|
|
|
console.log('Current Context');
|
|
|
|
var templateFunction = Marionette.TemplateCache.get(templateName);
|
|
|
|
console.log('====================');
|
|
|
|
return new Handlebars.SafeString(templateFunction(this));
|
|
|
|
console.log(this);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (optionalValue) {
|
|
|
|
Handlebars.registerHelper('debug', function (optionalValue) {
|
|
|
|
console.log('Value');
|
|
|
|
console.log('Current Context');
|
|
|
|
console.log('====================');
|
|
|
|
console.log('====================');
|
|
|
|
console.log(optionalValue);
|
|
|
|
console.log(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
if (optionalValue) {
|
|
|
|
|
|
|
|
console.log('Value');
|
|
|
|
Handlebars.registerHelper('fileSize', function (size) {
|
|
|
|
console.log('====================');
|
|
|
|
return new Handlebars.SafeString(NzbDrone.Shared.FormatHelpers.FileSizeHelper(size));
|
|
|
|
console.log(optionalValue);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
Handlebars.registerHelper('date', function (date) {
|
|
|
|
|
|
|
|
//TODO: show actual date in tooltip
|
|
|
|
Handlebars.registerHelper('fileSize', function (size) {
|
|
|
|
if (!date) {
|
|
|
|
return new Handlebars.SafeString(NzbDrone.Shared.FormatHelpers.FileSizeHelper(size));
|
|
|
|
return '';
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper('date', function (date) {
|
|
|
|
var shortDate = Date.create(date).short();
|
|
|
|
//TODO: show actual date in tooltip
|
|
|
|
var formattedDate = NzbDrone.Shared.FormatHelpers.DateHelper(date);
|
|
|
|
if (!date) {
|
|
|
|
var result = '<span title='' + shortDate + ''>' + formattedDate + '</span>';
|
|
|
|
return '';
|
|
|
|
|
|
|
|
}
|
|
|
|
return new Handlebars.SafeString(result);
|
|
|
|
|
|
|
|
});
|
|
|
|
var shortDate = Date.create(date).short();
|
|
|
|
|
|
|
|
var formattedDate = NzbDrone.Shared.FormatHelpers.DateHelper(date);
|
|
|
|
Handlebars.registerHelper('defaultImg', function () {
|
|
|
|
var result = '<span title="' + shortDate + '">' + formattedDate + '</span>';
|
|
|
|
return new Handlebars.SafeString('onerror='this.src=\'/content/images/poster-dark.jpg\';'');
|
|
|
|
|
|
|
|
|
|
|
|
return new Handlebars.SafeString(result);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper('defaultImg', function () {
|
|
|
|
|
|
|
|
return new Handlebars.SafeString('onerror="this.src="/content/images/poster-dark.jpg";"');
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|