Sha256: 92d3f6033cad42491ffd3823cd36d8498551c40b04902c412785da285b7c10ba

Contents?: true

Size: 1.35 KB

Versions: 10

Compression:

Stored size: 1.35 KB

Contents

$(function () {

  // add the batch ids to any submit of a batch update
  var batch_ids = null;
  $('input.updates-batches').on('click', function() {  
    var form = $(this).closest("form"); 
    var hash, id;

    // pull the ids from the url
    if (!batch_ids) {
      batch_ids = [];
      // pull the ids from the url
      var q = document.URL.split('?')[1];
      if(q != undefined){
          q = q.split('&');
          for(var i = 0; i < q.length; i++){
              hash = q[i].split('=');
              if (hash[0] == "batch_document_ids%5B%5D")
                 batch_ids.push(unescape(hash[1]));
          }
       }
    }

    // push the ids in the form
    for(var j = 0; j < batch_ids.length; j++){
      if (form.children("input[value='"+batch_ids[j]+"']").length == 0)
        form.append('<input type="hidden" multiple="multiple" name="batch_document_ids[]" value="'+batch_ids[j]+'" />');
    }
      
  });
  $('input.submits-batches').on('click', function() {  
      var form = $(this).closest("form"); 
      $.map( $(".batch_document_selector:checked"), function(document, i) {
         var id = document.id.substring("batch_document_".length);
         if (form.children("input[value='"+id+"']").length == 0)
           form.append('<input type="hidden" multiple="multiple" name="batch_document_ids[]" value="'+id+'" />');
      });
  
      
  });

});

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
hydra-collections-2.0.1 app/assets/javascripts/hydra/batch_select.js
hydra-collections-2.0.0 app/assets/javascripts/hydra/batch_select.js
hydra-collections-1.3.2 app/assets/javascripts/hydra/batch_select.js
hydra-collections-1.3.1 app/assets/javascripts/hydra/batch_select.js
hydra-collections-1.3.0 app/assets/javascripts/hydra/batch_select.js
hydra-collections-1.2.0 app/assets/javascripts/hydra/batch_select.js
hydra-collections-1.2.0.rc1 app/assets/javascripts/hydra/batch_select.js
hydra-collections-1.1.0 app/assets/javascripts/hydra/batch_select.js
hydra-collections-1.0.0 app/assets/javascripts/hydra/batch_select.js
hydra-collections-0.0.2 app/assets/javascripts/hydra/batch_select.js