Skip to content

Commit

Permalink
Add shorted event control names
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Jan 12, 2014
1 parent 7d3c228 commit 1a4a76b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,9 @@

* Add `Document.body` and `Document.head` shortcut to element instances.

* Add `Event` methods: `prevented?`, `prevent`, `stopped?` and `stop` to
replace longer javascript names.

## 0.1.2 2013-12-01

* Support setting html content through `Element#html()`.
Expand Down
21 changes: 14 additions & 7 deletions opal/opal-jquery/event.rb
Expand Up @@ -26,32 +26,39 @@ def target
##
# Propagation

def default_prevented?
def prevented?
`#@native.isDefaultPrevented()`
end

def prevent_default
def prevent
`#@native.preventDefault()`
end

def propagation_stopped?
def stopped?
`#@native.propagationStopped()`
end

def stop_propagation
def stop
`#@native.stopPropagation()`
end

def stop_immediate_propagation
def stop_immediate
`#@native.stopImmediatePropagation()`
end

# Stops propagation and prevents default action.
def kill
stop_propagation
prevent_default
stop
prevent
end

# to be removed?
alias default_prevented? prevented?
alias prevent_default prevent
alias propagation_stopped? stopped?
alias stop_propagation stop
alias stop_immediate_propagation stop_immediate

##
# Keyboard/Mouse/Touch

Expand Down

0 comments on commit 1a4a76b

Please sign in to comment.