Last active
August 29, 2015 14:23
-
-
Save anthonysbrown/162ed404fe3321094d81 to your computer and use it in GitHub Desktop.
Javascript Linkout Script Using Colorbox
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
<div style="display:none"> | |
<div class="dove-tail-linkout-content"> | |
<p>You are currently leaving the site! please confirm you would like to leave</p> | |
</div> | |
</div> |
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
(function( $ ){ | |
$.fn.dovetailLinkout= function(linkout){ | |
if( | |
linkout.hasClass('safe_link') || | |
linkout.parent().hasClass('safe_link') || | |
linkout.attr('href') == '' || | |
linkout.attr('href').substring(0, 1) == "#" || | |
linkout.attr('href').substring(0, 10) == "javascript" | |
){ | |
return true; | |
}else{ | |
$.colorbox({width:"450px", height:"400px",html: '<div class="colorbox-linkout-modal">' + $('.dove-tail-linkout-content').html()+ '<div class="colorbox-linkout-button"><a href="' + linkout.attr('href') +'" class="force_link">Click here to proceed to ' + linkout.attr('href') +'</a></div></div>'}); | |
return false; | |
} | |
} | |
})( jQuery ); | |
jQuery( document ).ready(function($) { | |
$('a').each(function () { | |
if (this.host.replace(':443','') !== location.host &&this.host.replace(':80','') !== location.host) { | |
$(this).addClass('external_link'); | |
} | |
else { | |
$(this).addClass('internal_link'); | |
} | |
}); | |
$('a.external_link').on('click',function(e){e.preventDefault(); return $(this).dovetailLinkout($(this)); }); | |
$('a.external_link span').on('click',function(e){e.preventDefault(); return $(this).dovetailLinkout($(this).parent()); }); | |
$('.ubermenu-item').on('click',function(e){e.preventDefault(); return $(this).dovetailLinkout($(this).child()); }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment