Sha256: 50cd830572c90775afdc142589db56903322fd1beb9b1d15f1f0abb2736546f2

Contents?: true

Size: 1.25 KB

Versions: 96

Compression:

Stored size: 1.25 KB

Contents

(function( $ ){
  $.fn.singleUseLinks = function( options ) {

    var clipboard = new Clipboard('.copy-single-use-link');

    var manager = {
      reload_table: function() {
        var url = $("table.single-use-links tbody").data('url')
        $.get(url).done(function(data) {
          $('table.single-use-links tbody').html(data);
        });
      },

      create_link: function(caller) {
        $.post(caller.attr('href')).done(function(data) {
          manager.reload_table()
        })
      },

      delete_link: function(caller) {
        $.ajax({
          url: caller.attr('href'),
          type: 'DELETE',
          done: caller.parent('td').parent('tr').remove()
        })
      }
    };

    $('.generate-single-use-link').click(function(event) {
      event.preventDefault()
      manager.create_link($(this))
      return false
    });

    $("table.single-use-links tbody").on('click', '.delete-single-use-link', function(event) {
      event.preventDefault()
      manager.delete_link($(this))
      return false;
    });

    clipboard.on('success', function(e) {
      $(e.trigger).tooltip('show');
      e.clearSelection();
    }); 

    return manager;

  };
})( jQuery );

Blacklight.onLoad(function () {
  $('.single-use-links').singleUseLinks();
});

Version data entries

96 entries across 96 versions & 3 rubygems

Version Path
hyrax-3.6.0 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-3.5.0 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-3.4.2 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-3.4.1 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-3.4.0 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-3.3.0 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-3.2.0 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-2.9.6 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-3.1.0 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-2.9.5 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-3.0.2 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-3.0.1 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-3.0.0 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-3.0.0.pre.rc4 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-2.9.4 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-3.0.0.pre.rc3 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-2.9.3 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-2.9.2 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-2.9.1 app/assets/javascripts/hyrax/single_use_links_manager.js
hyrax-2.9.0 app/assets/javascripts/hyrax/single_use_links_manager.js