Sha256: d3e826b0aec42b9e69c09a4ed5cda9c2cd566b97ddd8e4856978bfced1644dda

Contents?: true

Size: 1.64 KB

Versions: 7

Compression:

Stored size: 1.64 KB

Contents

module MxitRailsHelper

  def mxit_validation_message
    @_mxit_validation_messages.first
  end

  def mxit_table_row *styles
    str = ''
    if @_mxit.has_table
      # Close the previous row if there is one
      str += "<br /></td></tr>"
    else
      # Start a new table
      str += '<table title="mxit:table:full" style="width:100%" name="main_table" cellspacing="0" cellpadding="0">'
      str += '<colgroup span="1" width="100%"></colgroup>'
    end
    @_mxit.has_table = true

    # Start the new row
    style = styles.empty? ? mxit_style(:body) : mxit_style(*styles)
    str += "<tr><td style=\"#{ style }\">"
    str.html_safe
  end

  def mxit_style *names
    content = []
    names.each do |name|
      content << MxitRails::Styles.get(name) || ''
    end
    content.join(' ').html_safe
  end

  def mxit_proceed content
    "<br /><b style=\"#{ mxit_style :link }\"> &gt; #{content}</b><br />".html_safe
  end

  def mxit_select_row label, value, selected
    @_mxit_select_index ||= 0
    @_mxit_select_index += 1

    target = "#{request.path}?"
    if @_mxit.multi_select
      # Which input to modify, and which key to toggle for that input
      target += "_mxit_rails_multi_select=#{@_mxit.select}&_mxit_rails_multi_select_value=#{value}"
    else
      target += "_mxit_rails_submit=true&#{@_mxit.select}=#{value}"
    end

    content = selected ? "<b>#{label}</b>" : label

    output = "<a href=\"#{target}\">"
    if @_mxit.numbered_list
      output += "#{@_mxit_select_index})</a> #{content}"
    else
      output += "#{label}</a>"
      output = (selected ? '+ ' : '- ') + output
    end
    output += "<br />"

    output.html_safe
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mxit-rails-0.4.3 app/helpers/mxit_rails_helper.rb
mxit-rails-0.4.2 app/helpers/mxit_rails_helper.rb
mxit-rails-0.4.1 app/helpers/mxit_rails_helper.rb
mxit-rails-0.4.0 app/helpers/mxit_rails_helper.rb
mxit-rails-0.3.4 app/helpers/mxit_rails_helper.rb
mxit-rails-0.3.3 app/helpers/mxit_rails_helper.rb
mxit-rails-0.3.2 app/helpers/mxit_rails_helper.rb