1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

cleaned up template helpers

This commit is contained in:
kay.one 2013-06-24 21:43:16 -07:00
parent d7fbfec01e
commit 8841e43c25
17 changed files with 78 additions and 88 deletions

View File

@ -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" />

3
UI/.idea/scopes/NzbDrone.xml generated Normal file
View File

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

View File

@ -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>

View File

@ -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;
}

View File

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

View File

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

View File

@ -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";"');
});
});

View File

@ -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));
});
});

View File

@ -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) {

18
UI/Handlebars/debug.js Normal file
View File

@ -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();
});
}
});

View File

@ -1,5 +1,4 @@

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

View File

@ -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}}

View File

@ -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}}

View File

@ -1,5 +1,4 @@

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

View File

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

View File

@ -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";"');
});
});

View File

@ -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:
[