diff options
Diffstat (limited to 'source/javascripts')
| -rw-r--r-- | source/javascripts/external.js | 13 | ||||
| -rw-r--r-- | source/javascripts/slash.js | 24 | 
2 files changed, 14 insertions, 23 deletions
| diff --git a/source/javascripts/external.js b/source/javascripts/external.js deleted file mode 100644 index 2501d9b..0000000 --- a/source/javascripts/external.js +++ /dev/null @@ -1,13 +0,0 @@ -(function($){ -	var host = location.host; - -	$('a').on('click', function(e){ -		var href = $(this).attr('href'), -			link = href.replace(/(https?:\/\/)(.*)\/(.*)/, '$2'); - -		if (href.match('https?') && link != host){ -			window.open(href); -			e.preventDefault(); -		} -	}); -})(jQuery);
\ No newline at end of file diff --git a/source/javascripts/slash.js b/source/javascripts/slash.js index c23a4a2..270f39c 100644 --- a/source/javascripts/slash.js +++ b/source/javascripts/slash.js @@ -1,16 +1,19 @@  (function($){ -	/* external.js */ -	var host = location.host; +	// Open external links in new window +	var externalLinks = function(){ +		var host = location.host; -	$('a').on('click', function(e){ -		var href = $(this).attr('href'), -			link = href.replace(/(https?:\/\/)(.*)\/(.*)/, '$2'); +		$('body').on('click', 'a', function(e){ +			var href = this.href, +				link = href.replace(/https?:\/\/([^\/]+)(.*)/, '$1'); + +			if (link != host){ +				window.open(href); +				e.preventDefault(); +			} +		}); +	}; -		if (href.match('https?') && link != host){ -			window.open(href); -			e.preventDefault(); -		} -	});  	/* navigation.js */  	var appends = '<option>Menu</option>'; @@ -42,4 +45,5 @@  		});  	});  	$('.fancybox').fancybox(); +	externalLinks(); // Delete or comment this line to disable opening external links in new window  })(jQuery);
\ No newline at end of file | 
