Sha256: 5050d67ce3ed7059a2bd90047a61cd6dc9742d7552982338696baf155d6e9bd6

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 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)) ]
    # A little wierd attribute list due to button being both <button> and <input type="submit|reset|image|button" />
    ATTRIBUTES = BASE_ATTRIBUTES | [:type, :disabled, :tabindex, :accesskey, :onfocus, :onblur] | [:src, :usemap, :ismap]
    DEFAULT_HOW = :value

    def locate
      # ugly..
      if (val = @conditions[:value])
        locator = ElementLocator.new(@container.object, self.class)
        button_ident = Identifier.new('button')
        button_ident.text = val
        input_ident = Identifier.new('input', :type => %w(submit reset image button), :value => [val])
        locator.idents = [button_ident, input_ident]
        conditions = @conditions.dup
        conditions.delete(:value)
        @object = locator.find_by_conditions(conditions)
      else
        super
      end
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
celerity-0.0.3 lib/celerity/elements/button.rb