Sha256: 79a6cbe898a6c5fcea6e46bf6adba845bdf69244a951bfd0653cc005b869a6cd

Contents?: true

Size: 1.1 KB

Versions: 9

Compression:

Stored size: 1.1 KB

Contents

(function(flapjack, Medium) {
  // Shorthands
  // The application container
  var app = flapjack.app;

  Medium.Model = Backbone.JSONAPIModel.extend({
    name: 'media',
    initialize: function(){
      this.on('change', this.setDirty, this);
    },
    defaults: {
      type: null,
      address: '',
      interval: 60,
      rollup_threshold: 3,
      id: null,
      links: {},
    },
    toJSON: function() {
      return _.pick(this.attributes, 'id', 'type', 'address', 'interval', 'rollup_threshold');
    },
    sync: function(method, model, options) {
      if ( method == 'create') {
        options.url = flapjack.api_url + '/contacts/' + model.contact.get('id') + '/' + this.name;
      } else {
        options.url = flapjack.api_url + '/' + this.name + '/' + model.contact.get('id') + '_' + model.get('type');
      }
      Backbone.JSONAPIModel.prototype.sync(method, model, options);
    }

  });

  Medium.List = Backbone.JSONAPICollection.extend({
    model:      Medium.Model,
    comparator: 'type',
    url: function() { return flapjack.api_url + "/media"; }
  });

})(flapjack, flapjack.module("medium"));

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
flapjack-0.9.4 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-0.9.3 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.0.0rc3 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.0.0rc2 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-0.9.2 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-0.9.1 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.0.0rc1 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-0.9.0 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-0.8.12 lib/flapjack/gateways/web/public/js/modules/medium.js