Sha256: eb06767a277e6201a16bdb089122090833627591121d72ae0343739e1573272d

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

module Picky

  # This class provides a few view helpers.
  #
  class Helper
    
    @@localized_interface = lambda { |options|
      search_button_text = options[:button]     || 'search'
      no_results         = options[:no_results] || 'Sorry, no results found!'
      more_allocations   = options[:more]       || 'more'
<<-HTML
<div id="picky">
  <div class="dashboard empty">
    <div class="feedback">
      <div class="status"></div>
      <input type="text" autocorrect="off" class="query"/>
      <div class="reset" title="clear"></div>
    </div>
    <input type="button" class="search_button" value="#{search_button_text}">
  </div>
  <ol class="results"></ol>
  <div class="no_results">#{no_results}</div>
  <div class="allocations">
    <ol class="shown"></ol>
    <ol class="more">#{more_allocations}</ol>
    <ol class="hidden"></ol>
  </div>
</div>
HTML
    }
    
    # Returns a standard search interface for easy starting.
    #
    # ... aka scaffolding ;)
    #
    # Options:
    #  * button: The search button text.
    #  * no_results: The text shown when there are no results.
    #  * more: The text shown when there are more than X results.
    #
    # Usage, in Views:
    #
    #   = Picky::Helper.interface :button => 'Go go go!'
    #
    #
    def self.interface options = {}
      @@localized_interface[options].gsub!(/[\n]/, '').squeeze! ' '
    end
    
    # Returns a cached version if you always use a single language.
    #
    def self.cached_interface options = {}
      @interface ||= interface.freeze
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picky-client-0.0.4 lib/picky-client/helper.rb