User:Jayprakash12345/tabbedWindow.js

/** * * tabbedWindow.js * * Displays a sample code in the tabbed window */

( function ( $ ) {	'use strict';

$( document ).ready( function {

function makeTabWindow {

var tabs = [], indexLayout, panelLayout;

$( '.mw-gadget-tabbedwindow' ).each( function {

// Remove [edit] link to get clean heading $( this ).find( 'h3 > .mw-editsection' ).remove;

indexLayout = new OO.ui.IndexLayout( {					expanded: false				} );

// Loop all === === section $( this ).find( 'h3' ).each( function {					tabs.push( new OO.ui.TabPanelLayout( $( this ).text, {						expanded: false,						label: $( this ).text,						content: [							new OO.ui.HtmlSnippet( $( this ).next.prop( 'outerHTML' ) )						]					} ) );				} );

indexLayout.addTabPanels( tabs ); tabs = [];

panelLayout = new OO.ui.PanelLayout( {					expanded: false,					framed: true,					content: [ indexLayout ]				} );

$( this ).empty.append( panelLayout.$element );

$( '.oo-ui-indexLayout-stackLayout > .oo-ui-panelLayout' ).css( 'padding', '0.5em' ); } );		}

$.when( mw.loader.using( 'oojs-ui', 'oojs-ui-core', 'mediawiki.Title' ), $.ready ).then( function {

var supportedNamespaces = [ '' ], action = mw.config.get( 'wgAction' ), namespace = mw.config.get( 'wgCanonicalNamespace' ), mwTitle = mw.Title.newFromText( mw.config.get( 'wgPageName' ) ), isTalkPage = mwTitle.isTalkPage, tabwindow = $( '.mw-gadget-tabbedwindow' ).length;

if ( action !== 'view' ||				namespace.indexOf( supportedNamespaces ) === -1 ||				isTalkPage === true ||				tabwindow === 0 ) { return; } else { makeTabWindow; }		} );

} ); }( jQuery ) );