Yaron Koren has submitted this change and it was merged.
Change subject: Fixed TOC links not redirecting to proper tab
......................................................................
Fixed TOC links not redirecting to proper tab
If a TOC link for any tab than the current tab is clicked on,
it will not properly redirect to the correct link. This resolves
the issue by following the same pattern as used for external page
links using the # anchor.
Change-Id: Iec6a3936d2c609e206809dfd0a4423f81ff19e25
---
M skins/ext.headertabs.core.js
1 file changed, 20 insertions(+), 0 deletions(-)
Approvals:
Yaron Koren: Checked; Looks good to me, approved
jenkins-bot: Verified
diff --git a/skins/ext.headertabs.core.js b/skins/ext.headertabs.core.js
index 3ee8b07..9b9c73f 100644
--- a/skins/ext.headertabs.core.js
+++ b/skins/ext.headertabs.core.js
@@ -21,6 +21,13 @@
return tabName;
}
+function entryEscape(entryName) {
+ //Don't escape #'s for our entries
+ //Replacement code is courtesy of
http://http://totaldev.com/content/escaping-characters-get-valid-jquery-id
+ //Retireved 2013/4/22
+ entryName = entryName.replace(/([;&,\.\+\*\~':"\!\^$%@\[\]\(\)=>\|])/g,
'\\$1');
+ return entryName;
+}
var $tabs = $("#headertabs").tabs();
// delete the rule hiding unselected tabs
@@ -42,6 +49,19 @@
}
}
+/* rewrite TOC
+ * Code originally written by Chad Catlett
+ * Submitted with his permission. */
+$(document).ready(function(){
+ $(".toc ul a").each(function(){
+ $(this).click(function() {
+ var tabId =
$(entryEscape(this.hash)).closest('.ui-tabs-panel').attr('id');
+ $tabs.tabs('select', tabNameEscape(tabId));
+ });
+ });
+
+});
+
/* follow a # anchor to a tab OR a heading */
var curHash = window.location.hash;
if ( curHash.indexOf( "#tab=" ) == 0 ) {
--
To view, visit https://gerrit.wikimedia.org/r/240104
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iec6a3936d2c609e206809dfd0a4423f81ff19e25
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/HeaderTabs
Gerrit-Branch: master
Gerrit-Owner: Rglasnap <[email protected]>
Gerrit-Reviewer: Rglasnap <[email protected]>
Gerrit-Reviewer: Yaron Koren <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits