Skip to content

Commit

Permalink
Remove tag cloud filter link
Browse files Browse the repository at this point in the history
  • Loading branch information
peterhellberg committed May 6, 2010
1 parent e324cd9 commit e956662
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/ur_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ def facet_link(name, facet)
link = base_link

if link.match(/fq=/)
link = link.gsub(/ao:\"[^\"]+?\"/, '') if name == 'ao'
link = link.gsub('fq=', "fq=#{name}:\"#{facet.value}\" ").
gsub(/page\=\d+/, "page=1").sub(' &', '&')
gsub(/page\=\d+/, "page=1").sub(' &', '&').gsub(' ', ' ')
else
link += '&' if link != '/?'
link = "#{link}fq=#{name}:\"#{facet.value}\"".gsub(/page\=\d+/, "page=1")
Expand All @@ -57,10 +58,12 @@ def facet_link(name, facet)
link
end

def remove_facet_link(name, facet)
def remove_facet_link(name, facet = false)
facet = (facet) ? quoted_value(facet) : '[^\"]+?'

link = base_link
link = link.gsub(/#{name}:"#{quoted_value(facet)}"[ ]{0,}/, '').
gsub('?fq=&', '?').sub(' &', '&')
link = link.gsub(/#{name}:"#{facet}"[ ]{0,}/, '').
gsub('?fq=&', '?').sub(' &', '&').sub(' ', ' ')
link
end

Expand Down
3 changes: 3 additions & 0 deletions views/index.haml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
%h4= "Ämnesord"
%ul
%li
- if !params[:fq].nil? && params[:fq].match('ao:')
%a.remove_tag_cloud_filter{ :href => remove_facet_link('ao') }
= "⊗"
= tag_cloud.html_and_css(15)
- facet_order.each do |facet_name, facet_title|
- if !search.facets[facet_name].nil? && search.facets[facet_name].size > 0
Expand Down
7 changes: 7 additions & 0 deletions views/style.sass
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ div.num_found
font-size: 1.2em
line-height: 0.7em

.remove_tag_cloud_filter
font-size: 2em
line-height: 1.2em
float: right
padding-left: 1em
margin-top: -1.4em

ul.auto-complete-list
+box-shadow(2px, 2px, 4px, rgba(122,129,136,1))
list-style-type: none
Expand Down

0 comments on commit e956662

Please sign in to comment.