Sha256: 61c288356b475095d6100292bacb7b6337ac757b15a9dc4cd999298a927ab356
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 KB
Contents
pageflow.Chapter = Backbone.Model.extend({ modelName: 'chapter', paramRoot: 'chapter', i18nKey: 'pageflow/chapter', mixins: [pageflow.failureTracking, pageflow.delayedDestroying], initialize: function(attributes, options) { this.pages = new pageflow.ChapterPagesCollection({ pages: options.pages || pageflow.pages, chapter: this }); this.listenTo(this, 'change:title', function() { this.save(); }); this.configuration = new pageflow.ChapterConfiguration(this.get('configuration') || {}); this.listenTo(this.configuration, 'change', function() { this.save(); this.trigger('change:configuration', this); }); return attributes; }, urlRoot: function() { return this.isNew() ? this.collection.url() : '/chapters'; }, addPage: function(options) { options = options || {}; var pos = ('position' in options) ? options.position : this.pages.length; var create_opts = { chapter_id: this.get('id'), position: pos }; return this.pages.create(create_opts); }, toJSON: function() { return _.extend(_.clone(this.attributes), { configuration: this.configuration.toJSON() }); }, destroy: function() { this.destroyWithDelay(); } });
Version data entries
3 entries across 3 versions & 1 rubygems