Sha256: 612a8c5e7caae322021bd59ec69b52653b1c184131cce74c34e1abc693eaa627

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

module SpaghettiHelpers
  def spaghetti name, path_or_items
    output = ''.html_safe
    puts path_or_items.class.name
    if path_or_items.class.name == 'String'
      output << "<div class=\"#{ name } spaghetti\" data-spaghetti-enabled=\"1\" data-spaghetti-url=\"#{ path_or_items }\" data-spaghetti-next-page=\"1\"><div class=\"items\"></div><div class=\"throbber\">#{ image_tag 'throbber.gif' }</div></div>".html_safe
    else
      if path_or_items.any?
        output << "$('.#{ name } .items').append('#{ j render path_or_items }');".html_safe
        output << "$('.#{ name }').data('spaghetti-next-page', #{ params[:page].to_i + 1 });".html_safe
        output << "$('.#{ name }').data('spaghetti-enabled', '1');".html_safe
      else
        output << "$('.#{ name }').data('spaghetti-enabled', '0');".html_safe
        output << "$('.#{ name }').append($('<div class=\"spaghetti-disabled\"></div>'));".html_safe
      end
      output << "$('.#{ name }').removeClass('spaghetti-loading');".html_safe
    end
    output
  end  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spaghetti-0.2.6 app/helpers/spaghetti_helpers.rb