From: Steve Sutton Date: Mon, 1 Feb 2016 19:41:51 +0000 (-0500) Subject: fix for external js and blog url X-Git-Tag: v1.4.2^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=87f5bf2153b514ec23a4c70c39eca525def7ceb0;p=web%2FKeweenaw.git fix for external js and blog url --- 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'); + }); + } +});