mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-25 19:48:48 +01:00
Move font calculation into tag cloud
This commit is contained in:
parent
2321d1f2a3
commit
d478efdd01
2 changed files with 11 additions and 3 deletions
|
|
@ -10,10 +10,20 @@ module Stats
|
|||
@levels = 10
|
||||
end
|
||||
|
||||
def empty?
|
||||
tags.empty?
|
||||
end
|
||||
|
||||
def font_size(tag)
|
||||
(9 + 2*(tag.count.to_i-min)/divisor)
|
||||
end
|
||||
|
||||
def tags
|
||||
@tags ||= top_tags
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def max
|
||||
@max ||= tag_counts.max
|
||||
end
|
||||
|
|
@ -30,8 +40,6 @@ module Stats
|
|||
@divisor ||= ((max - min) / levels) + 1
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def tag_counts
|
||||
@tag_counts ||= tags.map {|t| t.count.to_i}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
else
|
||||
tag_cloud.tags.each do |t| %>
|
||||
<%= link_to t.name, tag_path(t.name), {
|
||||
:style => "font-size: " + (9 + 2*(t.count.to_i-tag_cloud.min)/tag_cloud.divisor).to_s + "pt",
|
||||
:style => "font-size: " + "#{tag_cloud.font_size(t)}pt",
|
||||
:title => t.count.to_s+" #{t('common.actions_midsentence', :count => t.count)}"}
|
||||
-%> <%
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue