Skip to content

Instantly share code, notes, and snippets.

@e-river
Last active August 29, 2015 14:10
Show Gist options
  • Save e-river/9d5e70b8b2e49a28d000 to your computer and use it in GitHub Desktop.
Save e-river/9d5e70b8b2e49a28d000 to your computer and use it in GitHub Desktop.
PointerEvents for less than IE10
$(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();
};
.click-shield a {
cursor: default;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment