Sha256: e41bbb9dddfa88ca5bc5b708cc335e7936899da4a5b36f77ca9dab3e5ae0bfe2

Contents?: true

Size: 1.22 KB

Versions: 11

Compression:

Stored size: 1.22 KB

Contents

function toggleTrophy(url, anchor) {
  $.ajax({
     url: url,
     type: "post",
     success: function(data) {
       gid = data.work_id;
       if (anchor.hasClass("trophy-on")){
         // we've just removed the trophy
         trophyOff(anchor);
       } else {
         trophyOn(anchor);
       }

       anchor.toggleClass("trophy-on");
       anchor.toggleClass("trophy-off");
     }
  });
}
// Trophy will be removed from the public profile page
function trophyOff(anchor) {
    if (anchor.data('removerow')) {
        $('#trophyrow_'+gid).fadeOut(1000, function() {
            $('#trophyrow_'+gid).remove();
        });
    } else {
        setAnchorAttrs(anchor, 'Highlight work', 'add-text');
    }
}

function trophyOn(anchor) {
    setAnchorAttrs(anchor, 'Unhighlight work', 'remove-text');
}

function setAnchorAttrs(anchor, title, data) {
    anchor.attr('title', title);
    $nodes = anchor.contents();
    $nodes[$nodes.length - 1].nodeValue = anchor.data(data)
}

Blacklight.onLoad( function() {
  // #this method depends on a "current_user" global variable having been set.
  $('.trophy-class').on("click", function(evt){
    evt.preventDefault();
    anchor = $(this);
    toggleTrophy(anchor.data('url'), anchor);
  });
});

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
hyrax-5.0.1 app/assets/javascripts/hyrax/trophy.js
hyrax-5.0.0 app/assets/javascripts/hyrax/trophy.js
hyrax-5.0.0.rc3 app/assets/javascripts/hyrax/trophy.js
hyrax-5.0.0.rc2 app/assets/javascripts/hyrax/trophy.js
hyrax-5.0.0.rc1 app/assets/javascripts/hyrax/trophy.js
hyrax-4.0.0 app/assets/javascripts/hyrax/trophy.js
hyrax-4.0.0.rc3 app/assets/javascripts/hyrax/trophy.js
hyrax-4.0.0.rc2 app/assets/javascripts/hyrax/trophy.js
hyrax-4.0.0.rc1 app/assets/javascripts/hyrax/trophy.js
hyrax-4.0.0.beta2 app/assets/javascripts/hyrax/trophy.js
hyrax-4.0.0.beta1 app/assets/javascripts/hyrax/trophy.js