Created
March 17, 2014 18:20
-
-
Save jemgold/9605170 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Batman.DOM.nodeIsEditable = (node) -> | |
if node.nodeName.toUpperCase() in ['INPUT', 'TEXTAREA', 'SELECT'] or node.hasAttribute('contenteditable') | |
return true | |
else return false | |
Batman.DOM.events.change = (node, callback, view) -> | |
eventNames = switch node.nodeName.toUpperCase() | |
when 'TEXTAREA' then ['input', 'keyup', 'change'] | |
when 'INPUT' | |
if node.type.toLowerCase() in Batman.DOM.textInputTypes | |
oldCallback = callback | |
callback = (node, event, view) -> | |
return if event.type is 'keyup' and Batman.DOM.events.isEnter(event) | |
oldCallback(node, event, view) | |
['input', 'keyup', 'change'] | |
else | |
['input', 'change'] | |
else | |
if node.hasAttribute('contenteditable') | |
['input', 'change'] | |
else | |
['change'] | |
for eventName in eventNames | |
Batman.DOM.addEventListener node, eventName, (args...) -> | |
callback node, args..., view | |
return | |
Batman.DOM.ValueBinding.prototype.nodeChange = (node, context) -> | |
if @isTwoWay() | |
@set('filteredValue', (@node.value or @node.textContent)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment