Sha256: ffbedea0a567c97e0eb4d08cce6ea2d0dd036479cc7770bdb4c92f574602a889

Contents?: true

Size: 1.61 KB

Versions: 56

Compression:

Stored size: 1.61 KB

Contents

HAL.Views.EmbeddedResource = Backbone.View.extend({
  initialize: function(opts) {
    this.vent = opts.vent;
    this.resource = opts.resource;

    this.propertiesView = new HAL.Views.Properties({});
    this.linksView = new HAL.Views.Links({
      vent: this.vent
    });

    _.bindAll(this, 'onToggleClick');
    _.bindAll(this, 'onDoxClick');
  },

  events: {
    'click a.accordion-toggle': 'onToggleClick',
    'click span.dox': 'onDoxClick'
  },

  className: 'embedded-resource accordion-group',

  onToggleClick: function(e) {
    e.preventDefault();
    this.$accordionBody.collapse('toggle');
    return false;
  },
  
  onDoxClick: function(e) {
    e.preventDefault();
    this.vent.trigger('show-docs', {
      url: $(e.currentTarget).data('href')
    });
    return false;
  },

  render: function() {
    this.$el.empty();

    this.propertiesView.render(this.resource.toJSON());
    this.linksView.render(this.resource.links);

    this.$el.append(this.template({
      resource: this.resource
    }));

    var $inner = $('<div class="accordion-inner"></div>');
    $inner.append(this.propertiesView.el);
    $inner.append(this.linksView.el);

    if (this.resource.embeddedResources) {
      var embeddedResourcesView = new HAL.Views.EmbeddedResources({ vent: this.vent });
      embeddedResourcesView.render(this.resource.embeddedResources);
      $inner.append(embeddedResourcesView.el);
    }

    this.$accordionBody = $('<div class="accordion-body collapse"></div>');
    this.$accordionBody.append($inner)

    this.$el.append(this.$accordionBody);
  },

  template: _.template($('#embedded-resource-template').html())
});

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
pact_broker-2.78.1 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.78.0 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.77.0 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.76.2 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.76.1 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.76.0 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.75.0 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.74.1 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.74.0 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.73.0 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.72.0 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.71.0 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.70.0 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.69.0 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.68.1 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.68.0 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.67.0 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.66.0 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.65.0 vendor/hal-browser/js/hal/views/embedded_resource.js
pact_broker-2.64.0 vendor/hal-browser/js/hal/views/embedded_resource.js