https://www.mediawiki.org/wiki/Special:Code/MediaWiki/115028
Revision: 115028
Author: yaron
Date: 2012-04-24 22:16:40 +0000 (Tue, 24 Apr 2012)
Log Message:
-----------
Fixed #switchtablink to finally work correctly with jQuery UI, using new global
variable, $htTabIndexes
Modified Paths:
--------------
trunk/extensions/HeaderTabs/HeaderTabs.php
trunk/extensions/HeaderTabs/HeaderTabs_body.jq.php
trunk/extensions/HeaderTabs/skins-jquery/ext.headertabs.core.js
Modified: trunk/extensions/HeaderTabs/HeaderTabs.php
===================================================================
--- trunk/extensions/HeaderTabs/HeaderTabs.php 2012-04-24 20:00:59 UTC (rev
115027)
+++ trunk/extensions/HeaderTabs/HeaderTabs.php 2012-04-24 22:16:40 UTC (rev
115028)
@@ -47,6 +47,9 @@
$htStyle = 'jquery-large';
$htEditTabLink = true;
+// Other variables
+$htTabIndexes = array();
+
// Extension:Configure
if ( isset( $wgConfigureAdditionalExtensions ) && is_array(
$wgConfigureAdditionalExtensions ) ) {
@@ -100,6 +103,7 @@
'localBasePath' => dirname( __FILE__ ),
'remoteExtPath' => 'HeaderTabs',
);
+ $wgHooks['MakeGlobalVariablesScript'][] =
'HeaderTabs::setGlobalJSVariables';
} else { // if ! $useJQuery
$wgAutoloadClasses['HeaderTabs'] = "$dir/HeaderTabs_body.yui.php";
}
Modified: trunk/extensions/HeaderTabs/HeaderTabs_body.jq.php
===================================================================
--- trunk/extensions/HeaderTabs/HeaderTabs_body.jq.php 2012-04-24 20:00:59 UTC
(rev 115027)
+++ trunk/extensions/HeaderTabs/HeaderTabs_body.jq.php 2012-04-24 22:16:40 UTC
(rev 115028)
@@ -18,7 +18,8 @@
}
public static function replaceFirstLevelHeaders( &$parser, &$text ) {
- global $htRenderSingleTab, $htAutomaticNamespaces,
$htDefaultFirstTab, $htDisableDefaultToc, $htGenerateTabTocs, $htStyle,
$htEditTabLink;
+ global $htRenderSingleTab, $htAutomaticNamespaces,
$htDefaultFirstTab, $htDisableDefaultToc, $htGenerateTabTocs, $htStyle,
$htEditTabLink;
+ global $htTabIndexes;
//! @todo handle __NOTABTOC__, __TABTOC__, __FORCETABTOC__ here
(2011-12-12, ofb)
@@ -251,6 +252,11 @@
$text = $above . $tabhtml . $below;
$parser->getOutput()->addHeadItem(HTML::inlineScript(
'document.styleSheets[0].insertRule?document.styleSheets[0].insertRule(".unselected
{display:none;}", 0):document.styleSheets[0].addRule(".unselected",
"display:none");' ), true );
+
+ foreach ( $tabs as $i => $tab ) {
+ $tabTitle = str_replace( ' ', '_', $tab['title'] );
+ $htTabIndexes[$tabTitle] = $i;
+ }
return true;
}
@@ -285,6 +291,10 @@
}
public static function renderSwitchTabLink( &$parser, $tabName,
$linkText, $anotherTarget = '' ) {
+ // The cache unfortunately needs to be disabled for the
+ // Javascript for such links to work.
+ $parser->disableCache();
+
$tabTitle = Title::newFromText( $tabName );
$tabKey = $tabTitle->getDBkey();
$sanitizedLinkText = $parser->recursiveTagParse( $linkText );
@@ -301,4 +311,9 @@
return $parser->insertStripItem( $output, $parser->mStripState
);
}
+ static function setGlobalJSVariables( &$vars ) {
+ global $htTabIndexes;
+ $vars['htTabIndexes'] = $htTabIndexes;
+ return true;
+ }
}
Modified: trunk/extensions/HeaderTabs/skins-jquery/ext.headertabs.core.js
===================================================================
--- trunk/extensions/HeaderTabs/skins-jquery/ext.headertabs.core.js
2012-04-24 20:00:59 UTC (rev 115027)
+++ trunk/extensions/HeaderTabs/skins-jquery/ext.headertabs.core.js
2012-04-24 22:16:40 UTC (rev 115028)
@@ -99,7 +99,8 @@
/* click a tab parserhook link */
$(".tabLink").click( function() {
- var href = $(this).attr('href');
- $tabs.tabs('select', tabNameEscape(href));
+ var tabName = $(this).attr('href').replace('#tab=', '');
+ var tabIndex = htTabIndexes[tabName];
+ $tabs.tabs('select', tabIndex ); //tabNameEscape(href));
return false;
} );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs