Sha256: a1860aa3cd48f29bac7002e6826445b0271031a1496f70d3e01253d64029f5d6

Contents?: true

Size: 872 Bytes

Versions: 2

Compression:

Stored size: 872 Bytes

Contents

# backtick_javascript: true

module Browser; module DOM; class Element < Node

class Input < Element
  def_selector "input"

  def value
    %x{
      if (#@native.value == "") {
        return nil;
      }
      else {
        return #@native.value;
      }
    }
  end

  alias_native :value=
  alias_native :name_, :name
  alias_native :type
  alias_native :checked?, :checked
  alias_native :enabled?, :enabled

  def check!
    `#@native.checked = 'checked'`
  end

  def uncheck!
    `#@native.checked = ''`
  end

  def disable!
    `#@native.disabled = 'disabled'`
  end

  def enable!
    `#@native.disabled = ''`
  end

  def clear
    `#@native.value = ''`
  end

  # @!attribute [r] files
  # @return [Array<File>] list of files attached to this {Input}
  def files
    Native::Array.new(`#@native.files`).map { |f| File.new(f.to_n) }
  end
end

end; end; end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-browser-0.3.5 opal/browser/dom/element/input.rb
opal-browser-0.3.4 opal/browser/dom/element/input.rb