-
-
Save cpojer/1155881 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
/*<ltIE9>*/ | |
if (!window.addEventListener) (function(){ | |
var update = function(event){ | |
event.target.store('$change', event.target.checked); | |
}; | |
Element.Events.change = { | |
base: 'click', | |
condition: function(event){ | |
var target = event.target; | |
if (target.type != 'radio') return true; | |
return (event.type == 'keyup') ? !target.checked : target.checked; | |
}, | |
onAdd: function(fn){ | |
if (this.type == 'checkbox' || this.type == 'radio') this.addEvents(this.retrieve('$change:events', { | |
focus: update, | |
keydown: update, | |
keyup: function(event){ | |
var code = event.which || event.keyCode, | |
element = event.target, | |
value = element.retrieve('$change'); | |
if (value != null && value != element.checked && (type == 'checkbox' && code == 32) || (type == 'radio' && code >= 37 && code <= 39)) fn.call(this, event) | |
} | |
}); | |
}, | |
onRemove: function(){ | |
this.removeEvents(this.retrieve('$change:events')).eliminate('$change:events'); | |
} | |
}; | |
})(); | |
/*</ltIE9>*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment