Sha256: 6ab6d1bf22d4947450368708ca3f4cbcc7f64b542b2d16c4298068c045702d98

Contents?: true

Size: 1.53 KB

Versions: 13

Compression:

Stored size: 1.53 KB

Contents

pageflow.linkmapPage.AreasCollection = Backbone.Collection.extend({
  model: pageflow.linkmapPage.Area,

  initialize: function(models, options) {
    this.page = options.page;
    this.defaultPosition = {
      left: 10,
      top: 10
    };

    this.listenTo(this, 'select', this.updateSelectedAttributes);
    this.listenTo(this, 'add', this.updateSelectedAttributes);
  },

  comparator: function(area) {
    return area.get('position');
  },

  canAddLink: function() {
    return true;
  },

  addLink: function(targetPageId) {
    this.addWithPosition({
      target_type: 'page',
      target_id: targetPageId
    });
  },

  addAudioFile: function(audioFileId) {
    this.addWithPosition({
      target_type: 'audio_file',
      target_id: audioFileId
    });
  },

  addExternalSite: function(siteId) {
    this.addWithPosition({
      target_type: 'external_site',
      target_id: siteId
    });
  },

  addTextOnly: function() {
    this.addWithPosition({
      target_type: 'text_only'
    });
  },

  addWithPosition: function(attributes) {
    var collection = this;

    pageflow.linkmapPage.selectArea(this.page).then(function(positionAttributes) {
      collection.add(_.extend(
        positionAttributes,
        attributes
      ));
    });
  },

  resetSelection: function() {
    this.trigger('resetSelection');
    this.updateSelectedAttributes(null);
  },

  updateSelectedAttributes: function(selectedArea) {
    this.each(function(area) {
      area.set('selected', area === selectedArea);
    });
  },

  saveOrder: function() {}
});

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/collections/areas_collection.js
pageflow-linkmap-page-2.9.0 app/assets/javascript/pageflow/linkmap_page/editor/collections/areas_collection.js
pageflow-linkmap-page-2.8.0 app/assets/javascript/pageflow/linkmap_page/editor/collections/areas_collection.js
pageflow-linkmap-page-2.7.1 app/assets/javascript/pageflow/linkmap_page/editor/collections/areas_collection.js
pageflow-linkmap-page-2.7.0 app/assets/javascript/pageflow/linkmap_page/editor/collections/areas_collection.js
pageflow-linkmap-page-2.6.1 app/assets/javascript/pageflow/linkmap_page/editor/collections/areas_collection.js
pageflow-linkmap-page-2.6.0 app/assets/javascript/pageflow/linkmap_page/editor/collections/areas_collection.js
pageflow-linkmap-page-2.5.0 app/assets/javascript/pageflow/linkmap_page/editor/collections/areas_collection.js
pageflow-linkmap-page-2.4.0 app/assets/javascript/pageflow/linkmap_page/editor/collections/areas_collection.js
pageflow-linkmap-page-2.3.0 app/assets/javascript/pageflow/linkmap_page/editor/collections/areas_collection.js
pageflow-linkmap-page-2.2.0 app/assets/javascript/pageflow/linkmap_page/editor/collections/areas_collection.js
pageflow-linkmap-page-2.1.0 app/assets/javascript/pageflow/linkmap_page/editor/collections/areas_collection.js
pageflow-linkmap-page-2.0.0 app/assets/javascript/pageflow/linkmap_page/editor/collections/areas_collection.js