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;

// Loop over all div with tabwindow class $( '.tabwindow' ).each( function {

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

// Create Index Layout IndexLayout = new OO.ui.IndexLayout( {					expanded: false				} );

// Loop all === === section $( this ).find( 'h3' ).each( function {

// Push the TabPanelLayout in Tabs array Tabs.push( new OO.ui.TabPanelLayout( $( this ).text, { expanded: false, label: $( this ).text, content: [ new OO.ui.HtmlSnippet( $( this ).next.prop( 'outerHTML' ) ) ]					} )					);				} );

// Add Tab Panal to IndexLayout IndexLayout.addTabPanels( Tabs );

// Clear the Tabs array Tabs = [];

// Create Panal Layout PanelLayout = new OO.ui.PanelLayout( {					expanded: false,					framed: true,					content: [ IndexLayout ]				} );

// Empty tabwindow class tag and append the PanelLayout $( this ).empty.append( PanelLayout.$element );

// Deduce the panelLayout padding $( '.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 = $( '.tabwindow' ).length;

if ( action !== 'view' ||				namespace.indexOf( supportedNamespaces ) === -1 ||				isTalkPage === true ||				tabwindow === 0 ) { return; } else { // Start function to create Tab Window makeTabWindow; }		} );

} ); }( jQuery ) );