Sha256: fac984d89b89eee149e5d70b0eb8173234e257cbd1515ef403d70ed0294e7abb

Contents?: true

Size: 1.29 KB

Versions: 82

Compression:

Stored size: 1.29 KB

Contents

HAL.Views.Links = Backbone.View.extend({
  initialize: function(opts) {
    this.vent = opts.vent;
  },

  events: {
    'click .follow': 'followLink',
    'click .non-get': 'showNonSafeRequestDialog',
    'click .query': 'showUriQueryDialog',
    'click .dox': 'showDocs'
  },

  className: 'links',

  followLink: function(e) {
    e.preventDefault();
    var $target = $(e.currentTarget);
    var uri = $target.attr('href');
    window.location.hash = uri;
  },

  showUriQueryDialog: function(e) {
    e.preventDefault();

    var $target = $(e.currentTarget);
    var uri = $target.attr('href');

    new HAL.Views.QueryUriDialog({
      href: uri
    }).render({});
  },

  showNonSafeRequestDialog: function(e) {
    e.preventDefault();

    var postForm = (HAL.customPostForm !== undefined) ? HAL.customPostForm : HAL.Views.NonSafeRequestDialog;
    var d = new postForm({
      href: $(e.currentTarget).attr('href'),
      vent: this.vent
    }).render({})
  },

  showDocs: function(e) {
    e.preventDefault();
    var $target = $(e.target);
    var uri = $target.attr('href') || $target.parent().attr('href');
    this.vent.trigger('show-docs', { url: uri });
  },

  template: _.template($('#links-template').html()),

  render: function(links) {
    this.$el.html(this.template({ links: links }));
  }
});

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
pact_broker-2.83.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.82.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.81.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.80.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.79.1 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.79.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.78.1 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.78.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.77.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.76.2 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.76.1 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.76.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.75.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.74.1 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.74.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.73.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.72.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.71.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.70.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.69.0 vendor/hal-browser/js/hal/views/links.js