Last active
August 29, 2015 14:10
-
-
Save e-river/9d5e70b8b2e49a28d000 to your computer and use it in GitHub Desktop.
PointerEvents for less than IE10
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
$(function(){ | |
var pointer = new PointerEvent(); | |
pointer.load(); | |
}); | |
function PointerEvent(){ | |
this.userAgent = window.navigator.userAgent.toLowerCase(); | |
this.appVersion = window.navigator.appVersion.toLowerCase(); | |
this.target = $('.cp-image'); | |
this.pointer = $('.click-shield'); | |
} | |
PointerEvent.prototype.load = function(){ | |
var self = this; | |
self.init(); | |
self.exe(); | |
}; | |
PointerEvent.prototype.init = function(){ | |
var self = this; | |
if(self.userAgent.indexOf("msie") !== -1) { | |
if(self.appVersion.indexOf("msie 10.") !== -1) { | |
self.addedClass(); | |
} else if(self.appVersion.indexOf("msie 9.") !== -1) { | |
self.addedClass(); | |
} else if(self.appVersion.indexOf("msie 8.") !== -1) { | |
self.addedClass(); | |
} | |
} | |
}; | |
PointerEvent.prototype.addedClass = function() { | |
var self = this; | |
self.target.addClass('click-shield'); | |
}; | |
PointerEvent.prototype.exe = function(){ | |
var self = this; | |
if(self.target.hasClass('click-shield')){ | |
self.target.on('click', 'a', $.proxy(self.event, self)); | |
} | |
}; | |
PointerEvent.prototype.event = function(e){ | |
e.preventDefault(); | |
e.stopPropagation(); | |
}; |
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
.click-shield a { | |
cursor: default; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment