MediaWiki:Gadget-HeadingLink.js: Unterschied zwischen den Versionen

Aus Offene Naturführer BiolFlor
Wechseln zu: Navigation, Suche
K (slideUp/down)
K (allow main + template namespace)
Zeile 12: Zeile 12:
 
/* global $j */
 
/* global $j */
 
/* add a link of the section while hovering it */
 
/* add a link of the section while hovering it */
if (mw.config.get( 'wgNamespaceNumber' ) === 0 ) {// only in main namespace
+
switch (mw.config.get( 'wgNamespaceNumber' )) {
   if ($j('h1,h2,h3,h4').length) {
+
  case  0: // main namespace
    $j('h1,h2,h3,h4').mouseenter(function () {
+
   case 10: // template namespace
      hrefID = $j(this).find('.mw-headline').attr('id');
+
    if ($j('h1,h2,h3,h4').length) {
      hrefID = hrefID === 'undefined' ? false : hrefID;
+
      $j('h1,h2,h3,h4').mouseenter(function () {
      hasCurRevisionId = mw.config.get( 'wgCurRevisionId') ? true : false;
+
        hrefID = $j(this).find('.mw-headline').attr('id');
      tmpArtilePath = mw.config.get( 'wgServer') +  
+
        hrefID = hrefID === 'undefined' ? false : hrefID;
          mw.config.get( 'wgArticlePath').replace(/\$1/, mw.config.get( 'wgPageName')) ;
+
        hasCurRevisionId = mw.config.get( 'wgCurRevisionId') ? true : false;
      msgBox = '<div id=linkmsg_' + hrefID + ' style=display:none class=js-messagebox >(1) Normal link to this head line or (2) the permanent link with version number:' +
+
        tmpArtilePath   = mw.config.get( 'wgServer') +  
        '<ol>' +  
+
            mw.config.get( 'wgArticlePath').replace(/\$1/, mw.config.get( 'wgPageName')) ;
          '<li>' + tmpArtilePath + ( hrefID ? '#' + hrefID : '' ) + '</li>' +
+
        msgBox = '<div id=linkmsg_' + hrefID + ' style=display:none class=js-messagebox >' +
          ( hasCurRevisionId ? '<li>' + tmpArtilePath + '?oldid=' + mw.config.get('wgCurRevisionId') + ( hrefID ? '#' + hrefID : '' ) + '</li>' : '')  +
+
          ( $.jI18n.en.toolTipHeadingLinkHelp ? $.resource('toolTipHeadingLinkHelp') : '(1) Normal link to this head line or (2) the permanent link with version number:' ) +
        '</ol></div>';
+
          '<ol>' +  
      $j(this).append('<a ' +  
+
            '<li>' + tmpArtilePath + ( hrefID ? '#' + hrefID : '' ) + '</li>' +
        ' class="headerlink" ' +  
+
            ( hasCurRevisionId ? '<li>' + tmpArtilePath + '?oldid=' + mw.config.get('wgCurRevisionId') + ( hrefID ? '#' + hrefID : '' ) + '</li>' : '')  +
        ' onclick="$j(this).parent().before( msgBox );' +  
+
          '</ol></div>';
          '$j(\'#linkmsg_' + hrefID + '\').slideDown(\'slow\');' +  
+
        $j(this).append('<a ' +  
          '$j(\'#linkmsg_' + hrefID + '\').mouseleave (function () {$j(this).slideUp(\'slow\', function () {$j(this).remove;});} );' +  
+
          ' class="headerlink" ' +  
          '$j(this).attr(\'href\',\'#linkmsg_' + hrefID + '\')" ' +  
+
          ' onclick="$j(this).parent().before( msgBox );' +  
        ' style="color:#CCCCCC; margin-left:0.2em;" ' +  
+
            '$j(\'#linkmsg_' + hrefID + '\').slideDown(\'slow\');' +  
        ' title="' + ( $.jI18n.en.toolTipHeadingLink ? $.resource('toolTipHeadingLink') : 'Click to get a (permanent) link of this headline' ) + '" ' +  
+
            '$j(\'#linkmsg_' + hrefID + '\').mouseleave (function () {$j(this).slideUp(\'slow\', function () {$j(this).remove;});} );' +  
        ' 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>');
+
            '$j(this).attr(\'href\',\'#linkmsg_' + hrefID + '\')" ' +  
    }).mouseleave(function () {
+
          ' style="color:#CCCCCC; margin-left:0.2em;" ' +  
      $j(this).find('a.headerlink').remove();
+
          ' title="' + ( $.jI18n.en.toolTipHeadingLink ? $.resource('toolTipHeadingLink') : 'Click to get a (permanent) link of this headline' ) + '" ' +  
    });
+
          ' href="#" ><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();
 +
      });
 +
    }
 +
    break;
 
}
 
}
 
// </source>
 
// </source>

Version vom 17. Oktober 2011, 16:15 Uhr

// <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 */
switch (mw.config.get( 'wgNamespaceNumber' )) {
  case  0: // main namespace
  case 10: // template 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 >' + 
          ( $.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('<a ' + 
          ' class="headerlink" ' + 
          ' onclick="$j(this).parent().before( msgBox );' + 
            '$j(\'#linkmsg_' + hrefID + '\').slideDown(\'slow\');' + 
            '$j(\'#linkmsg_' + hrefID + '\').mouseleave (function () {$j(this).slideUp(\'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="#" ><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();
      });
    }
    break;
}
// </source>