Sha256: 9b3b2c287cd285655121ab5678245181da7f98cc0553f97f70f2c3c975713288

Contents?: true

Size: 1010 Bytes

Versions: 2

Compression:

Stored size: 1010 Bytes

Contents

module Bootstrap
  module ViewHelpers
    module Components
      class Button < Component
        class Close < Button
          def to_html
            button_tag(html_options) do
              content_tag(:span, '×', aria: { hidden: true })
            end
          end

          protected

          attr_reader :dismiss

          def verify_disabled_link
            return unless options[:disabled]
            options[:tabindex] = '-1'
          end

          def inject_data_attributes
            super
            @dismiss = options.delete(:dismiss) || 'modal'
          end

          def inject_class_name_to_options
            options[:class] ||= ''
            options[:class] << ' close'
          end

          def inject_aria_attributes
            options[:aria] ||= {}
            options[:aria][:label] = 'Fechar'
          end

          def html_options
            options.merge({ type: :button, data: { dismiss: dismiss } })
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bootstrap-view_helpers-0.0.3 lib/bootstrap/view_helpers/components/button/close.rb
bootstrap-view_helpers-0.0.2 lib/bootstrap/view_helpers/components/button/close.rb