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.55.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.54.0 vendor/hal-browser/js/hal/views/links.js