Created
November 14, 2012 16:47
-
-
Save mikebaldry/4073246 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class ClickTracking | |
| constructor: -> | |
| @lastX = -1 | |
| @lastY = -1 | |
| this._hookEvent() | |
| $(document).on "click", "*", (e) => | |
| this._trackClick(e) | |
| _trackClick: (e) -> | |
| return if e.pageX == @lastX && e.pageY == @lastY | |
| console.log "clicked at #{e.pageX}, #{e.pageY}" | |
| @lastX = e.pageX | |
| @lastY = e.pageY | |
| _hookEvent: -> | |
| jQuery.Event.prototype._prevPreventDefault = jQuery.Event.prototype.preventDefault | |
| jQuery.Event.prototype.preventDefault = -> | |
| window.GlobalClientStats.ClickTracking._trackClick(this) if this.type == "click" | |
| jQuery.Event.prototype._prevPreventDefault() | |
| jQuery.Event.prototype._prevStopPropagation = jQuery.Event.prototype.stopPropagation | |
| jQuery.Event.prototype.stopPropagation = -> | |
| window.GlobalClientStats.ClickTracking._trackClick(this) if this.type == "click" | |
| jQuery.Event.prototype._prevStopPropagation() | |
| window.GlobalClientStats.ClickTracking = new ClickTracking() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment