Skip to content

Instantly share code, notes, and snippets.

@opi
Created May 6, 2015 09:27
Show Gist options
  • Save opi/8750eba32e4a02efa752 to your computer and use it in GitHub Desktop.
Save opi/8750eba32e4a02efa752 to your computer and use it in GitHub Desktop.
enlarge your click
// From https://github.com/opi/basement/blob/7.x-1.x/js/basement.js#L29
// Enlarge Your Click Zone : allow link'parent element to be clickable too
var enlargeYourClick = function(selector){
$(selector).click(function(e){
// don't handle if user click on a link, or if he click with mouse wheel
if (e.target.tagName != "A" && e.button != 1) {
var firstLink = $(this).find('a:first'),
dest = firstLink.attr('href'),
blank = firstLink.attr('target');
if (dest && !blank) {
window.location = dest
}else if (blank){
window.open(dest);
};
}
})
.css({cursor: 'pointer'});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment