Sha256: 4f241e39c3925110e870bcaedb4127cebe2b2f706321d3a11ecbdc72b6d6ce64

Contents?: true

Size: 1.29 KB

Versions: 15

Compression:

Stored size: 1.29 KB

Contents

module Celerity
  
  #
  # Input: Button
  #
  # Class representing 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

15 entries across 15 versions & 2 rubygems

Version Path
jarib-celerity-0.0.5.10 lib/celerity/elements/button.rb
jarib-celerity-0.0.5.11 lib/celerity/elements/button.rb
jarib-celerity-0.0.5.6 lib/celerity/elements/button.rb
jarib-celerity-0.0.5.7 lib/celerity/elements/button.rb
jarib-celerity-0.0.5.8 lib/celerity/elements/button.rb
jarib-celerity-0.0.5.9 lib/celerity/elements/button.rb
jarib-celerity-0.0.6.1 lib/celerity/elements/button.rb
jarib-celerity-0.0.6.2 lib/celerity/elements/button.rb
jarib-celerity-0.0.6.3 lib/celerity/elements/button.rb
jarib-celerity-0.0.6.4 lib/celerity/elements/button.rb
jarib-celerity-0.0.6.5 lib/celerity/elements/button.rb
jarib-celerity-0.0.6.6 lib/celerity/elements/button.rb
jarib-celerity-0.0.6.7 lib/celerity/elements/button.rb
jarib-celerity-0.0.6 lib/celerity/elements/button.rb
celerity-0.0.6 lib/celerity/elements/button.rb