Last active
January 13, 2016 13:48
-
-
Save rastersysteme/ce485a089a50fea2cf84 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
(function($){ | |
/* ---- | |
superLink jQuery plugin | |
(c) James Padolsey | |
---- | |
Contributors: | |
Brian Fisher | |
---- | |
Adapted to project | |
*/ | |
$.fn.superLink = function(link, targetElement){ | |
link = link || 'a:first'; | |
return this.each(function(){ | |
var $container = $(this), | |
$targetLink = $(link, $container).clone(true), | |
$targetElement = targetElement || $('td:first', $container); | |
// Take all current mouseout handlers of $container and | |
// transfer them to the mouseout handler of $targetLink | |
var mouseouts = $(this).data('events') && $(this).data('events').mouseout; | |
if (mouseouts) { | |
$.each(mouseouts, function(i, fn){ | |
$targetLink.mouseout(function(e){ | |
fn.call($container, e); | |
}); | |
}); | |
delete $(this).data('events').mouseout; | |
} | |
// Take all current mouseover handlers of $container and | |
// transfer them to the mouseover handler of $targetLink | |
var mouseovers = $(this).data('events') && $(this).data('events').mouseover; | |
if (mouseovers) { | |
$.each(mouseovers, function(i, fn){ | |
$targetLink.mouseover(function(e){ | |
fn.call($container, e); | |
}); | |
}); | |
delete $(this).data('events').mouseover; | |
} | |
$targetLink | |
.click(function(){ | |
$targetLink.blur(); | |
}) | |
.css({ | |
position: 'absolute', | |
top: $container.offset().top, | |
left: $container.offset().left, | |
// IE requires background to be set | |
backgroundColor: '#fff', | |
display: 'none', | |
opacity: 0, | |
width: $container.outerWidth(), | |
height: $container.outerHeight(), | |
padding: 0 | |
}) | |
.addClass('super-link') | |
.appendTo($targetElement); | |
$targetLink.show(); | |
}); | |
}; | |
$.fn.superUnlink = function(){ | |
return this.each(function(){ | |
$('.super-link', this).remove() | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment