client side code webstorm code cleanup.

This commit is contained in:
kay.one 2013-03-29 16:28:58 -07:00
commit 445ea4f344
94 changed files with 4355 additions and 4243 deletions

View file

@ -2,13 +2,13 @@
$.fn.autoComplete = function (resource) {
$(this).typeahead({
source: function (filter, callback) {
source : function (filter, callback) {
$.ajax({
url: NzbDrone.Constants.ApiRoot + resource,
url : NzbDrone.Constants.ApiRoot + resource,
dataType: "json",
type: "GET",
data: { query: filter },
success: function (data) {
type : "GET",
data : { query: filter },
success : function (data) {
callback(data);
}
});

View file

@ -1,28 +1,25 @@
//try to add ajax data as query string to DELETE calls.
(function (){
(function () {
var original = Backbone.ajax;
Backbone.ajax = function (){
Backbone.ajax = function () {
var xhr = arguments[0];
//check if ajax call was made with data option
if(xhr && xhr.data && xhr.type=='DELETE')
{
if(xhr.url.indexOf('?') === -1)
{
if (xhr && xhr.data && xhr.type == 'DELETE') {
if (xhr.url.indexOf('?') === -1) {
xhr.url = xhr.url + '?' + $.param(xhr.data);
}
else
{
else {
xhr.url = xhr.url + '&' + $.param(xhr.data);
}
}
if (original){
original.apply (this, arguments);
if (original) {
original.apply(this, arguments);
}
};
} ());
}());

View file

@ -12,7 +12,7 @@ Marionette.TemplateCache.get = function (templateId) {
return function (data) {
try {
console.log('rendering template ' + templateName);
//console.log('rendering template ' + templateName);
return templateFunction(data);
}
catch (error) {

View file

@ -1,12 +1,22 @@
function bestDateString(sourceDate){
if (!sourceDate) return '';
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.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}');
}
return date.format('{MM}/{dd}/{yyyy}');
}

View file

@ -1,7 +1,7 @@
$.tablesorter.addParser({
// set a unique id
id: 'title',
is: function (s) {
id : 'title',
is : function (s) {
// return false so this parser is not auto detected
return false;
},
@ -10,33 +10,34 @@ $.tablesorter.addParser({
return s.match(/title="(.*?)"/)[1].toLowerCase();
},
// set type, either numeric or text
type: 'text'
type : 'text'
});
$.tablesorter.addParser({
// set a unique id
id: 'date',
is: function (s) {
id : 'date',
is : function (s) {
// return false so this parser is not auto detected
return false;
},
format: function (s) {
// format your data for normalization
var match = s.match(/data-date="(.*?)"/)[1];
if (match === '')
if (match === '') {
return Date.create().addYears(100).format(Date.ISO8601_DATETIME);
}
return match;
},
// set type, either numeric or text
type: 'text'
type : 'text'
});
$.tablesorter.addParser({
// set a unique id
id: 'innerHtml',
is: function (s) {
id : 'innerHtml',
is : function (s) {
// return false so this parser is not auto detected
return false;
},
@ -45,5 +46,5 @@ $.tablesorter.addParser({
return $(s).get(0).innerHTML;
},
// set type, either numeric or text
type: 'text'
type : 'text'
});