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
Jump to: navigation, search
m (onclick)
m (+only in main name space; fade in and out)
Line 12: Line 12:
 
/* global $j */
 
/* global $j */
 
/* add a link of the section while hovering it */
 
/* add a link of the section while hovering it */
if ($j('h1,h2,h3,h4').length) {
+
if (mw.config.get( 'wgNamespaceNumber' ) === 0 ) {// only in main namespace
  $j('h1,h2,h3,h4').mouseenter(function () {
+
  if ($j('h1,h2,h3,h4').length) {
    hrefID = $j(this).find('.mw-headline').attr('id');
+
    $j('h1,h2,h3,h4').mouseenter(function () {
    hrefID = hrefID === 'undefined' ? false : hrefID;
+
      hrefID = $j(this).find('.mw-headline').attr('id');
    $j(this).append('<a ' +  
+
      hrefID = hrefID === 'undefined' ? false : hrefID;
      ' class="headerlink" ' +  
+
      hasCurRevisionId = mw.config.get( 'wgCurRevisionId') ? true : false;
      ' onclick="function () {return false};" ' +  
+
      tmpArtilePath = mw.config.get( 'wgServer') +
      ' style="color:#CCCCCC; margin-left:0.2em;" ' +  
+
          mw.config.get( 'wgArticlePath').replace(/\$1/, mw.config.get( 'wgPageName')) ;
      ' title="' + ( $.jI18n.en.toolTipHeadingLink ? $.resource('toolTipHeadingLink') : 'Permanent link to this headline' ) + '" ' +  
+
      msgBox = '<div id=linkmsg_' + hrefID + ' style=display:none class=js-messagebox >Link to this head line (1) or versioned permanent link (2):' +
      ' href="' + '?oldid=' + wgCurRevisionId + ( hrefID ? '#' + hrefID : '' ) + '" ><img src="http://species-id.net/o/media/f/f9/Button-sprite_link-pale.png"  style="vertical-align:middle;" width="16" height="16"></a>');
+
        '<ol>' +
  }).mouseleave(function () {
+
          '<li>' + tmpArtilePath + ( hrefID ? '#' + hrefID : '' ) + '</li>' +
    $j(this).find('a.headerlink').remove();
+
          ( hasCurRevisionId ? '<li>' + tmpArtilePath + '?oldid=' + wgCurRevisionId + ( hrefID ? '#' + hrefID : '' ) + '</li>' : '')  +
  });
+
        '</ol></div>';
 +
      $j(this).append('<a ' +  
 +
        ' class="headerlink" ' +  
 +
        ' onclick="$j(this).parent().before( msgBox );' +
 +
          '$j(\'#linkmsg_' + hrefID + '\').fadeIn(\'slow\');' +
 +
          '$j(\'#linkmsg_' + hrefID + '\').mouseleave (function () {$j(this).fadeOut(\'slow\', function () {$j(this).remove;});} );' +
 +
          '$j(this).attr(\'href\',\'#linkmsg_' + hrefID + '\')" ' +  
 +
        ' style="color:#CCCCCC; margin-left:0.2em;" ' +  
 +
        ' title="' + ( $.jI18n.en.toolTipHeadingLink ? $.resource('toolTipHeadingLink') : 'Click to get a (permanent) link of this headline' ) + '" ' +  
 +
        ' href="' + '?oldid=' + wgCurRevisionId + ( hrefID ? '#' + hrefID : '' ) + '" ><img src="http://species-id.net/o/media/f/f9/Button-sprite_link-pale.png"  style="vertical-align:middle;" width="16" height="16"></a>');
 +
    }).mouseleave(function () {
 +
      $j(this).find('a.headerlink').remove();
 +
    });
 +
  }
 
}
 
}
 
// </source>
 
// </source>

Revision as of 14:58, 17 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 */
if (mw.config.get( 'wgNamespaceNumber' ) === 0 ) {// only in main 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')) ;
      msgBox = '<div id=linkmsg_' + hrefID + ' style=display:none class=js-messagebox >Link to this head line (1) or versioned permanent link (2):' +
        '<ol>' + 
          '<li>' + tmpArtilePath + ( hrefID ? '#' + hrefID : '' ) + '</li>' +
          ( hasCurRevisionId ? '<li>' + tmpArtilePath + '?oldid=' + wgCurRevisionId + ( hrefID ? '#' + hrefID : '' ) + '</li>' : '')  +
        '</ol></div>';
      $j(this).append('<a ' + 
        ' class="headerlink" ' + 
        ' onclick="$j(this).parent().before( msgBox );' + 
          '$j(\'#linkmsg_' + hrefID + '\').fadeIn(\'slow\');' + 
          '$j(\'#linkmsg_' + hrefID + '\').mouseleave (function () {$j(this).fadeOut(\'slow\', function () {$j(this).remove;});} );' + 
          '$j(this).attr(\'href\',\'#linkmsg_' + hrefID + '\')" ' + 
        ' style="color:#CCCCCC; margin-left:0.2em;" ' + 
        ' title="' + ( $.jI18n.en.toolTipHeadingLink ? $.resource('toolTipHeadingLink') : 'Click to get a (permanent) link of this headline' ) + '" ' + 
        ' href="' + '?oldid=' + wgCurRevisionId + ( hrefID ? '#' + hrefID : '' ) + '" ><img src="http://species-id.net/o/media/f/f9/Button-sprite_link-pale.png"  style="vertical-align:middle;" width="16" height="16"></a>');
    }).mouseleave(function () {
      $j(this).find('a.headerlink').remove();
    });
  }
}
// </source>