Allow switching off preview links

The data-preview-link=false tag can be used to switch off preview links
This commit is contained in:
Asvin Goel 2016-07-21 12:15:07 +02:00 committed by GitHub
parent c1d94f1b60
commit a652e0a8ea
1 changed files with 4 additions and 3 deletions

View File

@ -983,10 +983,11 @@
// Iframe link previews
if( config.previewLinks ) {
enablePreviewLinks();
disablePreviewLinks( '[data-preview-link=false]' );
}
else {
disablePreviewLinks();
enablePreviewLinks( '[data-preview-link]' );
enablePreviewLinks( '[data-preview-link]:not([data-preview-link=false])' );
}
// Remove existing auto-slide controls
@ -1456,9 +1457,9 @@
/**
* Unbind preview frame links.
*/
function disablePreviewLinks() {
function disablePreviewLinks( selector ) {
var anchors = toArray( document.querySelectorAll( 'a' ) );
var anchors = toArray( document.querySelectorAll( selector ? selector : 'a' ) );
anchors.forEach( function( element ) {
if( /^(http|www)/gi.test( element.getAttribute( 'href' ) ) ) {