From 498a4280f2cf296c082313d8e826ca4078785b16 Mon Sep 17 00:00:00 2001 From: khawkins98 <khawkins98@gmail.com> Date: Thu, 31 Aug 2017 15:24:15 +0100 Subject: [PATCH] Add external link for v1.3 #110 --- css/ebi-css-build/ebi-global.scss | 12 ++++++++++++ js/foundationExtendEBI.js | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/css/ebi-css-build/ebi-global.scss b/css/ebi-css-build/ebi-global.scss index 60631c0e..badf506f 100644 --- a/css/ebi-css-build/ebi-global.scss +++ b/css/ebi-css-build/ebi-global.scss @@ -341,6 +341,18 @@ .lead { color: $secondary-color; margin-bottom: .5rem; } } + // external links + a.external{ + &:after { + content: " x"; + font-family: "EBI-Generic"; + font-size: .65rem; + position: relative; + top: -1px; + margin-left: .4rem; + } + } + // read more a.read-more, a.readmore, diff --git a/js/foundationExtendEBI.js b/js/foundationExtendEBI.js index 73c42d60..3b35c4fe 100644 --- a/js/foundationExtendEBI.js +++ b/js/foundationExtendEBI.js @@ -395,6 +395,18 @@ function invokeResponsiveMenuEBI() { } + // Programatically open external links in new tabs, and add '.external' + function addBlankTargetToExternalLinkEBI(parent) { + var parent = parent || '#content'; + $(parent + ' a').filter(function() { + return this.hostname && this.hostname !== location.hostname; + }).attr('target','_blank'); + } + function addExternalToBlankWindowLinksEBI(parent) { + var parent = parent || '#content'; + $(parent + ' a[target="_blank"]').addClass('external'); + } + /* Allow invokation of of foundation and foundationExtendEBI with data attributes <body data-foundationInvoke="document" data-foundationExtendEBI="document"> @@ -416,5 +428,9 @@ function invokeResponsiveMenuEBI() { if (bodyData.foundationExtendEBI === 'true') bodyData.foundationExtendEBI = 'document'; $(bodyData.foundationExtendEBI).foundationExtendEBI(); } + if (bodyData.addExternal) { + addBlankTargetToExternalLinkEBI(); + addExternalToBlankWindowLinksEBI(); + } }(jQuery)); -- GitLab