cleaned up template helpers

pull/3113/head
kay.one 12 years ago
parent d7fbfec01e
commit 8841e43c25

@ -4,7 +4,7 @@
<option name="myLocal" value="false" />
<inspection_tool class="AssignmentResultUsedJS" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AssignmentToForLoopParameterJS" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="AssignmentToFunctionParameterJS" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="AssignmentToFunctionParameterJS" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="BadExpressionStatementJS" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="BreakStatementJS" enabled="true" level="SERVER PROBLEM" enabled_by_default="true" />
<inspection_tool class="BreakStatementWithLabelJS" enabled="true" level="ERROR" enabled_by_default="true" />
@ -67,7 +67,6 @@
<option name="m_limit" value="3" />
</inspection_tool>
<inspection_tool class="JSDuplicatedDeclaration" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="JSHint" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="JSLastCommaInArrayLiteral" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="JSPotentiallyInvalidUsageOfThis" enabled="true" level="SERVER PROBLEM" enabled_by_default="true" />
<inspection_tool class="JSUndeclaredVariable" enabled="true" level="ERROR" enabled_by_default="true" />

@ -0,0 +1,3 @@
<component name="DependencyValidationManager">
<scope name="NzbDrone" pattern="!file:JsLibraries//*" />
</component>

@ -6,5 +6,5 @@
<a href="{{series.route}}">
<h4>{{series.title}}</h4>
</a>
<p>{{startTime}} {{date airDate}}<span class="pull-right">{{seasonNumber}}x{{paddedEpisodeNumber}}</span><br>{{episodeTitle}}</p>
<p>{{startTime}} {{ShortDate airDate}}<span class="pull-right">{{seasonNumber}}x{{paddedEpisodeNumber}}</span><br>{{episodeTitle}}</p>
</div>

@ -11,7 +11,7 @@ define(
render: function () {
var size = this.model.get(this.column.get('name'));
this.$el.html(FormatHelpers.FileSizeHelper(size));
this.$el.html(FormatHelpers.Bytes(size));
this.delegateEvents();
return this;
}

@ -15,7 +15,7 @@
<tbody>
<tr>
<td>{{path}}</td>
<td>{{fileSize size}}</td>
<td>{{Byte size}}</td>
<td>{{quality.quality.name}}</td>
</tr>
</tbody>

@ -1,10 +1,10 @@
'use strict';
define(
[
'handlebars',
'sugar'
], {
register: function (handlebars) {
handlebars.registerHelper('ShortDate', function (input) {
], function (Handlebars) {
Handlebars.registerHelper('ShortDate', function (input) {
if (!input) {
return '';
}
@ -12,7 +12,6 @@ define(
var date = Date.create(input);
var result = '<span title="' + date.full() + '">' + date.short() + '</span>';
return new handlebars.SafeString(result);
return new Handlebars.SafeString(result);
});
}
});

@ -0,0 +1,10 @@
'use strict';
define(
[
'handlebars'
], function (Handlebars) {
Handlebars.registerHelper('defaultImg', function () {
return new Handlebars.SafeString('onerror="this.src="/content/images/poster-dark.jpg";"');
});
});

@ -0,0 +1,10 @@
'use strict';
define(
[
'handlebars',
'Shared/FormatHelpers'
], function (Handlebars, FormatHelpers) {
Handlebars.registerHelper('Bytes', function (size) {
return new Handlebars.SafeString(FormatHelpers.Bytes(size));
});
});

@ -1,8 +1,11 @@
'use strict';
'use strict';
define(
[
'templates'
'templates',
'Handlebars/Helpers/DateTime',
'Handlebars/Helpers/Html',
'Handlebars/Helpers/Numbers',
'Handlebars/Debug'
], function (Templates) {
return function () {
this.get = function (templateId) {

@ -0,0 +1,18 @@
'use strict';
define({
register: function (Handlebars) {
Handlebars.registerHelper("debug", function (optionalValue) {
console.group('Handlebar context');
console.log(this);
if (optionalValue) {
console.group('optional values');
console.log('optinal values');
console.groupEnd();
}
console.groupEnd();
});
}
});

@ -1,5 +1,4 @@

'use strict';
'use strict';
define(
[
'marionette',

@ -31,7 +31,7 @@
<div class="span8">
{{#if isContinuing}}
{{#if nextAiring}}
<span class="label">{{date nextAiring}}</span>
<span class="label">{{ShortDate nextAiring}}</span>
{{/if}}
<span class="label label-info">Season {{seasonCount}}</span>
{{else}}

@ -22,7 +22,7 @@
<div class="labels">
{{#if isContinuing}}
{{#if nextAiring}}
<span class="label label-inverse">{{date nextAiring}}</span>
<span class="label label-inverse">{{ShortDate nextAiring}}</span>
{{/if}}
<span class="label label-info">Season {{seasonCount}}</span>
{{else}}

@ -1,5 +1,4 @@

'use strict';
'use strict';
define(
[

@ -4,7 +4,7 @@ define(
[
'sugar'
], {
FileSizeHelper: function (sourceSize) {
Bytes: function (sourceSize) {
var size = Number(sourceSize);
return size.bytes(1);
},

@ -1,47 +0,0 @@
'use strict';
define(
[
'handlebars',
'Shared/FormatHelpers'
], function (Handlebars, FormatHelpers) {
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 new Handlebars.SafeString(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 = FormatHelpers.DateHelper(date);
var result = '<span title="' + shortDate + '">' + formattedDate + '</span>';
return new Handlebars.SafeString(result);
});
Handlebars.registerHelper('defaultImg', function () {
return new Handlebars.SafeString('onerror="this.src="/content/images/poster-dark.jpg";"');
});
});

@ -1,4 +1,4 @@
'use strict';
'use strict';
require.config({
urlArgs: 'v=' + window.ServerStatus.version,
@ -36,6 +36,14 @@ require.config({
}
},
signalR: {
deps:
[
'$'
]
},
bootstrap: {
deps:
[
@ -57,7 +65,7 @@ require.config({
]
},
'underscore': {
underscore: {
deps :
[
'$'
@ -90,30 +98,19 @@ require.config({
deps:
[
'backbone',
'handlebars',
'Handlebars/backbone.marionette.templates',
'mixins/AsNamedView',
'Handlebars/Helpers/DateTime'
'mixins/AsNamedView'
],
exports: 'Marionette',
init : function (Backbone, Handlebars, TemplateMixin, AsNamedView, DateTimeHelpers) {
init : function (Backbone, TemplateMixin, AsNamedView) {
TemplateMixin.call(Marionette.TemplateCache);
AsNamedView.call(Marionette.ItemView.prototype);
DateTimeHelpers.register(Handlebars);
}
},
signalR: {
deps:
[
'$'
]
},
'backbone.pageable': {
deps:
[

Loading…
Cancel
Save