Sha256: eaf2d6e7061f1f5d45602dd4bedb66c0bd02e563fb0beffb4e46dc8697c9cbc6

Contents?: true

Size: 1.21 KB

Versions: 62

Compression:

Stored size: 1.21 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').click(function(evt){
    evt.preventDefault();
    anchor = $(this);
    toggleTrophy(anchor.data('url'), anchor);
  });
});

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
hyrax-3.0.0.pre.rc2 app/assets/javascripts/hyrax/trophy.js
hyrax-2.8.0 app/assets/javascripts/hyrax/trophy.js
hyrax-2.7.2 app/assets/javascripts/hyrax/trophy.js
hyrax-2.7.1 app/assets/javascripts/hyrax/trophy.js
hyrax-2.7.0 app/assets/javascripts/hyrax/trophy.js
hyrax-2.6.0 app/assets/javascripts/hyrax/trophy.js
hyrax-3.0.0.pre.rc1 app/assets/javascripts/hyrax/trophy.js
hyrax-3.0.0.pre.beta3 app/assets/javascripts/hyrax/trophy.js
hyrax-2.5.1 app/assets/javascripts/hyrax/trophy.js
hyrax-2.5.0 app/assets/javascripts/hyrax/trophy.js
hyrax-3.0.0.pre.beta2 app/assets/javascripts/hyrax/trophy.js
hyrax-2.4.1 app/assets/javascripts/hyrax/trophy.js
hyrax-3.0.0.pre.beta1 app/assets/javascripts/hyrax/trophy.js
hyrax-2.4.0 app/assets/javascripts/hyrax/trophy.js
hyrax-2.3.3 app/assets/javascripts/hyrax/trophy.js
hyrax-2.3.2 app/assets/javascripts/hyrax/trophy.js
hyrax-2.3.1 app/assets/javascripts/hyrax/trophy.js
hyrax-2.3.0 app/assets/javascripts/hyrax/trophy.js
hyrax-2.0.3 app/assets/javascripts/hyrax/trophy.js
hyrax-2.2.4 app/assets/javascripts/hyrax/trophy.js