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

Version Path
pageflow-13.0.0.beta4 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-13.0.0.beta3 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-13.0.0.beta2 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-13.0.0.beta1 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-12.2.0 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-12.1.0 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-12.0.4 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-12.0.3 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-12.0.2 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-12.0.1 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-12.0.0 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-12.0.0.rc7 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-12.0.0.rc6 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-0.11.4 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-12.0.0.rc5 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-12.0.0.rc4 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-12.0.0.rc3 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-12.0.0.rc2 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-12.0.0.rc1 app/assets/javascripts/pageflow/editor/models/chapter.js
pageflow-0.11.3 app/assets/javascripts/pageflow/editor/models/chapter.js