From e877b327f21e802962e910caa74db3ff245ddc19 Mon Sep 17 00:00:00 2001 From: Leif Hanson Date: Mon, 9 Sep 2013 15:36:31 +0000 Subject: [PATCH] Switch to a local external.js file. --- Toolkit/Page.php | 2 +- libjs/external.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100755 libjs/external.js 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'); + }); + } +}); -- 2.17.1