Maintenance
All wikis at Biowikifarm are in read-only mode due to the restoration after a severe cyberattack in October 2023.
After 1 year being shut down the Biowikifarm is online again.
You see the latest restored version from 18th October 2023.
Difference between revisions of "MediaWiki:Gadget-HeadingLink.js"
From Species-ID
m (allow main + template namespace) |
m (update from ON) |
||
Line 11: | Line 11: | ||
*/ | */ | ||
/* global $j */ | /* global $j */ | ||
− | /* add a link of the section while hovering it */ | + | /* add a link of the section while hovering it |
+ | DEPENDENCIES: jqueryEscapeId() | ||
+ | */ | ||
switch (mw.config.get( 'wgNamespaceNumber' )) { | switch (mw.config.get( 'wgNamespaceNumber' )) { | ||
case 0: // main namespace | case 0: // main namespace | ||
case 10: // template namespace | case 10: // template namespace | ||
+ | case 12: // help namespace | ||
if ($j('h1,h2,h3,h4').length) { | if ($j('h1,h2,h3,h4').length) { | ||
$j('h1,h2,h3,h4').mouseenter(function () { | $j('h1,h2,h3,h4').mouseenter(function () { | ||
Line 22: | Line 25: | ||
tmpArtilePath = mw.config.get( 'wgServer') + | tmpArtilePath = mw.config.get( 'wgServer') + | ||
mw.config.get( 'wgArticlePath').replace(/\$1/, mw.config.get( 'wgPageName')) ; | mw.config.get( 'wgArticlePath').replace(/\$1/, mw.config.get( 'wgPageName')) ; | ||
− | + | msgBoxHeadinglink = '<div id=linkmsg_' + hrefID + ' style=display:none class=js-messagebox >' + | |
( $.jI18n.en.toolTipHeadingLinkHelp ? $.resource('toolTipHeadingLinkHelp') : '(1) Normal link to this head line or (2) the permanent link with version number:' ) + | ( $.jI18n.en.toolTipHeadingLinkHelp ? $.resource('toolTipHeadingLinkHelp') : '(1) Normal link to this head line or (2) the permanent link with version number:' ) + | ||
'<ol>' + | '<ol>' + | ||
Line 28: | Line 31: | ||
( hasCurRevisionId ? '<li>' + tmpArtilePath + '?oldid=' + mw.config.get('wgCurRevisionId') + ( hrefID ? '#' + hrefID : '' ) + '</li>' : '') + | ( hasCurRevisionId ? '<li>' + tmpArtilePath + '?oldid=' + mw.config.get('wgCurRevisionId') + ( hrefID ? '#' + hrefID : '' ) + '</li>' : '') + | ||
'</ol></div>'; | '</ol></div>'; | ||
− | $j(this).append('< | + | $j(this).append(' ' |
− | ' class=" | + | + '<span ' + |
− | ' onclick="$j(this).parent().before( | + | ' class="headinglink" ' + |
− | '$j(\'#linkmsg_' + hrefID + '\').slideDown(\'slow\');' + | + | ' onclick="' + |
− | '$j(\'#linkmsg_' + hrefID + '\').mouseleave (function () {$j(this).slideUp(\'slow\', function () {$j(this).remove;});} );' + | + | '$j(this).parent().before( msgBoxHeadinglink );' + |
− | ' | + | '$j(jqueryEscapeId(\'#linkmsg_' + hrefID + '\')).slideDown(\'slow\');' + |
+ | '$j(jqueryEscapeId(\'#linkmsg_' + hrefID + '\')).mouseleave (function () {$j(this).slideUp(\'slow\', function () {$j(this).remove();});} );' + | ||
+ | '"' + | ||
' style="color:#CCCCCC; margin-left:0.2em;" ' + | ' style="color:#CCCCCC; margin-left:0.2em;" ' + | ||
' title="' + ( $.jI18n.en.toolTipHeadingLink ? $.resource('toolTipHeadingLink') : 'Click to get a (permanent) link of this headline' ) + '" ' + | ' title="' + ( $.jI18n.en.toolTipHeadingLink ? $.resource('toolTipHeadingLink') : 'Click to get a (permanent) link of this headline' ) + '" ' + | ||
− | ' | + | ' >' |
+ | + '<img src="http://species-id.net/o/media/f/f9/Button-sprite_link-pale.png" style="vertical-align:middle;" width="16" height="16">' | ||
+ | + '</span>'); | ||
}).mouseleave(function () { | }).mouseleave(function () { | ||
− | $j(this).find(' | + | $j(this).find('span.headinglink').remove(); |
}); | }); | ||
} | } |
Revision as of 10:20, 18 October 2011
// <source lang="javascript">
// This JavaScript will be loaded only for some pages, see MediaWiki:Common.js
// Copyright A. Plank
/*
This program is free software; you can redistribute it and/or modify it under the terms of
the EUPL v.1.1 or (at your option) the GNU General Public License as published by the Free
Software Foundation; either GPL v.3 or (at your option) any later version. This program is
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License (http://www.gnu.org/licenses/) for more details.
*/
/* global $j */
/* add a link of the section while hovering it
DEPENDENCIES: jqueryEscapeId()
*/
switch (mw.config.get( 'wgNamespaceNumber' )) {
case 0: // main namespace
case 10: // template namespace
case 12: // help namespace
if ($j('h1,h2,h3,h4').length) {
$j('h1,h2,h3,h4').mouseenter(function () {
hrefID = $j(this).find('.mw-headline').attr('id');
hrefID = hrefID === 'undefined' ? false : hrefID;
hasCurRevisionId = mw.config.get( 'wgCurRevisionId') ? true : false;
tmpArtilePath = mw.config.get( 'wgServer') +
mw.config.get( 'wgArticlePath').replace(/\$1/, mw.config.get( 'wgPageName')) ;
msgBoxHeadinglink = '<div id=linkmsg_' + hrefID + ' style=display:none class=js-messagebox >' +
( $.jI18n.en.toolTipHeadingLinkHelp ? $.resource('toolTipHeadingLinkHelp') : '(1) Normal link to this head line or (2) the permanent link with version number:' ) +
'<ol>' +
'<li>' + tmpArtilePath + ( hrefID ? '#' + hrefID : '' ) + '</li>' +
( hasCurRevisionId ? '<li>' + tmpArtilePath + '?oldid=' + mw.config.get('wgCurRevisionId') + ( hrefID ? '#' + hrefID : '' ) + '</li>' : '') +
'</ol></div>';
$j(this).append(' '
+ '<span ' +
' class="headinglink" ' +
' onclick="' +
'$j(this).parent().before( msgBoxHeadinglink );' +
'$j(jqueryEscapeId(\'#linkmsg_' + hrefID + '\')).slideDown(\'slow\');' +
'$j(jqueryEscapeId(\'#linkmsg_' + hrefID + '\')).mouseleave (function () {$j(this).slideUp(\'slow\', function () {$j(this).remove();});} );' +
'"' +
' style="color:#CCCCCC; margin-left:0.2em;" ' +
' title="' + ( $.jI18n.en.toolTipHeadingLink ? $.resource('toolTipHeadingLink') : 'Click to get a (permanent) link of this headline' ) + '" ' +
' >'
+ '<img src="http://species-id.net/o/media/f/f9/Button-sprite_link-pale.png" style="vertical-align:middle;" width="16" height="16">'
+ '</span>');
}).mouseleave(function () {
$j(this).find('span.headinglink').remove();
});
}
break;
}
// </source>