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

Aus Offene Naturführer BiolFlor
Wechseln zu: Navigation, Suche
K (href fix)
K (fix heading link)
 
(7 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
// <source lang="javascript">
+
// <syntaxhighlight lang="javascript">
// This JavaScript will be loaded only for some pages, see MediaWiki:Common.js
+
/** 
// Copyright A. Plank
+
* This JavaScript will be loaded only for some pages, see MediaWiki:Common.js
/*
+
* This program is free software; you can redistribute it and/or modify it under the terms of  
  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  
  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   
  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   
  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   
  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General   
+
* Public License (http://www.gnu.org/licenses/) for more details.   
  Public License (http://www.gnu.org/licenses/) for more details.   
+
* Author: A. Plank
 +
* @description add a link of the section while hovering it
 +
* @requires jqueryEscapeId()
 +
* @requires $.jI18n
 +
* @requires $.resource()
 
  */
 
  */
/* global $j */
+
/*jslint sloppy: true, indent: 2, white: true */
/* add a link of the section while hovering it */
+
/*global clearInterval: false, clearTimeout: false, document: false, event: false, frames: false, history: false, Image: false, location: false, name: false, navigator: false, Option: false, parent: false, screen: false, setInterval: false, setTimeout: false, window: false, XMLHttpRequest: false, $: false, mw: false */
 
switch (mw.config.get( 'wgNamespaceNumber' )) {
 
switch (mw.config.get( 'wgNamespaceNumber' )) {
 
   case  0: // main namespace
 
   case  0: // main namespace
 +
  case  1: // discussion namespace
 +
  case  2: // user namespace
 
   case 10: // template namespace
 
   case 10: // template namespace
     if ($j('h1,h2,h3,h4').length) {
+
  case 12: // help namespace
       $j('h1,h2,h3,h4').mouseenter(function () {
+
  case 200: // portal namespace
         hrefID = $j(this).find('.mw-headline').attr('id');
+
     if ($('h1,h2,h3,h4').length) {
        hrefID = hrefID === 'undefined' ? false : hrefID;
+
       $('h1,h2,h3,h4').mouseenter(function () {
         hasCurRevisionId = mw.config.get( 'wgCurRevisionId') ? true : false;
+
         hrefID = $(this).find('.mw-headline').attr('id'); hrefID = hrefID === 'undefined' ? false : hrefID;
         tmpArtilePath    = mw.config.get( 'wgServer') +  
+
         hasCurRevisionId = (mw.config.get( 'wgCurRevisionId') ? true : false);
             mw.config.get( 'wgArticlePath').replace(/\$1/, mw.config.get( 'wgPageName')) ;
+
         tmpArtilePath    = (mw.config.get( 'wgServer') +  
         msgBox = '<div id=linkmsg_' + hrefID + ' style=display:none class=js-messagebox >' +  
+
             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>' +  
Zeile 28: Zeile 35:
 
             ( 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('<a ' +  
+
      $(this).append(' '
           ' class="headerlink" ' +  
+
        + '<span ' +
           ' onclick="$j(this).parent().before( msgBox );' +  
+
           ' class="headinglink" ' +  
             '$j(jqueryEscapeId(\'#linkmsg_' + hrefID + '\')).slideDown(\'slow\');' +
+
           ' onclick="' +
            '$j(jqueryEscapeId(\'#linkmsg_' + hrefID + '\')).mouseleave (function () {$j(this).slideUp(\'slow\', function () {$j(this).remove();});} );' +  
+
            '$(this).parent().before( msgBoxHeadinglink );' +  
             '$j(this).attr(\'href\',\'#linkmsg_' + hrefID + '\')" ' +
+
             '$(jqueryEscapeId(\'#linkmsg_' + hrefID + '\'))' +
 +
              '.slideDown(\'slow\', function() {$(this).addClass(\'is-shown\');} )' +
 +
              '.mouseleave (function () {if($(this).hasClass(\'is-shown\')) {$(this).slideUp(\'slow\', function () {$(this).remove();return false;});return false;} });' +  
 +
             '"' +
 
           ' 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' ) + '" ' +  
           ' href="#' + 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>');
+
           ' >'
 +
        + '<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('a.headerlink').remove();
+
         $(this).find('span.headinglink').remove();
 
       });
 
       });
 
     }
 
     }
 
     break;
 
     break;
 
}
 
}
// </source>
+
// </syntaxhighlight>

Aktuelle Version vom 13. Juni 2014, 16:21 Uhr

// <syntaxhighlight lang="javascript">
/**  
 * This JavaScript will be loaded only for some pages, see MediaWiki:Common.js
 * 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.  
 * Author: A. Plank
 * @description add a link of the section while hovering it 
 * @requires jqueryEscapeId()
 * @requires $.jI18n
 * @requires $.resource()
 */
/*jslint sloppy: true, indent: 2, white: true */
/*global clearInterval: false, clearTimeout: false, document: false, event: false, frames: false, history: false, Image: false, location: false, name: false, navigator: false, Option: false, parent: false, screen: false, setInterval: false, setTimeout: false, window: false, XMLHttpRequest: false, $: false, mw: false */
switch (mw.config.get( 'wgNamespaceNumber' )) {
  case  0: // main namespace
  case  1: // discussion namespace
  case  2: // user namespace
  case 10: // template namespace
  case 12: // help namespace
  case 200: // portal namespace
    if ($('h1,h2,h3,h4').length) {
      $('h1,h2,h3,h4').mouseenter(function () {
        hrefID = $(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>';
       $(this).append(' '
        + '<span ' +
          ' class="headinglink" ' + 
          ' onclick="' +
            '$(this).parent().before( msgBoxHeadinglink );' + 
            '$(jqueryEscapeId(\'#linkmsg_' + hrefID + '\'))' + 
              '.slideDown(\'slow\', function() {$(this).addClass(\'is-shown\');} )' + 
              '.mouseleave (function () {if($(this).hasClass(\'is-shown\')) {$(this).slideUp(\'slow\', function () {$(this).remove();return false;});return false;} });' + 
            '"' +
          ' 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 () {
        $(this).find('span.headinglink').remove();
      });
    }
    break;
}
// </syntaxhighlight>