85,465
edits
m (Test) |
m (Test) |
||
Line 12: | Line 12: | ||
*/ | */ | ||
/* global mw, $ | /* global mw, $ */ | ||
/* jshint strict:false, browser:true */ | /* jshint strict:false, browser:true */ | ||
mw.loader.using( ['mediawiki. | mw.loader.using( ['mediawiki.user', 'mediawiki.util', 'mediawiki.notify'] ).done( function () { | ||
/* Begin of mw.loader.using callback */ | /* Begin of mw.loader.using callback */ | ||
Line 23: | Line 23: | ||
* Description: Adds an additional link to the complete list of languages available. | * Description: Adds an additional link to the complete list of languages available. | ||
* Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]] | * Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]] | ||
* | */ | ||
if ( mw.config.get( 'wgPageName' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) { | if ( mw.config.get( 'wgPageName' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) { | ||
$( function () { | $( function () { | ||
Line 30: | Line 30: | ||
} ); | } ); | ||
} | } | ||
/** | /** | ||
Line 81: | Line 80: | ||
if ( extraCSS ) { | if ( extraCSS ) { | ||
if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) { | if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) { | ||
mw.loader.load( '/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css' ); | |||
} else { | } else { | ||
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } ); | mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } ); | ||
Line 89: | Line 88: | ||
if ( extraJS ) { | if ( extraJS ) { | ||
if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) { | if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) { | ||
mw.loader.load( '/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript' ); | |||
} else { | } else { | ||
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } ); | mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } ); | ||
} | } | ||
} | } | ||
Line 167: | Line 126: | ||
* Collapsible tables | * Collapsible tables | ||
* | * | ||
* Allows tables to be collapsed, showing only the header. See [[ | * Allows tables to be collapsed, showing only the header. See [[Help:Collapsing]]. | ||
* | * | ||
* @version 2.0.3 (2014-03-14) | * @version 2.0.3 (2014-03-14) | ||
Line 192: | Line 151: | ||
var Rows = Table.rows; | var Rows = Table.rows; | ||
var i; | var i; | ||
var $row0 = $(Rows[0]); | |||
if ( Button.firstChild.data === collapseCaption ) { | if ( Button.firstChild.data === collapseCaption ) { | ||
Line 200: | Line 160: | ||
} else { | } else { | ||
for ( i = 1; i < Rows.length; i++ ) { | for ( i = 1; i < Rows.length; i++ ) { | ||
Rows[i].style.display = | Rows[i].style.display = $row0.css( 'display' ); | ||
} | } | ||
Button.firstChild.data = collapseCaption; | Button.firstChild.data = collapseCaption; | ||
Line 274: | Line 234: | ||
mw.hook( 'wikipage.content' ).add( createCollapseButtons ); | mw.hook( 'wikipage.content' ).add( createCollapseButtons ); | ||
/** | |||
* 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 ( $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(); | |||
} | |||
} | |||
$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 ); | |||
/** | /** | ||
Line 436: | Line 426: | ||
} | } | ||
} ); | } ); | ||
} | |||
/* Actions specific to the edit page */ | |||
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' ) { | |||
/** | |||
* Fix edit summary prompt for undo | |||
* | |||
* Fixes the fact that the undo function combined with the "no edit summary prompter" | |||
* complains about missing editsummary, if leaving the edit summary unchanged. | |||
* Added by [[User:Deskana]], code by [[User:Tra]]. | |||
* See also [[phab:T10912]]. | |||
*/ | |||
$(function () { | |||
if (document.location.search.indexOf('undo=') !== -1 && document.getElementsByName('wpAutoSummary')[0]) { | |||
document.getElementsByName('wpAutoSummary')[0].value = '1'; | |||
} | |||
}); | |||
} | } | ||