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.6.0 app/assets/javascripts/hyrax/trophy.js
hyrax-3.5.0 app/assets/javascripts/hyrax/trophy.js
hyrax-3.4.2 app/assets/javascripts/hyrax/trophy.js
hyrax-3.4.1 app/assets/javascripts/hyrax/trophy.js
hyrax-3.4.0 app/assets/javascripts/hyrax/trophy.js
hyrax-3.3.0 app/assets/javascripts/hyrax/trophy.js
hyrax-3.2.0 app/assets/javascripts/hyrax/trophy.js
hyrax-2.9.6 app/assets/javascripts/hyrax/trophy.js
hyrax-3.1.0 app/assets/javascripts/hyrax/trophy.js
hyrax-2.9.5 app/assets/javascripts/hyrax/trophy.js
hyrax-3.0.2 app/assets/javascripts/hyrax/trophy.js
hyrax-3.0.1 app/assets/javascripts/hyrax/trophy.js
hyrax-3.0.0 app/assets/javascripts/hyrax/trophy.js
hyrax-3.0.0.pre.rc4 app/assets/javascripts/hyrax/trophy.js
hyrax-2.9.4 app/assets/javascripts/hyrax/trophy.js
hyrax-3.0.0.pre.rc3 app/assets/javascripts/hyrax/trophy.js
hyrax-2.9.3 app/assets/javascripts/hyrax/trophy.js
hyrax-2.9.2 app/assets/javascripts/hyrax/trophy.js
hyrax-2.9.1 app/assets/javascripts/hyrax/trophy.js
hyrax-2.9.0 app/assets/javascripts/hyrax/trophy.js