User:DodoMan/modifysection.js: Difference between revisions
Jump to navigation
Jump to search
Created page with "→* Add a tab to toggle section editing links.: →sm8ps * 20220905: show links * 20220906: toggle links: if ( mw.config.get('wgNamespaceNumber') >= 0 ) { mw.loader.using( 'mediawiki.util', function () { $( function ( $ ) { var link = mw.util.addPortletLink( 'p-cactions', '#', 'Section editing', 'Section editing' ); $( link ).click( function ( e ) { e.preventDefault(); mw.loader.using( [ 'm..." |
m Justarandomamerican moved page User:Rafdodo/modifysection.js to User:DodoMan/modifysection.js: Automatically moved page while renaming the user "Rafdodo" to "DodoMan" |
(No difference)
|
Revision as of 12:44, 1 April 2024
/*
* Add a tab to toggle section editing links.
*/
/* sm8ps
* 20220905: show links
* 20220906: toggle links
*/
if ( mw.config.get('wgNamespaceNumber') >= 0 ) {
mw.loader.using( 'mediawiki.util', function () {
$( function ( $ ) {
var link = mw.util.addPortletLink( 'p-cactions', '#', 'Section editing', 'Section editing' );
$( link ).click( function ( e ) {
e.preventDefault();
mw.loader.using( [ 'mediawiki.api', 'oojs-ui' ], function () {
launch();
} );
} );
function launch( apicontinue ) {
/* get display style and toggle value */
var element = document.querySelector( '.mw-editsection' ) ;
var style = getComputedStyle( element ) ;
var display = style.display ;
var styles ;
if( display == 'none' ) {
styles = '.mw-editsection { display:inline!important; }';
} else {
styles = '.mw-editsection { display:none!important; }';
}
/* add tab */
var head = document.getElementsByTagName('HEAD')[0];
var css = document.createElement('style');
css.type = 'text/css';
if (css.styleSheet)
css.styleSheet.cssText = styles;
else
css.appendChild(document.createTextNode(styles));
head.appendChild(css);
}
} );
} );
}