chapter.js 494 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
define(["backbone", "js/models/chapter"], function(Backbone, ChapterModel) {
    var ChapterCollection = Backbone.Collection.extend({
        model: ChapterModel,
        comparator: "order",
        nextOrder: function() {
            if(!this.length) return 1;
            return this.last().get('order') + 1;
        },
        isEmpty: function() {
            return this.length === 0 || this.every(function(m) { return m.isEmpty(); });
        }
    });
    return ChapterCollection;
});