MediaWiki:Common.js: Unterschied zwischen den Versionen

Zur Navigation springen Zur Suche springen
Zeile 2: Zeile 2:
 
  if (wgUserGroups[i] == 'sysop')
 
  if (wgUserGroups[i] == 'sysop')
 
   var sysopRights = true;  
 
   var sysopRights = true;  
 +
 +
/***********************************
 +
      Bildformular
 +
***********************************/
 +
if ( wgNamespaceNumber == 6
 +
  && wgPageName.toLowerCase().indexOf('.jpg')!= -1
 +
  && document.getElementById('wpTextbox1')
 +
  && !document.getElementById('wpTextbox1').firstChild
 +
  ) {
 +
var d = new Date();
 +
var datum = d.getFullYear()+"/"+(d.getMonth()+1)+"/"+d.getDate();
 +
var p = "\n{{bild " +
 +
"\n|titel =  " +
 +
"\n|titel_j = " +
 +
"\n|titel_d =  " +
 +
"\n|detail = " +
 +
"\n|genre = " +
 +
"\n|genre2 = " +
 +
"\n|material = " +
 +
"\n|maße = " +
 +
"\n|artist= " +
 +
"\n|artist_dates = " +
 +
"\n|periode = " +
 +
"\n|jahr = " +
 +
"\n|serie = " +
 +
"\n|buch = " +
 +
"\n|serie_j = " +
 +
"\n|ort = " +
 +
"\n|treasure = " +
 +
"\n|q_link = " +
 +
"\n|q_text = " +
 +
"\n|quelle_b = " +
 +
"\n|quelle_d = " + datum +
 +
"\n|collection = " +
 +
"\n}}"+
 +
"<!--Beschreibung-->\n\n\n\n\n<noinclude>[["+"Kategorie:Bild]]</noinclude>";
 +
 +
document.getElementById('wpTextbox1').innerHTML = p;
 +
 +
}
  
 
/***********************************
 
/***********************************
Zeile 37: Zeile 77:
 
   }
 
   }
 
}
 
}
 
/*** EDIT GADGETS ***/
 
if (wgAction=='edit'&&wgNamespaceNumber==500) {
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/bg/no.gif",
 
    "speedTip": "",
 
    "tagOpen": "",
 
    "tagClose": "",
 
    "sampleText": ""};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/wikibilder/ndash.jpg",
 
    "speedTip": "kurzer Bindestrich (n–dash)",
 
    "tagOpen": "–",
 
    "tagClose": "",
 
    "sampleText": ""};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/wikibilder/mdash.jpg",
 
    "speedTip": "Text zwischen langen Bindestrichen (m—dash)",
 
    "tagOpen": "— ",
 
    "tagClose": " — ",
 
    "sampleText": "Text"};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/wikibilder/hyphens1_dt.jpg",
 
    "speedTip": "dt. Anführungszeichen einfach",
 
    "tagOpen": "‚",
 
    "tagClose": "‘",
 
    "sampleText": ""};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/wikibilder/hyphens2_dt.jpg",
 
    "speedTip": "dt. Anführungszeichen doppelt",
 
    "tagOpen": "„",
 
    "tagClose": "“",
 
    "sampleText": ""};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/wikibilder/oo.jpg",
 
    "speedTip": "langes o, klein",
 
    "tagOpen": "ō",
 
    "tagClose": "",
 
    "sampleText": ""};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/wikibilder/oo_gr.jpg",
 
    "speedTip": "langes O, gross",
 
    "tagOpen": "Ō",
 
    "tagClose": "",
 
    "sampleText": ""};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/wikibilder/uu.jpg",
 
    "speedTip": "langes u, klein",
 
    "tagOpen": "ū",
 
    "tagClose": "",
 
    "sampleText": ""};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/wikibilder/uu_gr.jpg",
 
    "speedTip": "langes U, gross",
 
    "tagOpen": "Ū",
 
    "tagClose": "",
 
    "sampleText": ""};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/wikibilder/shy.jpg",
 
    "speedTip": "stummes Trennzeichen",
 
    "tagOpen": "·",
 
    "tagClose": "",
 
    "sampleText": ""};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/wikibilder/nbsp.jpg",
 
    "speedTip": "festes Leerzeichen (no breaking space)",
 
    "tagOpen": "&nbsp;",
 
    "tagClose": "",
 
    "sampleText": ""};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/bg/no.gif",
 
    "speedTip": "",
 
    "tagOpen": "",
 
    "tagClose": "",
 
    "sampleText": ""};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/wikibilder/ref.jpg",
 
    "speedTip": "Fussnoten",
 
    "tagOpen": "<ref>",
 
    "tagClose": "</ref>",
 
    "sampleText": "Text"};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/wikibilder/cat.jpg",
 
    "speedTip": "Kategorie",
 
    "tagOpen": "[[Kategorie:",
 
    "tagClose": "]]",
 
    "sampleText": " "};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/wikibilder/glo.jpg",
 
    "speedTip": "Glossar",
 
    "tagOpen": "{{glossar:",
 
    "tagClose": "}}",
 
    "sampleText": " "};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/wikibilder/skt.jpg",
 
    "speedTip": "Sanskrit",
 
    "tagOpen": "{{skt:",
 
    "tagClose": "}}",
 
    "sampleText": " "};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/wikibilder/shy.jpg",
 
    "speedTip": "TITEL",
 
    "tagOpen": "{{DISPLAYTITLE:",
 
    "tagClose": "\}\}<!--\n\n-->",
 
    "sampleText": " "};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/bg/nbsp.jpg",
 
    "speedTip": "First Letter",
 
    "tagOpen": "{{fl|",
 
    "tagClose": "}}",
 
    "sampleText": " "};
 
mwCustomEditButtons[mwCustomEditButtons.length] =
 
  {"imageFile": "/rel_jap/bg/no.gif",
 
    "speedTip": "",
 
    "tagOpen": "",
 
    "tagClose": "",
 
    "sampleText": ""};
 
 
importScript('mediawiki:edit.js');
 
}
 
 
  
 
/*****************
 
/*****************
Zeile 222: Zeile 141:
 
     Reference Tooltips
 
     Reference Tooltips
 
*****************/
 
*****************/
// See [[mw:Reference Tooltips]]
+
// See [[mw:Reference Tooltips]]; Anmerkungen mit Hover sichtbar machen
 
   
 
   
 
window.pg || $(document).ready( function($) {
 
window.pg || $(document).ready( function($) {

Version vom 10. Juli 2014, 14:15 Uhr

for (i in wgUserGroups)
 if (wgUserGroups[i] == 'sysop')
  var sysopRights = true; 

/***********************************
       Bildformular
***********************************/
if ( wgNamespaceNumber == 6 
  && wgPageName.toLowerCase().indexOf('.jpg')!= -1 
  && document.getElementById('wpTextbox1')
  && !document.getElementById('wpTextbox1').firstChild
  ) {
var d = new Date();
var datum = d.getFullYear()+"/"+(d.getMonth()+1)+"/"+d.getDate();
var p = "\n{{bild " +
 "\n|titel =  " +
 "\n|titel_j = " +
 "\n|titel_d =  " +
 "\n|detail = " +
 "\n|genre = " +
 "\n|genre2 = " +
 "\n|material = " +
 "\n|maße = " +
 "\n|artist= " +
 "\n|artist_dates = " +
 "\n|periode = " +
 "\n|jahr = " +
 "\n|serie = " +
 "\n|buch = " +
 "\n|serie_j = " +
 "\n|ort = " +
 "\n|treasure = " +
 "\n|q_link = " +
 "\n|q_text = " +
 "\n|quelle_b = " +
 "\n|quelle_d = " + datum +
 "\n|collection = " +
 "\n}}"+
 "<!--Beschreibung-->\n\n\n\n\n<noinclude>[["+"Kategorie:Bild]]</noinclude>";

document.getElementById('wpTextbox1').innerHTML = p;

}

/***********************************
       Stylesheet changes
***********************************/

document.write (
    '<style>' +
    ' #nv.fixed {}' + //newRules[0]
    ' .glossar2:hover small small {}' + //newRules[1]
    ' </style>'
    );   
var newCSS = document.styleSheets[document.styleSheets.length-1],
  newRules = newCSS.cssRules || newCSS.rules;  // für alle Browser ansprechbar

/***********************************
      IMPORT
***********************************/

for (i in wgCategories) {

/*** NAVIGATION ***/
  if (wgCategories[i]=='Artikel') 
    importScript('mediawiki:navigation.js') ;

//wenn css:styles...
  if (wgCategories[i]=='Styles') { 

/*** GLOSSAR ***/
    importScript('mediawiki:glossar.js');

/*** POPUPS ***/
    if (wgNamespaceNumber != 6)
      importScript('mediawiki:popup.js');
  }
}

/*****************
         Tagline
*****************/

function taglineLinks() {
 var t=document.getElementById('siteSub') || 0;
 if (t) {
  var url= window.location.pathname.split('/');
  var home = url[0]+'/'+url[1]+'/'+url[2]+'/';
  var tags = t.innerHTML.split('&gt;');
  var newT= aaa = ''; 
  for (i=0; i<tags.length; i++) {
   tags[i] = tags[i].replace(/^\s/, '').replace(/\s$/, '');
   home+= i==1 ? tags[i] :
    i==2 ? ':'+tags[i] : '';
   aaa = '<a href=" ' + home + ' ">' + tags[i] + '</a>';
   newT+= i == 0 ? aaa + ' &gt; ' :
     (wgNamespaceNumber > 99 && i < tags.length-1) ? aaa + ' &gt; ' :
       (i < tags.length-1) ? tags[i]  + ' &gt; ' : tags[i];
   }
  t.innerHTML=newT;
 }
}
taglineLinks();

/*****************
         Bildinfos (Bildseite)
*****************/

if (sysopRights && document.getElementById('filehistory')) {
  with (document.getElementById('filehistory')) {
    style.display = 'block';
    style.fontSize= '12px';
    style.color= '#aaa';
    style.textAlign= 'right';
    innerHTML += ' (klick)';
    onclick = showFilehistory;
  }
}
function showFilehistory() {
  var e = document.getElementById('mw-imagepage-section-filehistory').style; 
  e.display =  e.display == 'block' ? 'none' : 'block';
}

/*****************
         Zitieren
*****************/

var zZ = document.getElementById('zitieren') || 0;
  zZ.className = 'hide';
  document.getElementById('z_float').parentNode.onclick = highlightZ;
  document.getElementById('z_hide').onmouseout = highlightZ;

for (i in document.links) 
    if (document.links[i].href && document.links[i].href.indexOf('#zitieren') != -1)
      document.links[i].onclick = highlightZ;

function highlightZ() { zZ.className = (zZ.className == 'show') ? 'hide' : 'show'; }


/*****************
    Reference Tooltips
*****************/
// See [[mw:Reference Tooltips]]; Anmerkungen mit Hover sichtbar machen
 
window.pg || $(document).ready( function($) {
 
    // Make sure we are in article, project, or help namespace
    if ( wgCanonicalNamespace === '' || wgCanonicalNamespace === 'Project' || wgCanonicalNamespace === 'Help'|| wgCanonicalNamespace === 'Bauten'|| wgCanonicalNamespace === 'Alltag'|| wgCanonicalNamespace === 'Grundbegriffe'|| wgCanonicalNamespace === 'Mythen'|| wgCanonicalNamespace === 'Ikonographie'|| wgCanonicalNamespace === 'Geschichte'|| wgCanonicalNamespace === 'Texte' ) {
        function toggleRT(o){
            mw.loader.using("jquery.cookie",function(){
                    $.cookie("RTsettings",o+"|"+ settings[1] + "|" + settings[2], {path:"/",expires:90});
                    location.reload();
            })
        }
        var settings = document.cookie.split("RTsettings=")[1];
        settings = settings ? settings.split(";")[0].split("%7C") : [1, 200, +("ontouchstart" in document.documentElement)];
        if( settings[0] == 0 ) {
            var footer = $("#footer-places, #f-list");
            if( footer.length === 0 ) {
                    footer = $("#footer li").parent();
            }
            footer.append($("<li>").append($("<a>").text("Enable Reference Tooltips").attr("href","javascript:(function(){})()").click(function(){toggleRT(1)})));
            return;
        }
        var isTouchscreen = +settings[2],
            timerLength = isTouchscreen ? 0 : +settings[1],
            settingsMenu;
        $(".reference").each( function() {
            var tooltipNode, hideTimer, showTimer, checkFlip = false;
            function findRef( h ){
                    h = h.firstChild.getAttribute("href"); h = h && h.split("#"); h = h && h[1];
                    h = h && document.getElementById( h );
                    h = h && h.nodeName == "LI" && h;
                    return h;
            }
            function hide( refLink ){
                    if( tooltipNode && tooltipNode.parentNode == document.body ) {
                            hideTimer = setTimeout( function() {
                                    $(tooltipNode).animate({opacity: 0}, 100, function(){ document.body.removeChild( tooltipNode ) })
                            }, isTouchscreen ? 16 : 100)
                    } else {
                            var h = findRef( refLink );
                            h && (h.style.border = "");
                    }
            }
            function show(){
                    if( !tooltipNode.parentNode || tooltipNode.parentNode.nodeType === 11 ){
                            document.body.appendChild( tooltipNode );
                            checkFlip = true;
                    }
                    $(tooltipNode).stop().animate({opacity: 1}, 100)
                    clearTimeout( hideTimer );
            }
            function openSettingsMenu(){
                    if( settingsMenu ) {
                            settingsMenu.dialog( "open" );
                    } else {
                            settingsMenu = $("<form>").append(
                                    $("<button>").css("width","100%").text("Disable Reference Tooltips").button().click(function(){toggleRT(0)}),
                                    $("<br>"),
                                    $("<small>").text("Once disabled, Reference Tooltips can be re-enabled using a link in the footer of the page."),
                                    $("<hr>"),
                                    $("<label>").text("Delay before the tooltip appears (in milliseconds): ").append($("<input>").attr({"type":"number","value":settings[1],step:50,min:0,max:5000})),
                                    $("<br>"),
                                    $("<span>").text("Tooltip is activated by:"),
                                    $("<label>").append(
                                            $("<input>").attr({"type":"radio", "name":"RTActivate", "checked":settings[2]==0&&"checked", "disabled":"ontouchstart" in document.documentElement&&"disabled"}),
                                            "hovering"
                                    ),
                                    $("<label>").append(
                                            $("<input>").attr({"type":"radio", "name":"RTActivate", "checked":settings[2]==1&&"checked"}),
                                            "clicking"
                                    )
                            ).submit(function(e){e.preventDefault()}).dialog({modal:true,width:500,title:"Reference Tooltips options",buttons:{"Save settings":function(){
                                    var a = this.getElementsByTagName("input"),
                                            b = +a[0].value;
                                    $.cookie("RTsettings","1|"+ (b > -1 && b < 5001 ? b : settings[1]) + (a[1].checked ? "|0" : "|1"), {path:"/",expires:90});
                                    location.reload();
                            }}});
                    }
            }
            $(this)[ isTouchscreen ? 'click' : 'hover' ](function( e ){
                    var _this = this;
                    if( isTouchscreen ) {
                            e.preventDefault();
                            (tooltipNode && tooltipNode.parentNode == document.body) || setTimeout( function(){
                                    $( document.body ).on("click touchstart", function( e ) {
                                            e = e || event;
                                            e = e.target || e.srcElement;
                                            for( ; e && !$( e ).hasClass( "referencetooltip" ) ; )
                                                    e = e.parentNode;
                                            if( !e ){
                                                    clearTimeout( showTimer );
                                                    hide( _this );
                                                    $(document.body).off("click touchstart", arguments.callee)
                                            }
                                    })
                            }, 0);
                    }
                    showTimer && clearTimeout( showTimer );
                    showTimer = setTimeout( function() {
                            var h = findRef( _this );
                            if( !h ){return};
                            if( !isTouchscreen && ( window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0 ) + $(window).height() > $( h ).offset().top + h.offsetHeight ) {
                                    h.style.border = "#080086 2px solid";
                                    return;
                            }
                            if(!tooltipNode){
                                    tooltipNode = document.createElement("ul");
                                    tooltipNode.className = "referencetooltip";
                                    var c = tooltipNode.appendChild( h.cloneNode( true ) );
                                    try {
                                            if( c.firstChild.nodeName != "A" ) {
                                                    while( c.childNodes[1].nodeName == "A" && c.childNodes[1].getAttribute( "href" ).indexOf("#cite_ref-") !== -1 ) {
                                                            do { c.removeChild( c.childNodes[1] ) } while ( c.childNodes[1].nodeValue == " " );
                                                    }
                                            }
                                    } catch (e) { mw.log(e) }
                                    c.removeChild( c.firstChild );
                                    $( tooltipNode.firstChild.insertBefore( document.createElement( "span" ), tooltipNode.firstChild.firstChild ) ).addClass("RTsettings").attr("title", "Tooltip settings").click(function(){
                                            mw.loader.using(["jquery.cookie","jquery.ui.dialog"], openSettingsMenu);
                                    })
                                    tooltipNode.appendChild( document.createElement( "li" ) );
                                    isTouchscreen || $(tooltipNode).hover(show, hide);
                            }
                            show();
                            var o = $(_this).offset(), oH = tooltipNode.offsetHeight;
                            $(tooltipNode).css({top: o.top - oH, left: o.left - 7 });
                            if( tooltipNode.offsetHeight > oH ) { // is it squished against the right side of the page?
                                    $(tooltipNode).css({left:'auto',right:0});
                                    tooltipNode.lastChild.style.marginLeft = (o.left - tooltipNode.offsetLeft) + "px";
                            }
                            if( checkFlip ) {
                                    if( o.top < tooltipNode.offsetHeight + ( window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0 ) ) { // is part of it above the top of the screen?
                                            $(tooltipNode).addClass("RTflipped").css({top: o.top + 12});
                                    } else if( tooltipNode.className === "referencetooltip RTflipped" ) { // cancel previous
                                            $(tooltipNode).removeClass("RTflipped");
                                    }
                                    checkFlip = false;
                            }
                    }, timerLength);
            }, isTouchscreen ? undefined : function(){clearTimeout(showTimer); hide(this); } )
 
        } );
 
    }
 
} );