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.112.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.111.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.109.1 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.109.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.108.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.107.1 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.107.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.107.0.beta.1 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.106.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.105.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.104.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.103.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.102.2 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.102.1 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.102.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.101.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.100.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.99.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.98.0 vendor/hal-browser/js/hal/views/links.js
pact_broker-2.97.0 vendor/hal-browser/js/hal/views/links.js