This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
Sequenzia/app/assets/javascripts/favorite.js
2013-10-26 18:06:58 -05:00

20 lines
750 B
JavaScript
Executable File

(function($) {
Favorite = {
link_to_users: function(users) {
var html = ""
if (users.size() == 0) {
return "no one"
} else {
html = users.slice(0, 6).map(function(x) {return '<a href="/user/show/' + x.id + '">' + x.name + '</a>'}).join(", ")
if (users.size() > 6) {
html += '<span id="remaining-favs" style="display: none;">' + users.slice(6, -1).map(function(x) {return '<a href="/user/show/' + x.id + '">' + x.name + '</a>'}).join(", ") + '</span> <span id="remaining-favs-link">(<a href="#" onclick="$(\'remaining-favs\').show(); $(\'remaining-favs-link\').hide(); return false;">' + (users.size() - 6) + ' more</a>)</span>'
}
return html
}
}
}
}) (jQuery);