Sha256: ab6ca85116ff30a55fbe882784f310c63210bc8f0ebed7e7e8ee5af79ae36578

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

module Celerity

  #
  # Input: Button
  #
  # Class representing button elements.
  #
  # This class covers both <button> and <input type="submit|reset|image|button" /> elements.
  #

  class Button < InputElement
    TAGS = [ Identifier.new('button'),
             Identifier.new('input', :type => %w[submit reset image button]) ]

    # Attribute list is a little weird due to this class covering both <button>
    # and <input type="submit|reset|image|button" />
    ATTRIBUTES = BASE_ATTRIBUTES | [:type, :disabled, :tabindex, :accesskey, :onfocus, :onblur] | [:src, :usemap, :ismap]
    DEFAULT_HOW = :value

    #
    # @api private
    #

    def locate
      # We want the :value attribute to point to the inner HTML for <button> elements,
      # and to the value attribute for <input type="button"> elements.

      if (val = @conditions[:value])
        button_ident      = Identifier.new('button')
        button_ident.text = val
        input_ident       = Identifier.new('input', :type => %w[submit reset image button], :value => [val])

        locator        = ElementLocator.new(@container, self.class)
        locator.idents = [button_ident, input_ident]

        conditions = @conditions.dup
        conditions.delete(:value)
        @object = locator.find_by_conditions(conditions)
      else
        super
      end
    end

  end # Button
end # Celerity

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
jarib-celerity-0.0.6.12 lib/celerity/elements/button.rb
regularfry-celerity-0.0.6.12 lib/celerity/elements/button.rb
walidhalabi-celerity-0.0.6.13 lib/celerity/elements/button.rb