MediaWiki:Gadget-Tabber.js: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
(Added Tabber Gadget)
 
mNo edit summary
 
Line 8: Line 8:
//OOUI-based tabber
//OOUI-based tabber
mw.hook( "wikipage.content" ).add( function ($content) {
mw.hook( "wikipage.content" ).add( function ($content) {
var $tabberElements = $content.find( ".nookipedia-tabber" );
var $tabberElements = $content.find( ".rhwiki-tabber" );
if ($tabberElements.length > 0) { //Only load the modules and run the Javascript if there is a nookipedia-tabber in the page.
if ($tabberElements.length > 0) { //Only load the modules and run the Javascript if there is a rhwiki-tabber in the page.
mw.loader.using("oojs-ui-widgets").then(function() {
mw.loader.using("oojs-ui-widgets").then(function() {
var CSS_END_REGEX = /;\s*$/;
var CSS_END_REGEX = /;\s*$/;
Line 36: Line 36:
while (i >= 0) {
while (i >= 0) {
$currentNode = $( $tabberContents.get( i ) );
$currentNode = $( $tabberContents.get( i ) );
if ($currentNode.is( ".nookipedia-tab-header" )) {
if ($currentNode.is( ".rhwiki-tab-header" )) {
tabPanelLayouts.push(new OO.ui.TabPanelLayout("TB" + uniqueNumber++, {
tabPanelLayouts.push(new OO.ui.TabPanelLayout("TB" + uniqueNumber++, {
expanded: false,
expanded: false,
Line 63: Line 63:
expanded: false,
expanded: false,
framed: false,
framed: false,
classes: $ele.attr("class").split(/\s+/).filter(function(clas) { return clas !== "nookipedia-tabber"; }),
classes: $ele.attr("class").split(/\s+/).filter(function(clas) { return clas !== "rhwiki-tabber"; }),
content: [ indexLayout ]
content: [ indexLayout ]
})).$element;
})).$element;
Line 84: Line 84:
do {
do {
$tabberElements.each( convertToOOUITabber );
$tabberElements.each( convertToOOUITabber );
$tabberElements = $content.find( ".nookipedia-tabber" );
$tabberElements = $content.find( ".rhwiki-tabber" );
} while ($tabberElements.length > 0);
} while ($tabberElements.length > 0);
convertToOOUITabber = null; //Preventing closure memory leak? Hard to tell since OOUI has memory leaks of its own
convertToOOUITabber = null; //Preventing closure memory leak? Hard to tell since OOUI has memory leaks of its own

Navigation menu