Sha256: 329502d369df1b51d4e3788facb19a6f7e589501a7db7f6d6ffba82e41381b1f

Contents?: true

Size: 1.17 KB

Versions: 21

Compression:

Stored size: 1.17 KB

Contents

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

  Medium.Model = Backbone.JSONAPIModel.extend({
    name: 'media',
    initialize: function(){
      Backbone.JSONAPIModel.prototype.initialize.apply(this, arguments);
      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

21 entries across 21 versions & 1 rubygems

Version Path
flapjack-1.6.0 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.6.0rc4 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.6.0rc3 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.6.0rc2 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.6.0rc1 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.5.0 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.5.0rc1 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.4.0 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.4.0rc1 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.3.0 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.3.0rc3 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.3.0rc2 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.3.0rc1 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.2.2 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.2.1 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.2.1rc3 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.2.1rc2 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.2.1rc1 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.2.0 lib/flapjack/gateways/web/public/js/modules/medium.js
flapjack-1.2.0rc2 lib/flapjack/gateways/web/public/js/modules/medium.js