From 87f5bf2153b514ec23a4c70c39eca525def7ceb0 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Mon, 1 Feb 2016 14:41:51 -0500 Subject: [PATCH] fix for external js and blog url --- Toolkit/Page.php | 2 +- js/external.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 js/external.js diff --git a/Toolkit/Page.php b/Toolkit/Page.php index 84a8659..3b50adb 100755 --- a/Toolkit/Page.php +++ b/Toolkit/Page.php @@ -162,7 +162,7 @@ class Toolkit_Page $GLOBALS['bottomScripts'][] = MEDIA_BASE_URL . 'js/pageSetup.js'; $GLOBALS['styleSheets'][] = $this->mediaBaseURL . 'fancybox/jquery.fancybox.css'; $GLOBALS['bottomScripts'][] = $this->mediaBaseURL . "fancybox/jquery.fancybox.js"; - $GLOBALS['bottomScripts']['external'] = $this->glmAppBaseURL . 'libjs/external.js'; + $GLOBALS['bottomScripts']['external'] = $this->mediaBaseURL . 'js/external.js'; } /** diff --git a/js/external.js b/js/external.js new file mode 100644 index 0000000..a8b1d62 --- /dev/null +++ b/js/external.js @@ -0,0 +1,25 @@ +/* + * Open all links that are not of the site to open in new window + */ + + +$('a').each(function() { + var urlPattern = new RegExp('/' + window.location.host + '/'); + if( !urlPattern.test(this.href) + && !$(this).hasClass('thickbox') + && !$(this).hasClass('colorbox') + && !$(this).hasClass('various') + && !$(this).hasClass('phototitle') + && !$(this).hasClass('photoimg') + && ($(this).attr('href') != "#") + && ($(this).attr('href') != "http://blog.keweenaw.info") + && ($(this).attr('href') != "") + && ($(this).attr('href') != null) + ) { + $(this).click(function(event) { + event.preventDefault(); + event.stopPropagation(); + window.open(this.href, '_blank'); + }); + } +}); -- 2.17.1