Sha256: 6507fc64aafb471a0f2c4ebfb968ef9521f84890675e5d858e4b5304e6f6b0ee

Contents?: true

Size: 974 Bytes

Versions: 11

Compression:

Stored size: 974 Bytes

Contents

pageflow.BackgroundImageEmbeddedView = Backbone.Marionette.View.extend({
  modelEvents: {
    'change': 'update'
  },

  render: function() {
    this.update();
    return this;
  },

  update: function() {
    this.$el.css({
      backgroundImage: 'url("' + this.model.getImageFileUrl(this.options.propertyName) + '")',
      backgroundPosition: this.model.getImageFilePosition(this.options.propertyName, 'x') + '% ' +
        this.model.getImageFilePosition(this.options.propertyName, 'y') + '%',
    });

    if (this.options.dataSizeAttributes) {
      var imageFile = this.model.getImageFile(this.options.propertyName);

      if (imageFile && imageFile.isReady()) {
        this.$el.attr('data-width',  imageFile.get('width'));
        this.$el.attr('data-height',  imageFile.get('height'));
      }
      else {
        this.$el.attr('data-width', '16');
        this.$el.attr('data-height', '9');
      }
      this.$el.css({backgroundPosition:'0 0'});
    }
  }
});

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pageflow-0.5.0 app/assets/javascripts/pageflow/editor/views/embedded/background_image_embedded_view.js
pageflow-0.4.0 app/assets/javascripts/pageflow/editor/views/embedded/background_image_embedded_view.js
pageflow-0.3.0 app/assets/javascripts/pageflow/editor/views/embedded/background_image_embedded_view.js
pageflow-0.2.1 app/assets/javascripts/pageflow/editor/views/embedded/background_image_embedded_view.js
pageflow-0.2.0 app/assets/javascripts/pageflow/editor/views/embedded/background_image_embedded_view.js
pageflow-0.1.0 app/assets/javascripts/pageflow/editor/views/embedded/background_image_embedded_view.js
pageflow-0.0.5 app/assets/javascripts/pageflow/editor/views/embedded/background_image_embedded_view.js
pageflow-0.0.4 app/assets/javascripts/pageflow/editor/views/embedded/background_image_embedded_view.js
pageflow-0.0.3 app/assets/javascripts/pageflow/editor/views/embedded/background_image_embedded_view.js
pageflow-0.0.2 app/assets/javascripts/pageflow/editor/views/embedded/background_image_embedded_view.js
pageflow-0.0.1 app/assets/javascripts/pageflow/editor/views/embedded/background_image_embedded_view.js