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

20 lines
750 B
JavaScript
Raw Permalink Normal View History

2013-10-27 01:06:58 +02:00
(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);