Sha256: 4e07e3a783da16e2098f53f1a27584ad50905a8300d1b4ea33fcf0c9f266d610
Contents?: true
Size: 1.15 KB
Versions: 8
Compression:
Stored size: 1.15 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 function trophyOff(anchor) { if (anchor.data('removerow')) { $('#trophyrow_'+gid).fadeOut(1000, function() { $('#trophyrow_'+gid).remove(); }); } else { anchor.attr("title", "Highlight work"); $nodes = anchor.contents() $nodes[$nodes.length - 1].nodeValue = anchor.data('add-text') } } function trophyOn(anchor) { anchor.attr("title", "Unhighlight work"); $nodes = anchor.contents() $nodes[$nodes.length - 1].nodeValue = anchor.data('remove-text') } 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
8 entries across 8 versions & 1 rubygems