https://wso.williams.edu/wiki/index.php?title=MediaWiki:Common.js&feed=atom&action=history
MediaWiki:Common.js - Revision history
2024-03-29T02:02:38Z
Revision history for this page on the wiki
MediaWiki 1.32.1
https://wso.williams.edu/wiki/index.php?title=MediaWiki:Common.js&diff=23696&oldid=prev
Al15: 1 revision imported
2019-06-17T17:07:36Z
<p>1 revision imported</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #222; text-align: center;">Revision as of 17:07, June 17, 2019</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>
Al15
https://wso.williams.edu/wiki/index.php?title=MediaWiki:Common.js&diff=23695&oldid=prev
wikipedia>Galobtter: remove unused class per request
2019-03-19T15:20:22Z
<p>remove unused class per request</p>
<p><b>New page</b></p><div>/**<br />
* Keep code in MediaWiki:Common.js to a minimum as it is unconditionally<br />
* loaded for all users on every wiki page. If possible create a gadget that is<br />
* enabled by default instead of adding it here (since gadgets are fully<br />
* optimized ResourceLoader modules with possibility to add dependencies etc.)<br />
*<br />
* Since Common.js isn't a gadget, there is no place to declare its<br />
* dependencies, so we have to lazy load them with mw.loader.using on demand and<br />
* then execute the rest in the callback. In most cases these dependencies will<br />
* be loaded (or loading) already and the callback will not be delayed. In case a<br />
* dependency hasn't arrived yet it'll make sure those are loaded before this.<br />
*/<br />
<br />
/* global mw, $ */<br />
/* jshint strict:false, browser:true */<br />
<br />
mw.loader.using( ['mediawiki.user', 'mediawiki.util', 'mediawiki.notify'] ).done( function () {<br />
/* Begin of mw.loader.using callback */<br />
<br />
/**<br />
* Main Page layout fixes<br />
*<br />
* Description: Adds an additional link to the complete list of languages available.<br />
* Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]]<br />
*/<br />
if ( mw.config.get( 'wgPageName' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) {<br />
$( function () {<br />
mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias',<br />
'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias' );<br />
} );<br />
}<br />
<br />
/**<br />
* Redirect User:Name/skin.js and skin.css to the current skin's pages<br />
* (unless the 'skin' page really exists)<br />
* @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js<br />
* @rev: 2<br />
*/<br />
if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) {<br />
var titleParts = mw.config.get( 'wgPageName' ).split( '/' );<br />
/* Make sure there was a part before and after the slash<br />
and that the latter is 'skin.js' or 'skin.css' */<br />
if ( titleParts.length == 2 ) {<br />
var userSkinPage = titleParts.shift() + '/' + mw.config.get( 'skin' );<br />
if ( titleParts.slice( -1 ) == 'skin.js' ) {<br />
window.location.href = mw.util.getUrl( userSkinPage + '.js' );<br />
} else if ( titleParts.slice( -1 ) == 'skin.css' ) {<br />
window.location.href = mw.util.getUrl( userSkinPage + '.css' );<br />
}<br />
}<br />
}<br />
<br />
/**<br />
* Map addPortletLink to mw.util<br />
* @deprecated: Use mw.util.addPortletLink instead.<br />
*/<br />
mw.log.deprecate( window, 'addPortletLink', mw.util.addPortletLink, 'Use mw.util.addPortletLink instead' );<br />
<br />
/**<br />
* Extract a URL parameter from the current URL<br />
* @deprecated: Use mw.util.getParamValue with proper escaping<br />
*/<br />
mw.log.deprecate( window, 'getURLParamValue', mw.util.getParamValue, 'Use mw.util.getParamValue instead' );<br />
<br />
/**<br />
* Test if an element has a certain class<br />
* @deprecated: Use $(element).hasClass() instead.<br />
*/<br />
mw.log.deprecate( window, 'hasClass', function ( element, className ) {<br />
return $( element ).hasClass( className );<br />
}, 'Use jQuery.hasClass() instead' );<br />
<br />
/**<br />
* @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL<br />
* @rev 6<br />
*/<br />
var extraCSS = mw.util.getParamValue( 'withCSS' ),<br />
extraJS = mw.util.getParamValue( 'withJS' );<br />
<br />
if ( extraCSS ) {<br />
if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {<br />
mw.loader.load( '/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css' );<br />
} else {<br />
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );<br />
}<br />
}<br />
<br />
if ( extraJS ) {<br />
if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {<br />
mw.loader.load( '/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript' );<br />
} else {<br />
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );<br />
}<br />
}<br />
<br />
/**<br />
* WikiMiniAtlas<br />
*<br />
* Description: WikiMiniAtlas is a popup click and drag world map.<br />
* This script causes all of our coordinate links to display the WikiMiniAtlas popup button.<br />
* The script itself is located on meta because it is used by many projects.<br />
* See [[Meta:WikiMiniAtlas]] for more information.<br />
* Note - use of this service is recommended to be repalced with mw:Help:Extension:Kartographer<br />
*/<br />
( function () {<br />
var require_wikiminiatlas = false;<br />
var coord_filter = /geohack/;<br />
$( function () {<br />
$( 'a.external.text' ).each( function( key, link ) {<br />
if ( link.href && coord_filter.exec( link.href ) ) {<br />
require_wikiminiatlas = true;<br />
// break from loop<br />
return false;<br />
}<br />
} );<br />
if ( $( 'div.kmldata' ).length ) {<br />
require_wikiminiatlas = true;<br />
}<br />
if ( require_wikiminiatlas ) {<br />
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );<br />
}<br />
} );<br />
} )();<br />
<br />
/**<br />
* Collapsible tables; reimplemented with mw-collapsibe<br />
* Styling is also in place to avoid FOUC<br />
* <br />
* Allows tables to be collapsed, showing only the header. See [[Help:Collapsing]].<br />
* @version 3.0.0 (2018-05-20)<br />
* @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js<br />
* @author [[User:R. Koot]]<br />
* @author [[User:Krinkle]]<br />
* @author [[User:TheDJ]]<br />
* @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which<br />
* is supported in MediaWiki core. Shimmable since MediaWiki 1.32<br />
*/<br />
function makeCollapsibleMwCollapsible( $content ) {<br />
var $tables = $content<br />
.find( 'table.collapsible:not(.mw-collapsible)' )<br />
.addClass( 'mw-collapsible' );<br />
<br />
$.each( $tables, function( index, table ) {<br />
// mw.log.warn( 'This page is using the deprecated class collapsible. Please replace it with mw-collapsible.');<br />
if( $( table ).hasClass( 'collapsed') ) {<br />
$( table ).addClass( 'mw-collapsed' );<br />
// mw.log.warn( 'This page is using the deprecated class collapsed. Please replace it with mw-collapsed.');<br />
}<br />
} );<br />
if( $tables.length > 0 ) {<br />
mw.loader.using( 'jquery.makeCollapsible' ).then( function() {<br />
$tables.makeCollapsible();<br />
} );<br />
}<br />
}<br />
mw.hook( 'wikipage.content' ).add( makeCollapsibleMwCollapsible );<br />
<br />
/**<br />
* Add support to mw-collapsible for autocollapse, innercollapse and outercollapse<br />
*<br />
* Maintainers: TheDJ<br />
*/<br />
function mwCollapsibleSetup( $collapsibleContent ) {<br />
var $element,<br />
$toggle,<br />
autoCollapseThreshold = 2;<br />
$.each( $collapsibleContent, function (index, element) {<br />
$element = $( element );<br />
if ( $element.hasClass( 'collapsible' ) ) {<br />
$element.find('tr:first > th:first').prepend( $element.find('tr:first > * > .mw-collapsible-toggle'));<br />
}<br />
if ( $collapsibleContent.length >= autoCollapseThreshold && $element.hasClass( 'autocollapse' ) ) {<br />
$element.data( 'mw-collapsible' ).collapse();<br />
} else if ( $element.hasClass( 'innercollapse' ) ) {<br />
if ( $element.parents( '.outercollapse' ).length > 0 ) {<br />
$element.data( 'mw-collapsible' ).collapse();<br />
}<br />
}<br />
// because of colored backgrounds, style the link in the text color<br />
// to ensure accessible contrast<br />
$toggle = $element.find( '.mw-collapsible-toggle' );<br />
if ( $toggle.length ) {<br />
// Make the toggle inherit text color<br />
if( $toggle.parent()[0].style.color ) {<br />
$toggle.find( 'a' ).css( 'color', 'inherit' );<br />
}<br />
}<br />
} );<br />
}<br />
<br />
mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );<br />
<br />
/**<br />
* Dynamic Navigation Bars (experimental)<br />
*<br />
* Description: See [[Wikipedia:NavFrame]].<br />
* Maintainers: UNMAINTAINED<br />
*/<br />
<br />
var collapseCaption = 'hide';<br />
var expandCaption = 'show';<br />
<br />
// Set up the words in your language<br />
var navigationBarHide = '[' + collapseCaption + ']';<br />
var navigationBarShow = '[' + expandCaption + ']';<br />
<br />
/**<br />
* Shows and hides content and picture (if available) of navigation bars.<br />
*<br />
* @param {number} indexNavigationBar The index of navigation bar to be toggled<br />
* @param {jQuery.Event} event Event object<br />
*/<br />
function toggleNavigationBar( indexNavigationBar, event ) {<br />
var navToggle = document.getElementById( 'NavToggle' + indexNavigationBar );<br />
var navFrame = document.getElementById( 'NavFrame' + indexNavigationBar );<br />
var navChild;<br />
<br />
if ( !navFrame || !navToggle ) {<br />
return false;<br />
}<br />
<br />
// If shown now<br />
if ( navToggle.firstChild.data === navigationBarHide ) {<br />
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {<br />
if ( $( navChild ).hasClass( 'NavContent' ) ) {<br />
navChild.style.display = 'none';<br />
}<br />
}<br />
navToggle.firstChild.data = navigationBarShow;<br />
<br />
// If hidden now<br />
} else if ( navToggle.firstChild.data === navigationBarShow ) {<br />
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {<br />
if ( $( navChild ).hasClass( 'NavContent' ) ) {<br />
navChild.style.display = 'block';<br />
}<br />
}<br />
navToggle.firstChild.data = navigationBarHide;<br />
}<br />
<br />
event.preventDefault();<br />
}<br />
<br />
/**<br />
* Adds show/hide-button to navigation bars.<br />
*<br />
* @param {jQuery} $content<br />
*/<br />
function createNavigationBarToggleButton( $content ) {<br />
var i, j, navChild, navToggle, navToggleText, isCollapsed,<br />
indexNavigationBar = 0;<br />
// Iterate over all < div >-elements<br />
var $divs = $content.find( 'div.NavFrame:not(.mw-collapsible)' );<br />
$divs.each( function ( i, navFrame ) {<br />
indexNavigationBar++;<br />
navToggle = document.createElement( 'a' );<br />
navToggle.className = 'NavToggle';<br />
navToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );<br />
navToggle.setAttribute( 'href', '#' );<br />
$( navToggle ).on( 'click', $.proxy( toggleNavigationBar, null, indexNavigationBar ) );<br />
<br />
isCollapsed = $( navFrame ).hasClass( 'collapsed' );<br />
/**<br />
* Check if any children are already hidden. This loop is here for backwards compatibility:<br />
* the old way of making NavFrames start out collapsed was to manually add style="display:none"<br />
* to all the NavPic/NavContent elements. Since this was bad for accessibility (no way to make<br />
* the content visible without JavaScript support), the new recommended way is to add the class<br />
* "collapsed" to the NavFrame itself, just like with collapsible tables.<br />
*/<br />
for ( navChild = navFrame.firstChild; navChild !== null && !isCollapsed; navChild = navChild.nextSibling ) {<br />
if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {<br />
if ( navChild.style.display === 'none' ) {<br />
isCollapsed = true;<br />
}<br />
}<br />
}<br />
if ( isCollapsed ) {<br />
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {<br />
if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {<br />
navChild.style.display = 'none';<br />
}<br />
}<br />
}<br />
navToggleText = document.createTextNode( isCollapsed ? navigationBarShow : navigationBarHide );<br />
navToggle.appendChild( navToggleText );<br />
<br />
// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)<br />
for ( j = 0; j < navFrame.childNodes.length; j++ ) {<br />
if ( $( navFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {<br />
navToggle.style.color = navFrame.childNodes[j].style.color;<br />
navFrame.childNodes[j].appendChild( navToggle );<br />
}<br />
}<br />
navFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );<br />
} );<br />
}<br />
<br />
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );<br />
<br />
/**<br />
* Magic editintros ****************************************************<br />
*<br />
* Description: Adds editintros on disambiguation pages and BLP pages.<br />
* Maintainers: [[User:RockMFR]]<br />
*/<br />
function addEditIntro( name ) {<br />
$( '.mw-editsection, #ca-edit, #ca-ve-edit' ).find( 'a' ).each( function ( i, el ) {<br />
el.href = $( this ).attr( 'href' ) + '&editintro=' + name;<br />
} );<br />
}<br />
<br />
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {<br />
$( function () {<br />
if ( document.getElementById( 'disambigbox' ) ) {<br />
addEditIntro( 'Template:Disambig_editintro' );<br />
}<br />
} );<br />
<br />
$( function () {<br />
var cats = mw.config.get('wgCategories');<br />
if ( !cats ) {<br />
return;<br />
}<br />
if ( $.inArray( 'Living people', cats ) !== -1 || $.inArray( 'Possibly living people', cats ) !== -1 ) {<br />
addEditIntro( 'Template:BLP_editintro' );<br />
}<br />
} );<br />
}<br />
<br />
/* Actions specific to the edit page */<br />
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' ) {<br />
/**<br />
* Fix edit summary prompt for undo<br />
*<br />
* Fixes the fact that the undo function combined with the "no edit summary prompter"<br />
* complains about missing editsummary, if leaving the edit summary unchanged.<br />
* Added by [[User:Deskana]], code by [[User:Tra]].<br />
* See also [[phab:T10912]].<br />
*/<br />
$(function () {<br />
if (document.location.search.indexOf('undo=') !== -1 && document.getElementsByName('wpAutoSummary')[0]) {<br />
document.getElementsByName('wpAutoSummary')[0].value = '1';<br />
}<br />
});<br />
}<br />
<br />
/* End of mw.loader.using callback */<br />
} );<br />
/* DO NOT ADD CODE BELOW THIS LINE */</div>
wikipedia>Galobtter