2013-06-25 02:41:59 +03:00
|
|
|
'use strict';
|
|
|
|
define(
|
|
|
|
[
|
|
|
|
'backbone',
|
2013-07-17 09:23:44 +03:00
|
|
|
'moment',
|
2013-06-25 02:41:59 +03:00
|
|
|
'Series/EpisodeModel'
|
2013-07-17 09:23:44 +03:00
|
|
|
], function (Backbone, Moment, EpisodeModel) {
|
2013-06-25 02:41:59 +03:00
|
|
|
return Backbone.Collection.extend({
|
|
|
|
url : window.ApiRoot + '/calendar',
|
|
|
|
model: EpisodeModel,
|
2013-06-06 06:03:04 +03:00
|
|
|
|
2013-07-01 21:25:06 +03:00
|
|
|
comparator: function (model1, model2) {
|
2013-07-24 08:28:06 +03:00
|
|
|
var airDate1 = model1.get('airDateUtc');
|
2013-07-17 09:23:44 +03:00
|
|
|
var date1 = Moment(airDate1);
|
|
|
|
var time1 = date1.unix();
|
2013-07-01 21:25:06 +03:00
|
|
|
|
2013-07-24 08:28:06 +03:00
|
|
|
var airDate2 = model2.get('airDateUtc');
|
2013-07-17 09:23:44 +03:00
|
|
|
var date2 = Moment(airDate2);
|
|
|
|
var time2 = date2.unix();
|
2013-07-01 21:25:06 +03:00
|
|
|
|
|
|
|
if (time1 < time2){
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (time1 > time2){
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2013-06-25 02:41:59 +03:00
|
|
|
}
|
|
|
|
});
|
2013-02-23 20:42:15 +03:00
|
|
|
});
|