Sha256: 4815a8eef01b2c835c6df988eb638bf424e5f02d9c7fa0f3f0e01b90260b9a5b
Contents?: true
Size: 1.4 KB
Versions: 64
Compression:
Stored size: 1.4 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'; }, storylinePosition: function() { return (this.storyline && this.storyline.get('position')) || -1; }, addPage: function(attributes) { var page = this.buildPage(attributes); page.save(); return page; }, buildPage: function(attributes) { var defaults = { chapter_id: this.id, position: this.pages.length }; return this.pages.addAndReturnModel(_.extend(defaults, attributes)); }, toJSON: function() { return _.extend(_.clone(this.attributes), { configuration: this.configuration.toJSON() }); }, destroy: function() { this.destroyWithDelay(); } });
Version data entries
64 entries across 64 versions & 1 rubygems