Sha256: 32a61b1e97a65ea8ac9291c9fa364e5a7f055cecf898d14b2235d48145bf0b1a

Contents?: true

Size: 1.62 KB

Versions: 87

Compression:

Stored size: 1.62 KB

Contents

function setWeight(node, weight) {
  weightField(node).val(weight);
}

/* find the input element with data-property="order" that is nested under the given node */
function weightField(node) {
  return findProperty(node, "order");
}

function findProperty(node, property) {
  return node.find("input[data-property=" + property + "]");
}

function findNode(id, container) {
  return container.find("[data-id="+id+"]");
}

function dragAndDrop(selector) {
  selector.nestable({maxDepth: 1});
  selector.on('change', function(event) {
    // Scope to a container because we may have two orderable sections on the page
    container = $(event.currentTarget);
    var data = $(this).nestable('serialize')
    var weight = 0;
    for(var i in data){
      var parent_id = data[i]['id'];
      parent_node = findNode(parent_id, container);
      setWeight(parent_node, weight++);
    }
  });
}

Blacklight.onLoad(function() {
  $('a[data-behavior="feature"]').on('click', function(evt) {
    evt.preventDefault();
    anchor = $(this);
    $.ajax({
       url: anchor.attr('href'),
       type: "post",
       success: function(data) {
         anchor.addClass('collapse');
         $('a[data-behavior="unfeature"]').removeClass('collapse')

       }
    });
  });

  $('a[data-behavior="unfeature"]').on('click', function(evt) {
    evt.preventDefault();
    anchor = $(this);
    $.ajax({
       url: anchor.attr('href'),
       type: "post",
       data: {"_method":"delete"},
       success: function(data) {
         anchor.addClass('collapse');
         $('a[data-behavior="feature"]').removeClass('collapse')
       }
    });
  });

  dragAndDrop($('#dd'));
});

Version data entries

87 entries across 87 versions & 2 rubygems

Version Path
hyrax-5.1.0.pre.beta1 app/assets/javascripts/hyrax/featured_works.js
hyrax-5.0.4 app/assets/javascripts/hyrax/featured_works.js
hyrax-5.0.3 app/assets/javascripts/hyrax/featured_works.js
hyrax-5.0.2 app/assets/javascripts/hyrax/featured_works.js
hyrax-5.0.1 app/assets/javascripts/hyrax/featured_works.js
hyrax-5.0.0 app/assets/javascripts/hyrax/featured_works.js
hyrax-5.0.0.rc3 app/assets/javascripts/hyrax/featured_works.js
hyrax-5.0.0.rc2 app/assets/javascripts/hyrax/featured_works.js
hyrax-5.0.0.rc1 app/assets/javascripts/hyrax/featured_works.js
hyrax-3.6.0 app/assets/javascripts/hyrax/featured_works.js
hyrax-4.0.0 app/assets/javascripts/hyrax/featured_works.js
hyrax-4.0.0.rc3 app/assets/javascripts/hyrax/featured_works.js
hyrax-4.0.0.rc2 app/assets/javascripts/hyrax/featured_works.js
hyrax-4.0.0.rc1 app/assets/javascripts/hyrax/featured_works.js
hyrax-3.5.0 app/assets/javascripts/hyrax/featured_works.js
hyrax-4.0.0.beta2 app/assets/javascripts/hyrax/featured_works.js
hyrax-3.4.2 app/assets/javascripts/hyrax/featured_works.js
hyrax-4.0.0.beta1 app/assets/javascripts/hyrax/featured_works.js
hyrax-3.4.1 app/assets/javascripts/hyrax/featured_works.js
hyrax-3.4.0 app/assets/javascripts/hyrax/featured_works.js