Sha256: 0acc7928086d0bd6de590aebb8f2cc6962dafb34937f608df6872fdf1f90e4e8

Contents?: true

Size: 1.9 KB

Versions: 33

Compression:

Stored size: 1.9 KB

Contents

(function( $ ){

  $.fn.proxyRights = function( options ) {

    // Create some defaults, extending them with any options that were provided
    var settings = $.extend( { }, options);

    var $container = this;

    function addContributor(name, user_key, grantor) {
      data = {name: name, user_key: user_key}

      $.ajax({
        type: "POST",
        url: '/users/'+grantor+'/depositors',
        dataType: 'json',
        data: {grantee_id: user_key},
        success: function (data) {
          if (data.name !== undefined) {
            row = rowTemplate(data);
            $('#authorizedProxies tbody', $container).append(row);
            if (settings.afterAdd)
              settings.afterAdd(this, cloneElem);
          }
        }
      })
      return false;
    }

    function removeContributor(event) {
      event.preventDefault();
      $.ajax({
        url: $(this).closest('a').prop('href'),
        type: "post",
        dataType: "json",
        data: {"_method":"delete"}
      });
      $(this).closest('tr').remove();
      return false;
    }

    function rowTemplate (data) {
      return '<tr>'+
                '<td class="depositor-name">'+data.name+'</td>'+
                '<td><a class="remove-proxy-button btn btn-danger" data-method="delete" href="'+data.delete_path+'" rel="nofollow">'+
                $('#delete_button_label').data('label')+'</a>'+
                '</td>'+
              '</tr>'
    }

    $("#user").userSearch();
    $("#user").on("change", function() {
      // Remove the choice from the select2 widget and put it in the table.
      obj = $("#user").select2("data")
      grantor = $('#user').data('grantor')
      $("#user").select2("val", '')
      addContributor(obj.text, obj.user_key, grantor);
    });

    $('body').on('click', 'a.remove-proxy-button', removeContributor);

  };

})( jQuery );

Blacklight.onLoad(function() {
  $('.proxy-rights').proxyRights();
});

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-2.9.5 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-2.9.4 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-2.9.3 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-2.9.2 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-2.9.1 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-2.9.0 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-2.8.0 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-2.7.2 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-2.7.1 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-2.7.0 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-2.6.0 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-2.5.1 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-2.5.0 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-3.0.0.pre.beta2 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-2.4.1 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-3.0.0.pre.beta1 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-2.4.0 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-2.3.3 app/assets/javascripts/hyrax/proxy_rights.js
hyrax-2.3.2 app/assets/javascripts/hyrax/proxy_rights.js