Sha256: 88194bc3baf0322947353461b7d59a4358bbc7651f81bcef16ffe12dced153df

Contents?: true

Size: 1.69 KB

Versions: 1

Compression:

Stored size: 1.69 KB

Contents

module BootstrapIt
  #
  module ViewHelpers
    #
    # Table
    #
    # @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
    #
    # @see http://getbootstrap.com/css/#tables Bootstrap docs
    class Table < WrapIt::Container
      html_class 'table'
      html_class_prefix 'table-'

      switch :striped, html_class: true
      switch :bordered, html_class: true
      switch :hover, html_class: true
      switch :condensed, html_class: true
      switch :responsive do |value|
        value && wrap(class: 'table-responsive')
      end

      child :row, 'BootstrapIt::ViewHelpers::TableRow'

      after_initialize { @tag = 'table' }
    end

    #
    # TableRow
    #
    # @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
    #
    class TableRow < WrapIt::Container
      include Contextual

      child :cell, 'BootstrapIt::ViewHelpers::TableCell'
      alias_method :td, :cell

      child :head, 'BootstrapIt::ViewHelpers::TableCell', tag: 'th'
      alias_method :th, :head
      alias_method :header, :head

      after_initialize { @tag = 'tr' }
    end

    #
    # TableCell
    #
    # @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
    #
    class TableCell < WrapIt::Base
      include WrapIt::TextContainer
      include SizableColumn
      include Contextual

      after_initialize do
        header = !@arguments.extract_first!([:header, :head, :th]).nil?
        header ||= @options[:header] == true || @options[:head] == true ||
          @options[:th] == true
        @options.delete(:header)
        @options.delete(:head)
        @options.delete(:th)
        @tag = header || @tag == 'th' ? 'th' : 'td'
      end
    end

    register :table, 'BootstrapIt::ViewHelpers::Table'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bootstrap_it-0.1.2 lib/bootstrap_it/view_helpers/table.rb