added jshint

pull/38/merge
kayone 11 years ago
parent 9536c6c1bb
commit 47d924cff3

@ -129,6 +129,27 @@ module.exports = function (grunt) {
}
},
jshint: {
options: {
'-W030': false,
'-W064': false,
'-W097': false,
'-W100': false,
'undef': true,
'globals': {
'require': true,
'define': true,
'window': true,
'document': true,
'console': true
}
},
all: [
srcRoot + '**/*.js',
'!**/JsLibraries/*.js'
]
},
requirejs: {
compile:{
options: {
@ -184,6 +205,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-notify');
grunt.loadNpmTasks('grunt-curl');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('package', ['clean:output','handlebars', 'copy', 'less']);
grunt.registerTask('packagerjs', ['clean:output','handlebars', 'requirejs', 'copy:content', 'less']);

@ -80,7 +80,7 @@ define(
this.collection.reset();
if (!options.term || options.term === this.collection.term) {
return $.Deferred().resolve();
return Marionette.$.Deferred().resolve();
}
this.searchResult.show(new LoadingView());

@ -2,8 +2,9 @@
define(
[
'backbone',
'AddSeries/Existing/UnmappedFolderModel'
], function (Backbone, UnmappedFolderModel) {
'AddSeries/Existing/UnmappedFolderModel',
'underscore'
], function (Backbone, UnmappedFolderModel,_) {
return Backbone.Collection.extend({
model: UnmappedFolderModel,

@ -7,7 +7,7 @@ define(
'moment',
'Calendar/Collection',
'fullcalendar'
], function (vent, Marionette, Moment, CalendarCollection) {
], function (vent, Marionette, moment, CalendarCollection) {
var _instance;
@ -16,7 +16,10 @@ define(
this.collection = new CalendarCollection();
},
render : function () {
$(this.$el).empty().fullCalendar({
var self = this;
this.$el.empty().fullCalendar({
defaultView : 'basicWeek',
allDayDefault : false,
ignoreTimezone: false,
@ -34,8 +37,8 @@ define(
},
events : this.getEvents,
eventRender : function (event, element) {
$(element).addClass(event.statusLevel);
$(element).children('.fc-event-inner').addClass(event.statusLevel);
self.$(element).addClass(event.statusLevel);
self.$(element).children('.fc-event-inner').addClass(event.statusLevel);
},
eventClick : function (event) {
vent.trigger(vent.Commands.ShowEpisodeDetails, {episode: event.model});
@ -50,8 +53,8 @@ define(
},
getEvents: function (start, end, callback) {
var startDate = Moment(start).toISOString();
var endDate = Moment(end).toISOString();
var startDate = moment(start).toISOString();
var endDate = moment(end).toISOString();
_instance.collection.fetch({
data : { start: startDate, end: endDate },
@ -61,7 +64,7 @@ define(
var seriesTitle = element.get('series').title;
var start = element.get('airDateUtc');
var runtime = element.get('series').runtime;
var end = Moment(start).add('minutes', runtime).toISOString();
var end = moment(start).add('minutes', runtime).toISOString();
element.set({
@ -83,9 +86,9 @@ define(
getStatusLevel: function (element) {
var hasFile = element.get('hasFile');
var currentTime = Moment();
var start = Moment(element.get('airDateUtc'));
var end = Moment(element.get('end'));
var currentTime = moment();
var start = moment(element.get('airDateUtc'));
var end = moment(element.get('end'));
var statusLevel = 'primary';
@ -94,10 +97,6 @@ define(
}
else if (currentTime.isAfter(start) && currentTime.isBefore(end)) {
var s = start.toISOString();
var e = end.toISOString();
var c = currentTime.toISOString();
statusLevel = 'warning';
}

@ -3,8 +3,9 @@
define(
[
'Cells/NzbDroneCell',
'Shared/FormatHelpers'
], function (NzbDroneCell, FormatHelpers) {
'Shared/FormatHelpers',
'underscore'
], function (NzbDroneCell, FormatHelpers, _) {
return NzbDroneCell.extend({
className: 'episode-number-cell',

@ -2,8 +2,9 @@
define(
[
'backgrid'
], function (Backgrid) {
'backgrid',
'backbone'
], function (Backgrid, Backbone) {
return Backgrid.Cell.extend({
_originalInit: Backgrid.Cell.prototype.initialize,
@ -15,8 +16,8 @@ define(
this.listenTo(this.model, 'change', this._refresh);
if (this._onEdit) {
this.listenTo(this.model, "backgrid:edit", function (model, column, cell, editor) {
if (column.get("name") == this.column.get("name")) {
this.listenTo(this.model, 'backgrid:edit', function (model, column, cell, editor) {
if (column.get('name') === this.column.get('name')) {
this._onEdit(model, column, cell, editor);
}
});

@ -2,8 +2,9 @@
define(
[
'backgrid',
'Quality/QualityProfileCollection'
], function (Backgrid, QualityProfileCollection) {
'Quality/QualityProfileCollection',
'underscore'
], function (Backgrid, QualityProfileCollection,_) {
return Backgrid.Cell.extend({
className: 'quality-profile-cell',

@ -18,7 +18,7 @@ define(
getValue: function (key, defaultValue) {
var storeValue = localStorage.getItem(key);
var storeValue = window.localStorage.getItem(key);
if (!storeValue) {
return defaultValue;
@ -35,7 +35,7 @@ define(
return;
}
localStorage.setItem(key, value);
window.localStorage.setItem(key, value);
vent.trigger(this.Events.ConfigUpdatedEvent, {key: key, value: value});
}

@ -1,8 +1,10 @@
'use strict';
define(
[
'handlebars'
], function (Handlebars) {
'marionette',
'handlebars',
'underscore'
], function (Marionette, Handlebars, _) {
var _fieldBuilder = function (field) {
if (!field.type) {

@ -38,7 +38,7 @@
return false; //don't suppress default alerts and logs.
};
$(document).ajaxError(function (event, xmlHttpRequest, ajaxOptions) {
window.$(document).ajaxError(function (event, xmlHttpRequest, ajaxOptions) {
//don't report 200 error codes
if (xmlHttpRequest.status >= 200 && xmlHttpRequest.status <= 300) {

@ -1,6 +1,6 @@
'use strict';
define(function () {
define(['jquery'],function ($) {
$.fn.autoComplete = function (resource) {
$(this).typeahead({

@ -2,10 +2,11 @@
define(
[
'marionette',
'Navbar/Search'
], function (Marionette) {
'Navbar/Search',
'jquery'
], function (Marionette, $) {
return Marionette.ItemView.extend({
template : 'Navbar/NavbarTemplate',
template: 'Navbar/NavbarTemplate',
ui: {
search: '.x-series-search'
@ -15,7 +16,7 @@ define(
'click a': 'onClick'
},
onRender: function (){
onRender: function () {
this.ui.search.bindSearch();
},

@ -1,8 +1,9 @@
'use strict';
define(
[
'backbone',
'Quality/QualitySizeModel'
], function (QualitySizeModel) {
], function (Backbone, QualitySizeModel) {
return Backbone.Collection.extend({
model: QualitySizeModel,
url : window.NzbDrone.ApiRoot + '/qualitysize'

@ -1,9 +1,12 @@
define(function () {
define(
[
'jquery'
], function ($) {
'use strict';
return {
load: function (name, parentRequire, onload, config) {
if(config.isBuild){
if (config.isBuild) {
return onload();
}
@ -19,7 +22,7 @@ define(function () {
xhr : xhr,
status: status,
error : error});
});
});
}
};
});

@ -112,13 +112,13 @@ define(
var element;
if (e.target.localName === 'i') {
seasonNumber = parseInt($(e.target).parent('td').attr('data-season-number'), 10);
element = $(e.target);
seasonNumber = parseInt(this.$(e.target).parent('td').attr('data-season-number'), 10);
element = this.$(e.target);
}
else {
seasonNumber = parseInt($(e.target).attr('data-season-number'), 10);
element = $(e.target).children('i');
seasonNumber = parseInt(this.$(e.target).attr('data-season-number'), 10);
element = this.$(e.target).children('i');
}
this.model.setSeasonMonitored(seasonNumber);
@ -146,7 +146,7 @@ define(
}
},
_toggleSeriesMonitored: function (e) {
_toggleSeriesMonitored: function () {
var savePromise = this.model.save('monitored', !this.model.get('monitored'), {
wait: true
});

@ -1,6 +1,7 @@
'use strict';
define(
[
'jquery',
'vent',
'reqres',
'marionette',
@ -15,7 +16,7 @@ define(
'underscore',
'backstrech',
'Mixins/backbone.signalr.mixin'
], function (vent,reqres, Marionette, Backbone, EpisodeCollection, EpisodeFileCollection, SeasonCollection, SeasonCollectionView, InfoView, CommandController, LoadingView, _) {
], function ($,vent,reqres, Marionette, Backbone, EpisodeCollection, EpisodeFileCollection, SeasonCollection, SeasonCollectionView, InfoView, CommandController, LoadingView, _) {
return Marionette.Layout.extend({
itemViewContainer: '.x-series-seasons',

@ -54,7 +54,7 @@ define(
options = {};
}
options['data'] = { seriesId: this.seriesId };
options.data = { seriesId: this.seriesId };
return this.originalFetch.call(this, options);
}

@ -23,7 +23,7 @@ define(
options = {};
}
options['data'] = { seriesId: this.seriesId };
options.data = { seriesId: this.seriesId };
return this.originalFetch.call(this, options);
}

@ -2,6 +2,7 @@
define(
[
'marionette',
'backgrid',
'Series/Index/Posters/CollectionView',
'Series/Index/List/CollectionView',
'Series/Index/EmptyView',
@ -16,8 +17,10 @@ define(
'Cells/SeriesStatusCell',
'Series/Index/FooterView',
'Series/Index/FooterModel',
'Shared/Toolbar/ToolbarLayout'
'Shared/Toolbar/ToolbarLayout',
'underscore'
], function (Marionette,
Backgrid,
PosterCollectionView,
ListCollectionView,
EmptyView,
@ -32,7 +35,8 @@ define(
SeriesStatusCell,
FooterView,
FooterModel,
ToolbarLayout) {
ToolbarLayout,
_) {
return Marionette.Layout.extend({
template: 'Series/Index/SeriesIndexLayoutTemplate',

@ -1,6 +1,6 @@
window.NzbDrone.ApiRoot = '/api';
var statusText = $.ajax({
var statusText = window.$.ajax({
type : 'GET',
url : window.NzbDrone.ApiRoot + '/system/status',
async: false,
@ -13,10 +13,13 @@ window.NzbDrone.ServerStatus = JSON.parse(statusText);
var footerText = window.NzbDrone.ServerStatus.version;
$(document).ready(function () {
if (window.NzbDrone.ServerStatus.branch != 'master') {
window.$(document).ready(function () {
if (window.NzbDrone.ServerStatus.branch !== 'master') {
footerText += '</br>' + window.NzbDrone.ServerStatus.branch;
}
$('#footer-region .version').html(footerText);
window.$('#footer-region .version').html(footerText);
});

@ -83,7 +83,7 @@ define(
this.indexerSettings = new IndexerCollection();
this.notificationSettings = new NotificationCollection();
$.when(this.settings.fetch(),
Backbone.$.when(this.settings.fetch(),
this.generalSettings.fetch(),
this.namingSettings.fetch(),
this.indexerSettings.fetch(),

@ -51,7 +51,7 @@ define(
return '';
}
return input.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return input.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
}
};
});

@ -1,8 +1,9 @@
'use strict';
define(
[
'marionette',
'backgrid.paginator'
], function (Paginator) {
], function (Marionette, Paginator) {
return Paginator.extend({
@ -24,7 +25,7 @@ define(
changePage: function (e) {
e.preventDefault();
var target = $(e.target);
var target =this.$(e.target);
if (target.closest('li').hasClass('disabled')) {
return;
@ -59,7 +60,7 @@ define(
}
var state = collection.state;
var pageIndex = $(e.target).text() * 1;
var pageIndex = target.text();
collection.getPage(state.firstPage === 0 ? pageIndex - 1 :pageIndex);
},

@ -14,10 +14,10 @@ define(
setTitle: function (title) {
if (title.toLocaleLowerCase() === 'nzbdrone') {
window.document.title = 'NzbDrone';
document.title = 'NzbDrone';
}
else {
window.document.title = title + ' - NzbDrone';
document.title = title + ' - NzbDrone';
}
}
});

@ -2,8 +2,9 @@
define(
[
'vent',
'jquery',
'signalR'
], function (vent) {
], function (vent, $) {
return {
appInitializer: function () {

@ -5,8 +5,9 @@ define(
'Shared/Toolbar/ButtonCollection',
'Shared/Toolbar/ButtonModel',
'Shared/Toolbar/Radio/RadioButtonCollectionView',
'Shared/Toolbar/Button/ButtonCollectionView'
], function (Marionette, ButtonCollection, ButtonModel, RadioButtonCollectionView, ButtonCollectionView) {
'Shared/Toolbar/Button/ButtonCollectionView',
'underscore'
], function (Marionette, ButtonCollection, ButtonModel, RadioButtonCollectionView, ButtonCollectionView,_) {
return Marionette.Layout.extend({
template: 'Shared/Toolbar/ToolbarLayoutTemplate',

@ -1,14 +1,17 @@
'use strict';
'use strict';
define(['System/Logs/Files/LogFileModel' ],
function (LogFileModel) {
return Backbone.Collection.extend({
url : window.NzbDrone.ApiRoot + '/log/files',
model: LogFileModel,
define(
[
'backbone',
'System/Logs/Files/LogFileModel'
], function (Backbone, LogFileModel) {
return Backbone.Collection.extend({
url : window.NzbDrone.ApiRoot + '/log/files',
model: LogFileModel,
state: {
sortKey : 'lastWriteTime',
order : 1
}
state: {
sortKey: 'lastWriteTime',
order : 1
}
});
});
});

@ -99,8 +99,8 @@ require.config({
exports: 'Marionette',
init : function (Backbone, TemplateMixin, AsNamedView) {
TemplateMixin.call(Marionette.TemplateCache);
AsNamedView.call(Marionette.ItemView.prototype);
TemplateMixin.call(window.Marionette.TemplateCache);
AsNamedView.call(window.Marionette.ItemView.prototype);
}
},
@ -140,7 +140,7 @@ require.config({
'Shared/Grid/HeaderCell'
], function () {
Backgrid.Column.prototype.defaults = {
window.Backgrid.Column.prototype.defaults = {
name : undefined,
label : undefined,
sortable : true,

@ -1,55 +1,59 @@
'use strict';
define(['backbone'],function (Backbone) {
//This module will automatically route all relative links through backbone router rather than
//causing links to reload pages.
define(
[
'backbone',
'jquery'
], function (Backbone,$) {
//This module will automatically route all relative links through backbone router rather than
//causing links to reload pages.
var routeBinder = {
var routeBinder = {
bind: function () {
var self = this;
$(document).on('click', 'a[href]', function (event) {
self._handleClick(event);
});
},
bind: function () {
var self = this;
$(document).on('click', 'a[href]', function (event) {
self._handleClick(event);
});
},
_handleClick: function (event) {
var $target = $(event.target);
_handleClick: function (event) {
var $target = $(event.target);
//check if tab nav
if ($target.parents('.nav-tabs').length) {
return;
}
//check if tab nav
if ($target.parents('.nav-tabs').length) {
return;
}
if ($target.hasClass('no-router')) {
return;
}
if ($target.hasClass('no-router')) {
return;
}
event.preventDefault();
event.preventDefault();
var href = event.target.getAttribute('href');
var href = event.target.getAttribute('href');
if (!href && $target.parent('a') && $target.parent('a')[0]) {
if (!href && $target.parent('a') && $target.parent('a')[0]) {
var linkElement = $target.parent('a')[0];
var linkElement = $target.parent('a')[0];
href = linkElement.getAttribute('href');
}
href = linkElement.getAttribute('href');
}
if (!href) {
throw 'couldn\'t find route target';
}
if (!href) {
throw 'couldn\'t find route target';
}
if (!href.startsWith('http')) {
Backbone.history.navigate(href, { trigger: true });
}
if (!href.startsWith('http')) {
Backbone.history.navigate(href, { trigger: true });
}
else {
//Open in new tab
window.open(href, '_blank');
else {
//Open in new tab
window.open(href, '_blank');
}
}
}
};
};
return routeBinder;
});
return routeBinder;
});

@ -50,7 +50,7 @@ define(
};
$.fn.addFormError = function (error) {
this.find('.control-group').parent().prepend('<div class="alert alert-error validation-error">' + error.errorMessage + '</div>')
this.find('.control-group').parent().prepend('<div class="alert alert-error validation-error">' + error.errorMessage + '</div>');
};
$.fn.removeAllErrors = function () {

Loading…
Cancel
Save