Sha256: 99eac1c5ec3f68d0afedc7c45cb62e57a1982f5215b4dd7e23a439d8709903e5

Contents?: true

Size: 897 Bytes

Versions: 5

Compression:

Stored size: 897 Bytes

Contents

module Browser; class Event

class Focus < UI
  handles 'blur', 'focus', 'focusin', 'focusout'

  def self.supported?
    Browser.supports? 'Event.Focus'
  end

  class Definition < UI::Definition
    def view=(value)
      `#@native.view = #{Native.convert(value)}`
    end

    def related=(elem)
      `#@native.relatedTarget = #{Native.convert(elem)}`
    end
  end

  if Browser.supports? 'Event.constructor'
    def self.construct(name, desc)
      `new FocusEvent(#{name}, #{desc})`
    end
  elsif Browser.supports? 'Event.create'
    def self.construct(name, desc)
      %x{
        var event = document.createEvent("FocusEvent");
            event.initFocusEvent(name, desc.bubbles, desc.cancelable,
              desc.view || window, 0, desc.relatedTarget);

        return event;
      }
    end
  end if supported?

  def related
    DOM(`#@native.relatedTarget`)
  end
end

end; end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
atome-opal-browser-0.3.9.5 opal/browser/event/focus.rb
opal-browser-0.3.3 opal/browser/event/focus.rb
opal-browser-0.3.2 opal/browser/event/focus.rb
opal-browser-0.3.1 opal/browser/event/focus.rb
opal-browser-0.3.0 opal/browser/event/focus.rb