Sha256: 903c0e2545e9edb7e812ef7f53ef8f2098b88071a7e4fafbbebc9a8e0603b612

Contents?: true

Size: 1.88 KB

Versions: 6

Compression:

Stored size: 1.88 KB

Contents

pageflow.Page = Backbone.Model.extend({
  modelName: 'page',
  paramRoot: 'page',

  defaults: {
    template: 'background_image',
    configuration: {},
    active: false,
    perma_id: ''
  },

  mixins: [pageflow.failureTracking, pageflow.delayedDestroying],

  initialize: function() {
    this.configuration = new pageflow.Configuration(this.get('configuration') || {});
    this.configuration.page = this;

    this.listenTo(this.configuration, 'change', function() {
      this.trigger('change:configuration');
    });

    this.listenTo(this.configuration, 'change:title', function() {
      this.trigger('change:title');
    });

    this.listenTo(this.configuration, 'change', function() {
      this.save();
    });

    this.listenTo(this, 'change:template', function() {
      this.save();
    });
  },

  urlRoot: function() {
    return this.isNew() ? this.collection.url() : '/pages';
  },

  chapterPosition: function() {
    return (this.chapter && this.chapter.get('position')) || -1;
  },

  title: function() {
    return this.configuration.get('title') || this.configuration.get('additional_title');
  },

  thumbnailFile: function() {
    if (_.contains(['video', 'background_video'], this.get('template'))) {
      if (this.configuration.get('poster_image_id')) {
        return this.configuration.getImageFile('poster_image_id');
      }
      else {
        return this.configuration.getVideoFile('video_file_id');
      }
    }
    else {
      return this.configuration.getImageFile('background_image_id');
    }
  },

  toJSON: function() {
    return _.extend(_.clone(this.attributes), {
      configuration: this.configuration.toJSON()
    });
  },

  destroy: function() {
    this.destroyWithDelay();
  }
});

pageflow.Page.transitions = ['fade', 'scroll'];
pageflow.Page.linkedPagesLayouts = ['default', 'hero_top_left', 'hero_top_right'];
pageflow.Page.textPositions = ['left', 'right'];

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pageflow-0.1.0 app/assets/javascripts/pageflow/editor/models/page.js
pageflow-0.0.5 app/assets/javascripts/pageflow/editor/models/page.js
pageflow-0.0.4 app/assets/javascripts/pageflow/editor/models/page.js
pageflow-0.0.3 app/assets/javascripts/pageflow/editor/models/page.js
pageflow-0.0.2 app/assets/javascripts/pageflow/editor/models/page.js
pageflow-0.0.1 app/assets/javascripts/pageflow/editor/models/page.js