From a406a9d24dc9a6b036d5791a67ebf74fee0adfc7 Mon Sep 17 00:00:00 2001 From: Tim Steiner <tsteiner2@unl.edu> Date: Tue, 9 Nov 2010 18:45:27 +0000 Subject: [PATCH] Add a fix to make #tags work when a base tag exists on the page. git-svn-id: file:///tmp/wdn_thm_drupal/trunk@304 20a16fea-79d4-4915-8869-1ea9d5ebf173 --- sites/all/themes/unl_wdn/theme.js | 24 ++++++++++++++++++++++++ sites/all/themes/unl_wdn/unl_wdn.info | 2 ++ 2 files changed, 26 insertions(+) create mode 100644 sites/all/themes/unl_wdn/theme.js diff --git a/sites/all/themes/unl_wdn/theme.js b/sites/all/themes/unl_wdn/theme.js new file mode 100644 index 00000000..3e5cae46 --- /dev/null +++ b/sites/all/themes/unl_wdn/theme.js @@ -0,0 +1,24 @@ +WDN.jQuery(document).ready(function () { + // if there's no base tag on the page, we don't have to worry about this + if (WDN.jQuery('base').length == 0) { + return; + } + WDN.jQuery('a').click(function(e){ + // if this link has a hash tag + if (this.href.split('#')[1] == '') { + return; + } + // and it is specifically for this page + if (this.getAttribute('href').split('#')[0] != '') { + return; + } + // and something else hasn't already customized the link + if (e.isDefaultPrevented()) { + return; + } + + // fix clicking the link so that it ignores the base tag + e.preventDefault(); + document.location.hash = this.href.split('#')[1]; + }); +}); \ No newline at end of file diff --git a/sites/all/themes/unl_wdn/unl_wdn.info b/sites/all/themes/unl_wdn/unl_wdn.info index 59139093..4354e7f2 100644 --- a/sites/all/themes/unl_wdn/unl_wdn.info +++ b/sites/all/themes/unl_wdn/unl_wdn.info @@ -6,6 +6,8 @@ engine = phptemplate stylesheets[all][] = style.css +scripts[] = theme.js + features[] = main_menu features[] = name features[] = node_user_picture -- GitLab