Sha256: da11dbf329ef1f700ba56e45b61baa53432cf232aa9d81b7a861de8f6c36453c

Contents?: true

Size: 844 Bytes

Versions: 2

Compression:

Stored size: 844 Bytes

Contents

module Browser; module DOM

class Document < Element
  # @!attribute [r] active_element
  # @return [Element] the element with focus
  def active_element
    DOM(`#@native.activeElement`)
  end
end

class Element
  # Show the element.
  #
  # @param what [Symbol] how to display it
  def show(what = :block)
    style[:display] = what
  end

  # Hide the element.
  def hide
    style[:display] = :none
  end

  # Toggle the visibility of the element, hide it if it's shown, show it if
  # it's hidden.
  def toggle
    if style![:display] == :none
      show
    else
      hide
    end
  end

  # Set the focus on the element.
  def focus
    `#@native.focus()`
  end

  # Blur the focus from the element.
  def blur
    `#@native.blur()`
  end

  # Check if the element is focused.
  def focused?
    `#@native.hasFocus`
  end
end

end; end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
diamonds-0.1.5 lib/diamonds/opal/browser/effects.rb
opal-browser-0.2.0 opal/browser/effects.rb