Sha256: 7321bee0be84768a2adc2e235adfcf0b294dcbd00f35851d48493a419cad54d2

Contents?: true

Size: 1.81 KB

Versions: 13

Compression:

Stored size: 1.81 KB

Contents

pageflow.linkmapPage.AreasEmbeddedView = Backbone.Marionette.View.extend({
  events: {
    'linkmapbackgroundclick': function() {
      this.model.linkmapAreas(this.options.propertyName).resetSelection();
      pageflow.editor.navigate('/pages/' + this.model.page.id + '/areas', {trigger: true});
    }
  },

  render: function() {
    var view = this;

    var colorMapDelegator = this.colorMap = new pageflow.linkmapPage.ColorMapDelegator();

    this.$el.on('linkmapupdatecolormap', function(event, options) {
      colorMapDelegator.updateDelegate(options.colorMap);
      view.updateClassNames();
    });

    this.subview(new pageflow.CollectionView({
      el: this.$el,
      collection: this.model.linkmapAreas(this.options.propertyName),
      itemViewConstructor: pageflow.linkmapPage.AreaItemEmbeddedView,
      itemViewOptions: {
        pageConfiguration: this.model,
        page: this.model.page,
        container: this.options.container,
        colorMap: colorMapDelegator
      }
    }));

    view.appendSubview(new pageflow.linkmapPage.AreaMasksPreviewEmbeddedView({
      model: this.model,
      areas: this.model.linkmapAreas(this.options.propertyName),
      colorMap: colorMapDelegator
    }));

    this.listenTo(this.model.page, 'change:areas_editable', function() {
      this.updateClassNames();
    });

    this.listenTo(pageflow.entry, 'change:emulation_mode', function() {
      this.updateClassNames();
    });

    return this;
  },

  updateClassNames: function() {
    var editable = this.model.page.get('areas_editable') && !pageflow.entry.has('emulation_mode');

    this.$el.toggleClass('editable', !!editable);
    this.$el.toggleClass('masks_available',
                         this.colorMap.components().length > 0 &&
                         this.model.get('background_type') !== 'hover_video');
  }
});

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
pageflow-linkmap-page-2.10.0 app/assets/javascript/pageflow/linkmap_page/editor/views/embedded/areas_embedded_view.js
pageflow-linkmap-page-2.9.0 app/assets/javascript/pageflow/linkmap_page/editor/views/embedded/areas_embedded_view.js
pageflow-linkmap-page-2.8.0 app/assets/javascript/pageflow/linkmap_page/editor/views/embedded/areas_embedded_view.js
pageflow-linkmap-page-2.7.1 app/assets/javascript/pageflow/linkmap_page/editor/views/embedded/areas_embedded_view.js
pageflow-linkmap-page-2.7.0 app/assets/javascript/pageflow/linkmap_page/editor/views/embedded/areas_embedded_view.js
pageflow-linkmap-page-2.6.1 app/assets/javascript/pageflow/linkmap_page/editor/views/embedded/areas_embedded_view.js
pageflow-linkmap-page-2.6.0 app/assets/javascript/pageflow/linkmap_page/editor/views/embedded/areas_embedded_view.js
pageflow-linkmap-page-2.5.0 app/assets/javascript/pageflow/linkmap_page/editor/views/embedded/areas_embedded_view.js
pageflow-linkmap-page-2.4.0 app/assets/javascript/pageflow/linkmap_page/editor/views/embedded/areas_embedded_view.js
pageflow-linkmap-page-2.3.0 app/assets/javascript/pageflow/linkmap_page/editor/views/embedded/areas_embedded_view.js
pageflow-linkmap-page-2.2.0 app/assets/javascript/pageflow/linkmap_page/editor/views/embedded/areas_embedded_view.js
pageflow-linkmap-page-2.1.0 app/assets/javascript/pageflow/linkmap_page/editor/views/embedded/areas_embedded_view.js
pageflow-linkmap-page-2.0.0 app/assets/javascript/pageflow/linkmap_page/editor/views/embedded/areas_embedded_view.js