User:SapadorCastelo/global.js

window.HeaderLinksCopyOnClick = true

importArticles({	type: 'script',	articles: [		'u:dev:MediaWiki:ListFiles/code.js',	] });

// version of dev:HeaderLinks (function($, mw) {

'use strict'; if (window.HeaderLinksLoaded) { return; } window.HeaderLinksLoaded = true; var headerLinks = { // Loading function init: function {

var headers = $('.mw-headline');

// abort if no headers exist if (!headers.length) { return; }

// don't load twice if ($('.mw-header-link').length) { return; }

headerLinks.addLinks(headers);

},

// Inserts link icons and associated CSS addLinks: function(headers) {

// append css to head // easier than importing such a small amount of code function init(i18n) { mw.util.addCSS(					'.mw-header-link {float:right; opacity:0; transition:opacity .3s;}' +                   'h1:hover .mw-header-link,h2:hover .mw-header-link,h3:hover .mw-header-link,h4:hover .mw-header-link,h5:hover .mw-header-link,h6:hover .mw-header-link{opacity:.5;}' +                    '.mw-headline .mw-header-link:hover{opacity:1;}'                );

headers.each(function {

var $svg = $(' ') .attr('class', 'wds-icon wds-icon-small') .append(                           $(' ')                            .attr('href', '#wds-icons-link-small')                        ), $a = $('') .attr('title', i18n.msg('text').plain) .append($svg), $span = $(' ') .attr('class', 'mw-header-link') .append($a), $h = $(this);

$a[0].innerHTML = $a[0].innerHTML; $a.attr('href', '#' + $h.attr('id')); $h.append($span);

});               if (window.HeaderLinksCopyOnClick) {                	$('.mw-header-link > a').click(function { var $temp = $(' '); $('body').append($temp); $temp.val( + mw.config.get('wgPageName') + $(this).attr('href') + ).select; document.execCommand('copy'); $temp.remove; });               }            }            mw.hook('dev.i18n').add(function(i18n) { i18n.loadMessages('HeaderLinks').then(init); });           importArticle({ type: 'script', article: 'u:dev:MediaWiki:I18n-js/code.js' });       }    };

$(headerLinks.init); }(jQuery, mediaWiki));