mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 04:22:30 +01:00
sugar kills (removed sugar.js)
Relative dates for next airing on posters and list (series) History time shows real time on tooltip
This commit is contained in:
parent
641e01376b
commit
207d9c256d
@ -24,7 +24,7 @@ module.exports = function (grunt) {
|
||||
'UI/JsLibraries/jquery.knob.js' : 'http://raw.github.com/aterrien/jQuery-Knob/master/js/jquery.knob.js',
|
||||
|
||||
'UI/JsLibraries/require.js' : 'http://raw.github.com/jrburke/requirejs/master/require.js',
|
||||
'UI/JsLibraries/sugar.js' : 'http://raw.github.com/andrewplummer/Sugar/master/release/sugar-full.development.js',
|
||||
'UI/JsLibraries/filesize.js' : 'http://cdn.filesizejs.com/filesize.js',
|
||||
'UI/JsLibraries/lodash.underscore.js' : 'http://raw.github.com/bestiejs/lodash/master/dist/lodash.underscore.js',
|
||||
|
||||
'UI/JsLibraries/messenger.js' : 'http://raw.github.com/HubSpot/messenger/master/build/js/messenger.js',
|
||||
|
@ -4,10 +4,11 @@ define(
|
||||
[
|
||||
'app',
|
||||
'marionette',
|
||||
'moment',
|
||||
'Calendar/Collection',
|
||||
'Episode/Layout',
|
||||
'fullcalendar'
|
||||
], function (App, Marionette, CalendarCollection, EpisodeLayout) {
|
||||
], function (App, Marionette, Moment, CalendarCollection, EpisodeLayout) {
|
||||
|
||||
var _instance;
|
||||
|
||||
@ -50,8 +51,8 @@ define(
|
||||
},
|
||||
|
||||
getEvents: function (start, end, callback) {
|
||||
var startDate = Date.create(start).format(Date.ISO8601_DATETIME);
|
||||
var endDate = Date.create(end).format(Date.ISO8601_DATETIME);
|
||||
var startDate = Moment(start).toISOString();
|
||||
var endDate = Moment(end).toISOString();
|
||||
|
||||
_instance.collection.fetch({
|
||||
data : { start: startDate, end: endDate },
|
||||
@ -80,11 +81,11 @@ define(
|
||||
|
||||
getStatusLevel: function (element) {
|
||||
var hasFile = element.get('hasFile');
|
||||
var currentTime = Date.create();
|
||||
var start = Date.create(element.get('airDate'));
|
||||
var end = Date.create(element.get('end'));
|
||||
var currentTime = Moment();
|
||||
var start = Moment(element.get('airDate'));
|
||||
var end = Moment(element.get('end'));
|
||||
|
||||
if (currentTime.isBetween(start, end)) {
|
||||
if (currentTime.isAfter(start) && currentTime.isBefore(end)) {
|
||||
return 'warning';
|
||||
}
|
||||
|
||||
|
@ -2,20 +2,21 @@
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'moment',
|
||||
'Series/EpisodeModel'
|
||||
], function (Backbone, EpisodeModel) {
|
||||
], function (Backbone, Moment, EpisodeModel) {
|
||||
return Backbone.Collection.extend({
|
||||
url : window.ApiRoot + '/calendar',
|
||||
model: EpisodeModel,
|
||||
|
||||
comparator: function (model1, model2) {
|
||||
var airDate1 = model1.get('airDate');
|
||||
var date1 = Date.create(airDate1);
|
||||
var time1 = date1.getTime();
|
||||
var date1 = Moment(airDate1);
|
||||
var time1 = date1.unix();
|
||||
|
||||
var airDate2 = model2.get('airDate');
|
||||
var date2 = Date.create(airDate2);
|
||||
var time2 = date2.getTime();
|
||||
var date2 = Moment(airDate2);
|
||||
var time2 = date2.unix();
|
||||
|
||||
if (time1 < time2){
|
||||
return -1;
|
||||
|
@ -2,16 +2,24 @@
|
||||
define(
|
||||
[
|
||||
'backgrid',
|
||||
'moment',
|
||||
'Shared/FormatHelpers'
|
||||
], function (Backgrid, FormatHelpers) {
|
||||
], function (Backgrid, Moment, FormatHelpers) {
|
||||
return Backgrid.Cell.extend({
|
||||
className: 'air-date-cell',
|
||||
|
||||
render: function () {
|
||||
|
||||
this.$el.empty();
|
||||
var airDate = this.model.get(this.column.get('name'));
|
||||
this.$el.html(FormatHelpers.DateHelper(airDate));
|
||||
var date = this.model.get(this.column.get('name'));
|
||||
|
||||
if (date) {
|
||||
this.$el.html(FormatHelpers.DateHelper(date));
|
||||
|
||||
//TODO: Figure out why this makes the series grid freak out
|
||||
//this.$el.attr('title', Moment(date).format('LLLL'));
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
@ -2,8 +2,9 @@
|
||||
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell'
|
||||
], function (NzbDroneCell) {
|
||||
'Cells/NzbDroneCell',
|
||||
'Shared/FormatHelpers'
|
||||
], function (NzbDroneCell, FormatHelpers) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'episode-number-cell',
|
||||
@ -30,14 +31,14 @@ define(
|
||||
|
||||
if (episodes.constructor === Array) {
|
||||
paddedEpisodes = _.map(episodes,function (episodeNumber) {
|
||||
return episodeNumber.pad(2);
|
||||
return FormatHelpers.pad(episodeNumber, 2);
|
||||
}).join();
|
||||
}
|
||||
else {
|
||||
paddedEpisodes = episodes.pad(2);
|
||||
paddedEpisodes = FormatHelpers.pad(episodes, 2);
|
||||
}
|
||||
|
||||
result = 'S{0}-E{1}'.format(seasonNumber.pad(2), paddedEpisodes);
|
||||
result = '{0}x{1}'.format(seasonNumber, paddedEpisodes);
|
||||
}
|
||||
else if (airDate) {
|
||||
result = new Date(airDate).toLocaleDateString();
|
||||
|
@ -2,8 +2,9 @@
|
||||
|
||||
define(
|
||||
[
|
||||
'backgrid'
|
||||
], function (Backgrid) {
|
||||
'backgrid',
|
||||
'moment'
|
||||
], function (Backgrid, Moment) {
|
||||
return Backgrid.Cell.extend({
|
||||
|
||||
className: 'episode-status-cell',
|
||||
@ -16,7 +17,7 @@ define(
|
||||
var icon;
|
||||
var tooltip;
|
||||
|
||||
var hasAired = Date.create(this.model.get('airDate')).isBefore(Date.create());
|
||||
var hasAired = Moment(this.model.get('airDate')).isBefore(Moment());
|
||||
var hasFile = this.model.get('hasFile');
|
||||
|
||||
if (hasFile) {
|
||||
|
@ -1,8 +1,10 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell'
|
||||
], function (NzbDroneCell) {
|
||||
'Cells/NzbDroneCell',
|
||||
'moment',
|
||||
'Shared/FormatHelpers'
|
||||
], function (NzbDroneCell, Moment, FormatHelpers) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'relative-date-cell',
|
||||
@ -10,7 +12,11 @@ define(
|
||||
render: function () {
|
||||
|
||||
var date = this.model.get(this.column.get('name'));
|
||||
this.$el.html(Date.create(date).relative());
|
||||
|
||||
if (date) {
|
||||
this.$el.html(FormatHelpers.DateHelper(date));
|
||||
this.$el.attr('title', Moment(date).format('LLLL'));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@ -8,11 +8,13 @@
|
||||
}
|
||||
|
||||
.air-date-cell {
|
||||
width : 100px;
|
||||
width : 120px;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.relative-date-cell {
|
||||
width : 150px;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.quality-cell {
|
||||
|
@ -2,15 +2,27 @@
|
||||
define(
|
||||
[
|
||||
'handlebars',
|
||||
'sugar'
|
||||
], function (Handlebars) {
|
||||
'moment',
|
||||
'Shared/FormatHelpers'
|
||||
], function (Handlebars, Moment, FormatHelpers) {
|
||||
Handlebars.registerHelper('ShortDate', function (input) {
|
||||
if (!input) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var date = Date.create(input);
|
||||
var result = '<span title="' + date.full() + '">' + date.short() + '</span>';
|
||||
var date = Moment(input);
|
||||
var result = '<span title="' + date.format('LLLL') + '">' + date.format('LL') + '</span>';
|
||||
|
||||
return new Handlebars.SafeString(result);
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('NextAiring', function (input) {
|
||||
if (!input) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var date = Moment(input);
|
||||
var result = '<span title="' + date.format('LLLL') + '">' + FormatHelpers.DateHelper(input) + '</span>';
|
||||
|
||||
return new Handlebars.SafeString(result);
|
||||
});
|
||||
@ -20,7 +32,7 @@ define(
|
||||
return '';
|
||||
}
|
||||
|
||||
return Date.create(input).format('{dd}');
|
||||
return Moment(input).format('DD');
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('Month', function (input) {
|
||||
@ -28,7 +40,7 @@ define(
|
||||
return '';
|
||||
}
|
||||
|
||||
return Date.create(input).format('{Mon}');
|
||||
return Moment(input).format('MMM');
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('StartTime', function (input) {
|
||||
@ -36,11 +48,11 @@ define(
|
||||
return '';
|
||||
}
|
||||
|
||||
var date = Date.create(input);
|
||||
if (date.format('{mm}') === '00') {
|
||||
return date.format('{h}{tt}');
|
||||
var date = Moment(input);
|
||||
if (date.format('mm') === '00') {
|
||||
return date.format('ha');
|
||||
}
|
||||
|
||||
return date.format('{h}.{mm}{tt}');
|
||||
return date.format('h.mma');
|
||||
});
|
||||
});
|
||||
|
@ -2,8 +2,9 @@
|
||||
define(
|
||||
[
|
||||
'handlebars',
|
||||
'Shared/FormatHelpers'
|
||||
], function (Handlebars, FormatHelpers) {
|
||||
'Shared/FormatHelpers',
|
||||
'moment'
|
||||
], function (Handlebars, FormatHelpers, Moment) {
|
||||
Handlebars.registerHelper('EpisodeNumber', function () {
|
||||
|
||||
if (this.series.seriesType === 'daily') {
|
||||
@ -19,11 +20,11 @@ define(
|
||||
Handlebars.registerHelper('StatusLevel', function () {
|
||||
|
||||
var hasFile = this.hasFile;
|
||||
var currentTime = Date.create();
|
||||
var start = Date.create(this.airDate);
|
||||
var end = Date.create(this.end);
|
||||
var currentTime = Moment();
|
||||
var start = Moment(this.airDate);
|
||||
var end = Moment(this.end);
|
||||
|
||||
if (currentTime.isBetween(start, end)) {
|
||||
if (currentTime.isAfter(start) && currentTime.isBefore(end)) {
|
||||
return 'warning';
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ define(
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('Pad2', function (input) {
|
||||
return input.pad(2);
|
||||
return FormatHelpers.pad(input, 2);
|
||||
});
|
||||
|
||||
});
|
||||
|
153
UI/JsLibraries/filesize.js
Normal file
153
UI/JsLibraries/filesize.js
Normal file
@ -0,0 +1,153 @@
|
||||
/**
|
||||
* filesize
|
||||
*
|
||||
* @author Jason Mulligan <jason.mulligan@avoidwork.com>
|
||||
* @copyright 2013 Jason Mulligan
|
||||
* @license BSD-3 <https://raw.github.com/avoidwork/filesize.js/master/LICENSE>
|
||||
* @link http://filesizejs.com
|
||||
* @module filesize
|
||||
* @version 1.10.0
|
||||
*/
|
||||
( function ( global ) {
|
||||
"use strict";
|
||||
|
||||
var base = 10,
|
||||
right = /\.(.*)/,
|
||||
bit = /b$/,
|
||||
bite = /^B$/,
|
||||
zero = /^0$/,
|
||||
options;
|
||||
|
||||
options = {
|
||||
all : {
|
||||
increments : [["B", 1], ["kb", 125], ["kB", 1000], ["Mb", 125000], ["MB", 1000000], ["Gb", 125000000], ["GB", 1000000000], ["Tb", 125000000000], ["TB", 1000000000000], ["Pb", 125000000000000], ["PB", 1000000000000000]],
|
||||
nth : 11
|
||||
},
|
||||
bitless : {
|
||||
increments : [["B", 1], ["kB", 1000], ["MB", 1000000], ["GB", 1000000000], ["TB", 1000000000000], ["PB", 1000000000000000]],
|
||||
nth : 6
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* filesize
|
||||
*
|
||||
* @param {Mixed} arg String, Int or Float to transform
|
||||
* @param {Mixed} pos [Optional] Position to round to, defaults to 2 if shrt is ommitted, or `true` for shrthand output
|
||||
* @param {Boolean} bits [Optional] Determines if `bit` sizes are used for result calculation, default is true
|
||||
* @return {String} Readable file size String
|
||||
*/
|
||||
function filesize ( arg) {
|
||||
var result = "",
|
||||
bits = true,
|
||||
skip = false,
|
||||
i, neg, num, pos, shrt, size, sizes, suffix, z;
|
||||
|
||||
// Determining arguments
|
||||
if (arguments[3] !== undefined) {
|
||||
pos = arguments[1];
|
||||
shrt = arguments[2];
|
||||
bits = arguments[3];
|
||||
}
|
||||
else {
|
||||
typeof arguments[1] === "boolean" ? shrt = arguments[1] : pos = arguments[1];
|
||||
|
||||
if ( typeof arguments[2] === "boolean" ) {
|
||||
bits = arguments[2];
|
||||
}
|
||||
}
|
||||
|
||||
if ( isNaN( arg ) || ( pos !== undefined && isNaN( pos ) ) ) {
|
||||
throw new Error("Invalid arguments");
|
||||
}
|
||||
|
||||
shrt = ( shrt === true );
|
||||
bits = ( bits === true );
|
||||
pos = shrt ? 1 : ( pos === undefined ? 2 : parseInt( pos, base ) );
|
||||
num = Number( arg );
|
||||
neg = ( num < 0 );
|
||||
|
||||
// Flipping a negative number to determine the size
|
||||
if ( neg ) {
|
||||
num = -num;
|
||||
}
|
||||
|
||||
// Zero is now a special case because bytes divide by 1
|
||||
if ( num === 0 ) {
|
||||
if ( shrt ) {
|
||||
result = "0";
|
||||
}
|
||||
else {
|
||||
result = "0 B";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( bits ) {
|
||||
sizes = options.all.increments;
|
||||
i = options.all.nth;
|
||||
}
|
||||
else {
|
||||
sizes = options.bitless.increments;
|
||||
i = options.bitless.nth;
|
||||
}
|
||||
|
||||
while ( i-- ) {
|
||||
size = sizes[i][1];
|
||||
suffix = sizes[i][0];
|
||||
|
||||
if ( num >= size ) {
|
||||
// Treating bytes as cardinal
|
||||
if ( bite.test( suffix ) ) {
|
||||
skip = true;
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
result = ( num / size ).toFixed( pos );
|
||||
|
||||
if ( !skip && shrt ) {
|
||||
if ( bits && bit.test( suffix ) ) {
|
||||
suffix = suffix.toLowerCase();
|
||||
}
|
||||
|
||||
suffix = suffix.charAt( 0 );
|
||||
z = right.exec( result );
|
||||
|
||||
if ( suffix === "k" ) {
|
||||
suffix = "K";
|
||||
}
|
||||
|
||||
if ( z !== null && z[1] !== undefined && zero.test( z[1] ) ) {
|
||||
result = parseInt( result, base );
|
||||
}
|
||||
|
||||
result += suffix;
|
||||
}
|
||||
else if ( !shrt ) {
|
||||
result += " " + suffix;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Decorating a 'diff'
|
||||
if ( neg ) {
|
||||
result = "-" + result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// CommonJS, AMD, script tag
|
||||
if ( typeof exports !== "undefined" ) {
|
||||
module.exports = filesize;
|
||||
}
|
||||
else if ( typeof define === "function" ) {
|
||||
define( function () {
|
||||
return filesize;
|
||||
});
|
||||
}
|
||||
else {
|
||||
global.filesize = filesize;
|
||||
}
|
||||
})( this );
|
File diff suppressed because it is too large
Load Diff
@ -2,16 +2,17 @@
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'moment',
|
||||
'Series/SeriesModel'
|
||||
], function (Backbone, SeriesModel) {
|
||||
], function (Backbone, Moment, SeriesModel) {
|
||||
return Backbone.Model.extend({
|
||||
|
||||
initialize: function () {
|
||||
if (this.has('series')) {
|
||||
var start = Date.create(this.get('airDate'));
|
||||
var start = Moment(this.get('airDate'));
|
||||
var runtime = this.get('series').get('runtime');
|
||||
|
||||
this.set('end', start.addMinutes(runtime));
|
||||
this.set('end', start.add('minutes', runtime));
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
<div class="span8">
|
||||
{{#if_eq status compare="continuing"}}
|
||||
{{#if nextAiring}}
|
||||
<span class="label">{{ShortDate nextAiring}}</span>
|
||||
<span class="label">{{NextAiring nextAiring}}</span>
|
||||
{{/if}}
|
||||
<span class="label label-info">Season {{seasonCount}}</span>
|
||||
{{else}}
|
||||
|
@ -20,14 +20,14 @@
|
||||
|
||||
<div class="center">
|
||||
<div class="labels">
|
||||
{{#if isContinuing}}
|
||||
{{#if_eq status compare="continuing"}}
|
||||
{{#if nextAiring}}
|
||||
<span class="label label-inverse">{{ShortDate nextAiring}}</span>
|
||||
<span class="label label-inverse">{{NextAiring nextAiring}}</span>
|
||||
{{/if}}
|
||||
<span class="label label-info">Season {{seasonCount}}</span>
|
||||
{{else}}
|
||||
<span class="label label-info">{{seasonCount}} Seasons</span>
|
||||
{{/if}}
|
||||
{{/if_eq}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -60,7 +60,8 @@ define(
|
||||
label : 'Episodes',
|
||||
sortable: false,
|
||||
template: 'Series/EpisodeProgressTemplate',
|
||||
cell : TemplatedCell
|
||||
cell : TemplatedCell,
|
||||
className: 'episode-progress-cell'
|
||||
},
|
||||
{
|
||||
name : 'this',
|
||||
@ -189,8 +190,7 @@ define(
|
||||
title : '',
|
||||
icon : 'icon-table',
|
||||
callback: this._showTable
|
||||
},
|
||||
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
|
@ -2,37 +2,37 @@
|
||||
|
||||
define(
|
||||
[
|
||||
'sugar'
|
||||
], {
|
||||
Bytes: function (sourceSize) {
|
||||
var size = Number(sourceSize);
|
||||
return size.bytes(1);
|
||||
},
|
||||
'moment',
|
||||
'filesize'
|
||||
], function (Moment, Filesize) {
|
||||
|
||||
DateHelper: function (sourceDate) {
|
||||
if (!sourceDate) {
|
||||
return '';
|
||||
}
|
||||
return {
|
||||
|
||||
var date = Date.create(sourceDate);
|
||||
Bytes: function (sourceSize) {
|
||||
var size = Number(sourceSize);
|
||||
return Filesize(size, 1, false);
|
||||
},
|
||||
|
||||
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}');
|
||||
}
|
||||
DateHelper: function (sourceDate) {
|
||||
if (!sourceDate) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (date.isAfter(Date.create().addDays(6))) {
|
||||
return date.relative().replace(' from now', '');
|
||||
}
|
||||
var date = Moment(sourceDate);
|
||||
|
||||
return date.format('{MM}/{dd}/{yyyy}');
|
||||
if (date.isAfter(Moment().add('days', 6))) {
|
||||
return date.fromNow(true);
|
||||
}
|
||||
|
||||
//TODO: It would be nice to not have to hack this...
|
||||
var calendarDate = date.calendar();
|
||||
return calendarDate.substring(0, calendarDate.indexOf(' at '));
|
||||
},
|
||||
|
||||
pad: function(n, width, z) {
|
||||
z = z || '0';
|
||||
n = n + '';
|
||||
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
23
UI/Shared/StringHelpers.js
Normal file
23
UI/Shared/StringHelpers.js
Normal file
@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
[
|
||||
], function () {
|
||||
|
||||
return {
|
||||
|
||||
startsWith: function(str, starts){
|
||||
if (starts === '') return true;
|
||||
if (str == null || starts == null) return false;
|
||||
str = String(str); starts = String(starts);
|
||||
return str.length >= starts.length && str.slice(0, starts.length) === starts;
|
||||
},
|
||||
|
||||
endsWith: function(str, ends){
|
||||
if (ends === '') return true;
|
||||
if (str == null || ends == null) return false;
|
||||
str = String(str); ends = String(ends);
|
||||
return str.length >= ends.length && str.slice(str.length - ends.length) === ends;
|
||||
}
|
||||
}
|
||||
});
|
@ -5,8 +5,8 @@ require.config({
|
||||
|
||||
paths: {
|
||||
'backbone' : 'JsLibraries/backbone',
|
||||
'sugar' : 'JsLibraries/sugar',
|
||||
'moment' : 'JsLibraries/moment',
|
||||
'filesize' : 'JsLibraries/filesize',
|
||||
'handlebars' : 'JsLibraries/handlebars.runtime',
|
||||
'handlebars.helpers' : 'JsLibraries/handlebars.helpers',
|
||||
'bootstrap' : 'JsLibraries/bootstrap',
|
||||
|
@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
define(function () {
|
||||
define(['Shared/StringHelpers'],function (StringHelpers) {
|
||||
//This module will automatically route all relative links through backbone router rather than
|
||||
//causing links to reload pages.
|
||||
|
||||
@ -40,7 +40,7 @@ define(function () {
|
||||
}
|
||||
|
||||
|
||||
if (!href.startsWith('http')) {
|
||||
if (!StringHelpers.startsWith(href, 'http')) {
|
||||
router.navigate(href, { trigger: true });
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user