From: Leif Hanson Date: Mon, 9 Sep 2013 15:36:31 +0000 (+0000) Subject: Switch to a local external.js file. X-Git-Tag: v1.0~52 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=e877b327f21e802962e910caa74db3ff245ddc19;p=web%2FMichiganTrailMaps.git Switch to a local external.js file. --- diff --git a/Toolkit/Page.php b/Toolkit/Page.php index d0adbb5..73e6d06 100755 --- a/Toolkit/Page.php +++ b/Toolkit/Page.php @@ -150,7 +150,7 @@ class Toolkit_Page $GLOBALS['bottomScripts'][] = $this->baseURL . 'photoswipe/lib/klass.min.js'; $GLOBALS['bottomScripts'][] = $this->baseURL . 'photoswipe/code.photoswipe.jquery-3.0.5.js'; $GLOBALS['bottomScripts'][] = $this->baseURL . "fancybox/jquery.fancybox.js"; - $GLOBALS['bottomScripts'][] = $this->glmAppBaseURL . 'libjs/external.js'; + $GLOBALS['bottomScripts'][] = $this->baseURL . 'libjs/external.js'; $GLOBALS['bottomScripts'][] = $this->baseURL . "libjs/pagefunctions.js"; } diff --git a/libjs/external.js b/libjs/external.js new file mode 100755 index 0000000..44277e8 --- /dev/null +++ b/libjs/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') != "") + && ($(this).attr('href') != null) + ) { + $(this).click(function(event) { + event.preventDefault(); + event.stopPropagation(); + window.open(this.href, '_blank'); + }); + } +});