مدیاویکی:Mobile.js: تفاوت میان نسخه‌ها

از ویکی حج
بدون خلاصۀ ویرایش
بدون خلاصۀ ویرایش
 
(یک نسخهٔ میانیِ ایجادشده توسط همین کاربر نشان داده نشد)
خط ۲: خط ۲:
mw.loader.using('mobile.site.styles')
mw.loader.using('mobile.site.styles')


#wikitext-editor {
/**
    font-family: monospace
* Collapsible tables; reimplemented with mw-collapsible
}
* Styling is also in place to avoid FOUC
/* to prevent double welcome! */
*
.page-Main_Page #section_0 {
* Allows tables to be collapsed, showing only the header. See [[Help:Collapsing]].
    display: none
* @version 3.0.0 (2018-05-20)
}
* @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
* @author [[User:R. Koot]]
* @author [[User:Krinkle]]
* @author [[User:TheDJ]]
* @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
* is supported in MediaWiki core. Shimmable since MediaWiki 1.32
*
* @param {jQuery} $content
*/
function makeCollapsibleMwCollapsible( $content ) {
var $tables = $content
.find( 'table.collapsible:not(.mw-collapsible)' )
.addClass( 'mw-collapsible' );


/* Mobile template hacks (see bug 54176) */
$.each( $tables, function ( index, table ) {
.mobile-float-reset {
// mw.log.warn( 'This page is using the deprecated class collapsible. Please replace it with mw-collapsible.');
    float: none !important;
if ( $( table ).hasClass( 'collapsed' ) ) {
    width: 100% !important;
$( table ).addClass( 'mw-collapsed' );
// mw.log.warn( 'This page is using the deprecated class collapsed. Please replace it with mw-collapsed.');
}
} );
if ( $tables.length > 0 ) {
mw.loader.using( 'jquery.makeCollapsible' ).then( function () {
$tables.makeCollapsible();
} );
}
}
}
mw.hook( 'wikipage.content' ).add( makeCollapsibleMwCollapsible );


/* Temporary fix for bug 53437 - nav boxes can disrupt reading experience on smaller screens
/**
TODO: Update template to have nomobile class */
* Add support to mw-collapsible for autocollapse, innercollapse and outercollapse
#content .vertical-navbox,
*
#content .navbox {
* Maintainers: TheDJ
    display: none;
*/
function mwCollapsibleSetup( $collapsibleContent ) {
var $element,
$toggle,
autoCollapseThreshold = 2;
$.each( $collapsibleContent, function ( index, element ) {
$element = $( element );
if ( $element.hasClass( 'collapsible' ) ) {
$element.find( 'tr:first > th:first' ).prepend( $element.find( 'tr:first > * > .mw-collapsible-toggle' ) );
}
if ( $collapsibleContent.length >= autoCollapseThreshold && $element.hasClass( 'autocollapse' ) ) {
$element.data( 'mw-collapsible' ).collapse();
} else if ( $element.hasClass( 'innercollapse' ) ) {
if ( $element.parents( '.outercollapse' ).length > 0 ) {
$element.data( 'mw-collapsible' ).collapse();
}
}
// because of colored backgrounds, style the link in the text color
// to ensure accessible contrast
$toggle = $element.find( '.mw-collapsible-toggle' );
if ( $toggle.length ) {
// Make the toggle inherit text color
if ( $toggle.parent()[ 0 ].style.color ) {
$toggle.find( 'a' ).css( 'color', 'inherit' );
}
}
} );
}
}


/* Tablet specific styling */
mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );
@media all and (min-width: 768px) {
    #content .vertical-navbox, #content .navbox {
        display: inherit;
    }
}
#mw-mf-last-modified {
    display: none;
}


/* For linked citation numbers and document IDs, where
/**
  the number need not be shown on a screen or a handheld,
* Dynamic Navigation Bars (experimental)
  but should be included in the printed version
*
TODO: Move to Citation template when templates have stylesheets
* Description: See [[Wikipedia:NavFrame]].
See https://www.mediawiki.org/wiki/Requests_for_comment/Allow_styling_in_templates
* Maintainers: UNMAINTAINED
*/
*/
@media screen,
handheld {
    .citation *.printonly {
        display: none;
    }
}
 
/* Styling for citations (CSS3). Breaks long urls, etc., rather than overflowing box
*/
.citation {
    word-wrap: break-word;
}


/* Default styling for Navbar template
var collapseCaption = 'بسته';
TODO: Move to Navbar template when templates have stylesheets
var expandCaption = 'باز';
See https://www.mediawiki.org/wiki/Requests_for_comment/Allow_styling_in_templates
*/
.navbar {
    display: inline;
    font-size: 88%;
    font-weight: normal;
}
.navbar ul {
    display: inline;
    white-space: nowrap;
}
.navbar li {
    word-spacing: -0.125em;
}
.navbar.mini li span {
    font-variant: small-caps;
}


/* Navbar styling when nested in infobox and navbox */
// Set up the words in your language
.infobox .navbar {
var navigationBarHide = '[' + collapseCaption + ']';
    font-size: 100%;
var navigationBarShow = '[' + expandCaption + ']';
    border: 1px solid #a2a9b1;
}
.navbox .navbar {
    display: block;
    font-size: 100%;
}
.navbox-title .navbar {
    /* @noflip */
    float: right;
    /* @noflip */
    text-align: right;
    /* @noflip */
    margin-left: 0.5em;
    width: 6em;
}


/* Style for horizontal lists (separator following item).
/**
  @source mediawiki.org/wiki/Snippets/Horizontal_lists
* Shows and hides content and picture (if available) of navigation bars.
  @revision 3.2 (2013-09-25)
*
  @author: [[User:Edokter]]
* @param {number} indexNavigationBar The index of navigation bar to be toggled
*/
* @param {jQuery.Event} event Event object
.hlist dl,
* @return {boolean}
.hlist ol,
*/
.hlist ul {
function toggleNavigationBar( indexNavigationBar, event ) {
    margin: 0;
var navToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
    padding: 0;
var navFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
}
var navChild;


/* Display list items inline and make them nowrap */
if ( !navFrame || !navToggle ) {
.hlist dd,
return false;
.hlist dt,
}
.hlist li {
    margin: 0;
    display: inline;
    white-space: nowrap;
}


/* Allow wrapping for list items (in tight spaces) */
// If shown now
.hlist.hwrap dd,
if ( navToggle.firstChild.data === navigationBarHide ) {
.hlist.hwrap dt,
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
.hlist.hwrap li {
if ( $( navChild ).hasClass( 'NavContent' ) ) {
    white-space: normal;
navChild.style.display = 'none';
}
}
 
}
/* Display nested lists inline and allow them to wrap */
navToggle.firstChild.data = navigationBarShow;
.hlist dl dl,
.hlist dl ol,
.hlist dl ul,
.hlist ol dl,
.hlist ol ol,
.hlist ol ul,
.hlist ul dl,
.hlist ul ol,
.hlist ul ul {
    display: inline;
    white-space: normal;
}


/* Generate interpuncts */
// If hidden now
#content .hlist dt:after {
} else if ( navToggle.firstChild.data === navigationBarShow ) {
    content: ":";
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
}
if ( $( navChild ).hasClass( 'NavContent' ) ) {
#content .hlist dd:after,
navChild.style.display = 'block';
#content .hlist li:after {
}
    content: " ·";
}
    font-weight: bold;
navToggle.firstChild.data = navigationBarHide;
}
}
#content .hlist dd:last-child:after,
#content .hlist dt:last-child:after,
#content .hlist li:last-child:after {
    content: none;
}


/* Add parentheses around nested lists */
event.preventDefault();
#content .hlist dd dd:first-child:before,
#content .hlist dd dt:first-child:before,
#content .hlist dd li:first-child:before,
#content .hlist dt dd:first-child:before,
#content .hlist dt dt:first-child:before,
#content .hlist dt li:first-child:before,
#content .hlist li dd:first-child:before,
#content .hlist li dt:first-child:before,
#content .hlist li li:first-child:before {
    content: "(";
    font-weight: normal;
}
#content .hlist dd dd:last-child:after,
#content .hlist dd dt:last-child:after,
#content .hlist dd li:last-child:after,
#content .hlist dt dd:last-child:after,
#content .hlist dt dt:last-child:after,
#content .hlist dt li:last-child:after,
#content .hlist li dd:last-child:after,
#content .hlist li dt:last-child:after,
#content .hlist li li:last-child:after {
    content: ")";
    font-weight: normal;
}
}


/* Put ordinals in front of ordered list items */
/**
#content .hlist ol {
* Adds show/hide-button to navigation bars.
    counter-reset: list-item;
*
}
* @param {jQuery} $content
#content .hlist ol > li {
*/
    counter-increment: list-item;
function createNavigationBarToggleButton( $content ) {
}
var j, navChild, navToggle, navToggleText, isCollapsed,
#content .hlist ol > li:before {
indexNavigationBar = 0;
    content: counter(list-item) " ";
// Iterate over all < div >-elements
}
var $divs = $content.find( 'div.NavFrame:not(.mw-collapsible)' );
#content .hlist dd ol > li:first-child:before,
$divs.each( function ( i, navFrame ) {
#content .hlist dt ol > li:first-child:before,
indexNavigationBar++;
#content .hlist li ol > li:first-child:before {
navToggle = document.createElement( 'a' );
    content: "(" counter(list-item) " ";
navToggle.className = 'NavToggle';
}
navToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
 
navToggle.setAttribute( 'href', '#' );
/* Unbulleted lists e.g. Barack Obama page */
$( navToggle ).on( 'click', $.proxy( toggleNavigationBar, null, indexNavigationBar ) );
.plainlist ul {
    list-style: none;
}


/* CODE FOR COMPACT AMBOX */
isCollapsed = $( navFrame ).hasClass( 'collapsed' );
 
/**
/* Hide the images */
* Check if any children are already hidden.  This loop is here for backwards compatibility:
.compact-ambox table .mbox-image,
* the old way of making NavFrames start out collapsed was to manually add style="display:none"
.compact-ambox table .mbox-imageright,
* to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
.compact-ambox table .mbox-empty-cell {
* the content visible without JavaScript support), the new recommended way is to add the class
    display: none;
* "collapsed" to the NavFrame itself, just like with collapsible tables.
}
*/
 
for ( navChild = navFrame.firstChild; navChild !== null && !isCollapsed; navChild = navChild.nextSibling ) {
/* Remove borders, backgrounds, padding, etc.
if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
Please document here what pages use this
if ( navChild.style.display === 'none' ) {
*/
isCollapsed = true;
.compact-ambox table.ambox {
}
    border: none;
}
    border-collapse: collapse;
}
    background: transparent;
if ( isCollapsed ) {
    margin: 0 1.6em 0 !important;
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
    padding: 0 !important;
if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
    width: auto;
navChild.style.display = 'none';
    display: block;
}
}
}
.compact-ambox table.mbox-small-left {
}
    font-size: 100%;
navToggleText = document.createTextNode( isCollapsed ? navigationBarShow : navigationBarHide );
    width: auto;
navToggle.appendChild( navToggleText );
    margin: 0;
}


/* Style the text cell as a list item and remove its padding */
// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
.compact-ambox table .mbox-text {
for ( j = 0; j < navFrame.childNodes.length; j++ ) {
    padding: 0 !important;
if ( $( navFrame.childNodes[ j ] ).hasClass( 'NavHead' ) ) {
    margin: 0 !important;
navToggle.style.color = navFrame.childNodes[ j ].style.color;
}
navFrame.childNodes[ j ].appendChild( navToggle );
.compact-ambox table .mbox-text-span {
}
    display: list-item;
}
    line-height: 1.5em;
navFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
    list-style-type: square;
} );
    list-style-image: url("data:image/gif;base64,R0lGODlhBQANAIAAAGOMnP///yH5BAEAAAEALAAAAAAFAA0AAAIJjI+pu+APo4SpADs=");
}
}


/* Allow for hiding text in compact form */
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
.compact-ambox .hide-when-compact {
    display: none;
}


/* Hatnotes and disambiguation notices
/** Dynamic Navigation Bars (experimental) *************************************
Please document here what pages use this
*
*  Description: See [[Wikipedia:NavFrame]].
*  Maintainers: UNMAINTAINED
  */
  */
.rellink,
.dablink {
    font-style: italic;
    margin-bottom: 0.5em;
}
.rellink i,
.dablink i {
    font-style: normal;
}


/* Geographical coordinates defaults. See [[Template:Coord/link]]
// set up the words in your language
  for how these are used. The classes "geo", "longitude", and
var NavigationBarHide = "[" + collapseCaption + "]";
  "latitude" are used by the [[Geo microformat]]. */
var NavigationBarShow = "[" + expandCaption + "]";
.geo-default,
.geo-dms,
.geo-dec {
    display: inline;
}
.geo-nondefault,
.geo-multi-punct {
    display: none;
}
.longitude,
.latitude {
    white-space: nowrap;
}


/* Prevent line breaks in silly places:
// shows and hides content and picture (if available) of navigation bars
  1) Where desired
// Parameters:
  2) Links when we don't want them to
//    indexNavigationBar: the index of navigation bar to be toggled
  3) Bold "links" to the page itself
window.toggleNavigationBar = function(indexNavigationBar, event) {
  4) Ref tags with group names <ref group="Note"> --> "[Note 1]"
  var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
Please document here what pages use this
  var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
*/
  var NavChild;
.nowrap,
.nowraplinks a,
.nowraplinks .selflink,
sup.reference a {
    white-space: nowrap;
}


/* But allow wrapping where desired: */
  if (!NavFrame || !NavToggle) {
.wrap,
     return false;
.wraplinks a {
  }
     white-space: normal;
}


/* Hide stuff meant for accounts with special permissions. Made visible again in
  /* if shown now */
  [[MediaWiki:Group-sysop.css]], [[MediaWiki:Group-accountcreator.css]] and
  if (NavToggle.firstChild.data === NavigationBarHide) {
  [[MediaWiki:Group-autoconfirmed.css]]. */
     for (NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
.sysop-show,
      if ($(NavChild).hasClass("NavContent") || $(NavChild).hasClass("NavPic")) {
.accountcreator-show,
        NavChild.style.display = "none";
.autoconfirmed-show {
      }
     display: none;
     }
}
     NavToggle.firstChild.data = NavigationBarShow;
#li-coordinates {
    background-image: url(//upload.wikimedia.org/wikipedia/commons/thumb/5/57/Edge-firefox.png/80px-Edge-firefox.png);
    float: right;
    display: none;
    -webkit-background-size: auto 30px;
    background-size: auto 30px;
}
.client-js .content_block.coordinates {
    display: none;
    text-align: right;
    margin-bottom: 0.5em;
     font-size: smaller;
}
.client-js .content_block.coordinates .latitude {
    display: none;
    padding-right: 20px;
     background-image: url(//upload.wikimedia.org/wikipedia/commons/thumb/5/57/Edge-firefox.png/50px-Edge-firefox.png);
    background-repeat: no-repeat;
    -webkit-background-size: auto 15px;
    background-size: auto 15px;
}


/* Until Geohack is mobile optimised and/or there is a nice alternative e.g. map namespace */
    /* if hidden now */
.alpha #li-coordinates {
  } else if (NavToggle.firstChild.data === NavigationBarShow) {
     display: list-item;
     for (NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
}
      if ($(NavChild).hasClass("NavContent") || $(NavChild).hasClass("NavPic")) {
.client-js .beta .content_block.coordinates {
        NavChild.style.display = "block";
    display: block;
      }
}
     }
.client-js .beta .content_block.coordinates .latitude {
    NavToggle.firstChild.data = NavigationBarHide;
     display: inline;
  }
}
.topicon {
    display: none;
}


/* Remove this when mobile page creation goes out of beta */
  event.preventDefault();
.stub {
};
    display: none;
}


/* hide the second toc */
/* adds show/hide-button to navigation bars */
#toc {
function createNavigationBarToggleButton() {
     display: none
  var indexNavigationBar = 0;
}
  var NavFrame;
  var NavChild;
  /* iterate over all < div >-elements */
  var divs = document.getElementsByTagName("div");
  for (var i = 0;
    (NavFrame = divs[i]); i++) {
     /* if found a navigation bar */
    if ($(NavFrame).hasClass("NavFrame")) {


/* hide language link */
      indexNavigationBar++;
.mw-ui-icon-language-switcher {
      var NavToggle = document.createElement("a");
    display: none !important
      NavToggle.className = "NavToggle";
}
      NavToggle.setAttribute("id", "NavToggle" + indexNavigationBar);
      NavToggle.setAttribute("href", "#");
      $(NavToggle).on("click", $.proxy(window.toggleNavigationBar, window, indexNavigationBar));


/* navbox */
      var isCollapsed = $(NavFrame).hasClass("collapsed");
.content table .navbox-inner {
      /**
    margin: 0;
      * Check if any children are already hidden.  This loop is here for backwards compatibility:
}
      * the old way of making NavFrames start out collapsed was to manually add style="display:none"
      * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
      * the content visible without JavaScript support), the new recommended way is to add the class
      * "collapsed" to the NavFrame itself, just like with collapsible tables.
      */
      for (NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling) {
        if ($(NavChild).hasClass("NavPic") || $(NavChild).hasClass("NavContent")) {
          if (NavChild.style.display === "none") {
            isCollapsed = true;
          }
        }
      }
      if (isCollapsed) {
        for (NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
          if ($(NavChild).hasClass("NavPic") || $(NavChild).hasClass("NavContent")) {
            NavChild.style.display = "none";
          }
        }
      }
      var NavToggleText = document.createTextNode(isCollapsed ? NavigationBarShow : NavigationBarHide);
      NavToggle.appendChild(NavToggleText);


/* طراحی صفحه اول */
      /* Find the NavHead and attach the toggle link (Must be this complicated because Moz"s firstChild handling is borked) */
.page-Main_Page.is-authenticated .pre-content{
      for (var j = 0; j < NavFrame.childNodes.length; j++) {
    display:none
        if ($(NavFrame.childNodes[j]).hasClass("NavHead")) {
}
          NavToggle.style.color = NavFrame.childNodes[j].style.color;
 
          NavFrame.childNodes[j].appendChild(NavToggle);
.mainpage-top {
        }
    background-image: url('/images/2/23/Pilgrims-flock-to-Mecca-each-year-for-Hajj-cropped.jpg');
      }
    background-attachment: initial;
      NavFrame.setAttribute("id", "NavFrame" + indexNavigationBar);
    background-repeat: no-repeat;
     }
    background-size: cover;
  }
    background-position: 20% center;
}
 
/* سفید کردن لینک های بالای صفحه اول */
.mainpage-top a {
    color: white !important
}
 
/* حذف دکمه اضافه از جستجوی صفحه اول */
[name=go] {
    display: none
}
 
/* راست چین کردن جستجوی صفحه اول */
#mainpage-search {
     text-align: right
}
 
/* tables */
caption {
    text-align: center !important
}
.content table {
    max-width: 100%;
}
}


/* navboxes */
// $(createNavigationBarToggleButton);
.content ol li, .content ul li {
    margin-bottom: 0px;
}
.hlist > ul li, .hlist > dl li, ul.hlist li {
    margin-left: initial;
    margin-right: 8px;
}
table {
display: table !important;
}
.content table caption {
    display: table-caption;
}

نسخهٔ کنونی تا ‏۸ مهٔ ۲۰۲۲، ساعت ۱۰:۴۶

/* Any JavaScript here will be loaded for users using the mobile site */
mw.loader.using('mobile.site.styles')

/**
 * Collapsible tables; reimplemented with mw-collapsible
 * Styling is also in place to avoid FOUC
 *
 * Allows tables to be collapsed, showing only the header. See [[Help:Collapsing]].
 * @version 3.0.0 (2018-05-20)
 * @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
 * @author [[User:R. Koot]]
 * @author [[User:Krinkle]]
 * @author [[User:TheDJ]]
 * @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
 * is supported in MediaWiki core. Shimmable since MediaWiki 1.32
 *
 * @param {jQuery} $content
 */
function makeCollapsibleMwCollapsible( $content ) {
	var $tables = $content
		.find( 'table.collapsible:not(.mw-collapsible)' )
		.addClass( 'mw-collapsible' );

	$.each( $tables, function ( index, table ) {
		// mw.log.warn( 'This page is using the deprecated class collapsible. Please replace it with mw-collapsible.');
		if ( $( table ).hasClass( 'collapsed' ) ) {
			$( table ).addClass( 'mw-collapsed' );
			// mw.log.warn( 'This page is using the deprecated class collapsed. Please replace it with mw-collapsed.');
		}
	} );
	if ( $tables.length > 0 ) {
		mw.loader.using( 'jquery.makeCollapsible' ).then( function () {
			$tables.makeCollapsible();
		} );
	}
}
mw.hook( 'wikipage.content' ).add( makeCollapsibleMwCollapsible );

/**
 * Add support to mw-collapsible for autocollapse, innercollapse and outercollapse
 *
 * Maintainers: TheDJ
 */
function mwCollapsibleSetup( $collapsibleContent ) {
	var $element,
		$toggle,
		autoCollapseThreshold = 2;
	$.each( $collapsibleContent, function ( index, element ) {
		$element = $( element );
		if ( $element.hasClass( 'collapsible' ) ) {
			$element.find( 'tr:first > th:first' ).prepend( $element.find( 'tr:first > * > .mw-collapsible-toggle' ) );
		}
		if ( $collapsibleContent.length >= autoCollapseThreshold && $element.hasClass( 'autocollapse' ) ) {
			$element.data( 'mw-collapsible' ).collapse();
		} else if ( $element.hasClass( 'innercollapse' ) ) {
			if ( $element.parents( '.outercollapse' ).length > 0 ) {
				$element.data( 'mw-collapsible' ).collapse();
			}
		}
		// because of colored backgrounds, style the link in the text color
		// to ensure accessible contrast
		$toggle = $element.find( '.mw-collapsible-toggle' );
		if ( $toggle.length ) {
			// Make the toggle inherit text color
			if ( $toggle.parent()[ 0 ].style.color ) {
				$toggle.find( 'a' ).css( 'color', 'inherit' );
			}
		}
	} );
}

mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );

/**
 * Dynamic Navigation Bars (experimental)
 *
 * Description: See [[Wikipedia:NavFrame]].
 * Maintainers: UNMAINTAINED
 */

var collapseCaption = 'بسته';
var expandCaption = 'باز';

// Set up the words in your language
var navigationBarHide = '[' + collapseCaption + ']';
var navigationBarShow = '[' + expandCaption + ']';

/**
 * Shows and hides content and picture (if available) of navigation bars.
 *
 * @param {number} indexNavigationBar The index of navigation bar to be toggled
 * @param {jQuery.Event} event Event object
 * @return {boolean}
 */
function toggleNavigationBar( indexNavigationBar, event ) {
	var navToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
	var navFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
	var navChild;

	if ( !navFrame || !navToggle ) {
		return false;
	}

	// If shown now
	if ( navToggle.firstChild.data === navigationBarHide ) {
		for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
			if ( $( navChild ).hasClass( 'NavContent' ) ) {
				navChild.style.display = 'none';
			}
		}
		navToggle.firstChild.data = navigationBarShow;

	// If hidden now
	} else if ( navToggle.firstChild.data === navigationBarShow ) {
		for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
			if ( $( navChild ).hasClass( 'NavContent' ) ) {
				navChild.style.display = 'block';
			}
		}
		navToggle.firstChild.data = navigationBarHide;
	}

	event.preventDefault();
}

/**
 * Adds show/hide-button to navigation bars.
 *
 * @param {jQuery} $content
 */
function createNavigationBarToggleButton( $content ) {
	var j, navChild, navToggle, navToggleText, isCollapsed,
		indexNavigationBar = 0;
	// Iterate over all < div >-elements
	var $divs = $content.find( 'div.NavFrame:not(.mw-collapsible)' );
	$divs.each( function ( i, navFrame ) {
		indexNavigationBar++;
		navToggle = document.createElement( 'a' );
		navToggle.className = 'NavToggle';
		navToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
		navToggle.setAttribute( 'href', '#' );
		$( navToggle ).on( 'click', $.proxy( toggleNavigationBar, null, indexNavigationBar ) );

		isCollapsed = $( navFrame ).hasClass( 'collapsed' );
		/**
		 * Check if any children are already hidden.  This loop is here for backwards compatibility:
		 * the old way of making NavFrames start out collapsed was to manually add style="display:none"
		 * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
		 * the content visible without JavaScript support), the new recommended way is to add the class
		 * "collapsed" to the NavFrame itself, just like with collapsible tables.
		 */
		for ( navChild = navFrame.firstChild; navChild !== null && !isCollapsed; navChild = navChild.nextSibling ) {
			if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
				if ( navChild.style.display === 'none' ) {
					isCollapsed = true;
				}
			}
		}
		if ( isCollapsed ) {
			for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
				if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
					navChild.style.display = 'none';
				}
			}
		}
		navToggleText = document.createTextNode( isCollapsed ? navigationBarShow : navigationBarHide );
		navToggle.appendChild( navToggleText );

		// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
		for ( j = 0; j < navFrame.childNodes.length; j++ ) {
			if ( $( navFrame.childNodes[ j ] ).hasClass( 'NavHead' ) ) {
				navToggle.style.color = navFrame.childNodes[ j ].style.color;
				navFrame.childNodes[ j ].appendChild( navToggle );
			}
		}
		navFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
	} );
}

mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );

/** Dynamic Navigation Bars (experimental) *************************************
 *
 *  Description: See [[Wikipedia:NavFrame]].
 *  Maintainers: UNMAINTAINED
 */

// set up the words in your language
var NavigationBarHide = "[" + collapseCaption + "]";
var NavigationBarShow = "[" + expandCaption + "]";

// shows and hides content and picture (if available) of navigation bars
// Parameters:
//     indexNavigationBar: the index of navigation bar to be toggled
window.toggleNavigationBar = function(indexNavigationBar, event) {
  var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
  var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
  var NavChild;

  if (!NavFrame || !NavToggle) {
    return false;
  }

  /* if shown now */
  if (NavToggle.firstChild.data === NavigationBarHide) {
    for (NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
      if ($(NavChild).hasClass("NavContent") || $(NavChild).hasClass("NavPic")) {
        NavChild.style.display = "none";
      }
    }
    NavToggle.firstChild.data = NavigationBarShow;

    /* if hidden now */
  } else if (NavToggle.firstChild.data === NavigationBarShow) {
    for (NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
      if ($(NavChild).hasClass("NavContent") || $(NavChild).hasClass("NavPic")) {
        NavChild.style.display = "block";
      }
    }
    NavToggle.firstChild.data = NavigationBarHide;
  }

  event.preventDefault();
};

/* adds show/hide-button to navigation bars */
function createNavigationBarToggleButton() {
  var indexNavigationBar = 0;
  var NavFrame;
  var NavChild;
  /* iterate over all < div >-elements */
  var divs = document.getElementsByTagName("div");
  for (var i = 0;
    (NavFrame = divs[i]); i++) {
    /* if found a navigation bar */
    if ($(NavFrame).hasClass("NavFrame")) {

      indexNavigationBar++;
      var NavToggle = document.createElement("a");
      NavToggle.className = "NavToggle";
      NavToggle.setAttribute("id", "NavToggle" + indexNavigationBar);
      NavToggle.setAttribute("href", "#");
      $(NavToggle).on("click", $.proxy(window.toggleNavigationBar, window, indexNavigationBar));

      var isCollapsed = $(NavFrame).hasClass("collapsed");
      /**
       * Check if any children are already hidden.  This loop is here for backwards compatibility:
       * the old way of making NavFrames start out collapsed was to manually add style="display:none"
       * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
       * the content visible without JavaScript support), the new recommended way is to add the class
       * "collapsed" to the NavFrame itself, just like with collapsible tables.
       */
      for (NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling) {
        if ($(NavChild).hasClass("NavPic") || $(NavChild).hasClass("NavContent")) {
          if (NavChild.style.display === "none") {
            isCollapsed = true;
          }
        }
      }
      if (isCollapsed) {
        for (NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
          if ($(NavChild).hasClass("NavPic") || $(NavChild).hasClass("NavContent")) {
            NavChild.style.display = "none";
          }
        }
      }
      var NavToggleText = document.createTextNode(isCollapsed ? NavigationBarShow : NavigationBarHide);
      NavToggle.appendChild(NavToggleText);

      /* Find the NavHead and attach the toggle link (Must be this complicated because Moz"s firstChild handling is borked) */
      for (var j = 0; j < NavFrame.childNodes.length; j++) {
        if ($(NavFrame.childNodes[j]).hasClass("NavHead")) {
          NavToggle.style.color = NavFrame.childNodes[j].style.color;
          NavFrame.childNodes[j].appendChild(NavToggle);
        }
      }
      NavFrame.setAttribute("id", "NavFrame" + indexNavigationBar);
    }
  }
}

// $(createNavigationBarToggleButton);