Sha256: 6d04b040975d8212e0d267e09f8ea213d1d7370e3e26ee3520cd8d6c11c8092c

Contents?: true

Size: 1.19 KB

Versions: 35

Compression:

Stored size: 1.19 KB

Contents

module LocationHelper
  
  # Renders the location stack for your view. You can add as many stack levels as you wish.
  #
  # Usage:  
  # <%= location(level1,leve2,level3,level4,....) %> 
  #
  # Output: 
  # base > level1 > level2 > level3 > level 4
  #
  # Default configuration:
  # base => "You are here" ("location.base" on config/locales)
  # separator => ">" ("location.separator" on config/locales)
  #
  # Styles and HTML wrapping:
  # partial => location/_location.html.erb 
  #
  # Example:  
  # 	Render a location with a two leves depth:
  #
  #   	<%= location(link_to(leve1.name, level1.url),link_to(leve2.name, level2.url)) %>
  #
  def location(*stack)
    location_body = t('location.base')
    stack.collect {|level|
      location_body << t('location.separator') + level
    }
    
    location_div = capture do
      render :partial => "location/location", :locals=>{:location_body => location_body}
    end
    
    case request.format
      when Mime::JS
      response = <<-EOJ

          $('#map_location').html("#{ escape_javascript(location_div) }");
          EOJ
      
      response.html_safe
    else
      content_for(:location) do
        location_div
      end
    end
    
  end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
social_stream-0.9.2 base/app/helpers/location_helper.rb
social_stream-base-0.9.6 app/helpers/location_helper.rb
social_stream-base-0.9.5 app/helpers/location_helper.rb
social_stream-base-0.9.4 app/helpers/location_helper.rb
social_stream-base-0.9.3 app/helpers/location_helper.rb
social_stream-base-0.9.2 app/helpers/location_helper.rb
social_stream-base-0.9.1 app/helpers/location_helper.rb
social_stream-base-0.9.0 app/helpers/location_helper.rb
social_stream-base-0.8.2 app/helpers/location_helper.rb
social_stream-base-0.8.1 app/helpers/location_helper.rb
social_stream-base-0.8.0 app/helpers/location_helper.rb
social_stream-base-0.7.11 app/helpers/location_helper.rb
social_stream-base-0.7.10 app/helpers/location_helper.rb
social_stream-base-0.7.9 app/helpers/location_helper.rb
social_stream-base-0.7.8 app/helpers/location_helper.rb
social_stream-base-0.7.7 app/helpers/location_helper.rb
social_stream-base-0.7.6 app/helpers/location_helper.rb
social_stream-base-0.7.5 app/helpers/location_helper.rb
social_stream-base-0.7.4 app/helpers/location_helper.rb
social_stream-base-0.7.3 app/helpers/location_helper.rb