Lompat ke isi

Pengguna:Py21/modern.js: Perbedaan antara revisi

Dari Wikipedia bahasa Indonesia, ensiklopedia bebas
Konten dihapus Konten ditambahkan
Tidak ada ringkasan suntingan
Tidak ada ringkasan suntingan
Baris 1: Baris 1:
/* Geser pranala "Sunting bagian: " mendekat ke samping judul bagian
/* Any JavaScript here will be loaded for users using the Modern skin */
* [[User:Drilnoth/lefteditlinks.js]]
*/
// font-size css definition for edit link span
if (typeof(leftEditLinkFontSize) == 'undefined') { var leftEditLinkFontSize = 'small'; }
// css definition for spacing after heading text span
addOnloadHook( function() {
if (typeof(leftEditLinkSpacing) == 'undefined') { var leftEditLinkSpacing = '0.2em'; }
var tooltipsToFix = ['p-cactions', 'mw_portlets', 'p-personal'];
for (i=0; i < tooltipsToFix.length; i++) {
var block = document.getElementById(tooltipsToFix[i]);
if (block)
updateTooltipAccessKeys(block.getElementsByTagName('a'))
}
});
// Compatibility function to run scripts only tested on Monobook.
// main program
// Required for using Twinkle or Friendly (along with many other scripts).
var LeftEditLinkMain = function() {
document._realGEBI = document.getElementById;
document.getElementById = function(id){
// recursively fix all spans inside headings
var x = this._realGEBI(id);
var content = document.getElementById('mw_content');
if(x) return x;
var LeftEditLink = function(level) {
else {
// try to find a reasonable equivalent for monobook-specific element ids
// get all heading of this level
switch(id) {
case "content": return this._realGEBI("mw_content");
var headings = content.getElementsByTagName('h' + level);
for (var i = 0; i < headings.length; i ++) {
case "column-content": return this._realGEBI("mw_contentwrapper");
case "bodyContent": return this._realGEBI("mw_contentholder");
var heading = headings[i];
case "column-one": return this._realGEBI("mw_portlets");
// get edit span
case "globalWrapper": return this._realGEBI("mw_main");
default: return null;
var editSpan = heading.firstChild;
if (editSpan == null) { continue }
if (editSpan.className != 'editsection') { continue }
// get blank
var blank = editSpan.nextSibling;
if (blank == null) { continue }
if (blank.nodeValue != ' ') { continue }
// get heading span
var headingSpan = blank.nextSibling;
if (headingSpan == null) { continue }
if (headingSpan.nodeName != 'SPAN') { continue }
// move blank after heading text
heading.appendChild(blank);
// move edit span after blank
heading.appendChild(editSpan);
// get rid of evil edit span floating
editSpan.style.styleFloat = 'none';
editSpan.style.cssFloat = 'none';
// set edit span font size
editSpan.style.fontSize = leftEditLinkFontSize;
// set heading span right margin
headingSpan.style.marginRight = leftEditLinkSpacing;
}
}
}
// recurse through heading levels
if (level < 6) {
LeftEditLink(level + 1);
}
return;
};
// call recursive function
LeftEditLink(1);
};
$(LeftEditLinkMain);

Revisi per 23 Juni 2012 03.52

/* Geser pranala "Sunting bagian: " mendekat ke samping judul bagian
 * [[User:Drilnoth/lefteditlinks.js]]
*/
// font-size css definition for edit link span
if (typeof(leftEditLinkFontSize) == 'undefined') { var leftEditLinkFontSize = 'small'; }
 
// css definition for spacing after heading text span
if (typeof(leftEditLinkSpacing) == 'undefined') { var leftEditLinkSpacing = '0.2em'; }
 
 
// main program
var LeftEditLinkMain = function() {
 
// recursively fix all spans inside headings
    var content = document.getElementById('mw_content');
    var LeftEditLink = function(level) {
 
// get all heading of this level
        var headings = content.getElementsByTagName('h' + level);
        for (var i = 0; i < headings.length; i ++) {
            var heading = headings[i];
 
// get edit span
            var editSpan = heading.firstChild;
            if (editSpan == null) { continue }
            if (editSpan.className != 'editsection') { continue }
 
// get blank
            var blank = editSpan.nextSibling;
            if (blank == null) { continue }
            if (blank.nodeValue != ' ') { continue }
 
// get heading span
            var headingSpan = blank.nextSibling;
            if (headingSpan == null) { continue }
            if (headingSpan.nodeName != 'SPAN') { continue }
 
// move blank after heading text
            heading.appendChild(blank);
 
// move edit span after blank
            heading.appendChild(editSpan);
 
// get rid of evil edit span floating
            editSpan.style.styleFloat = 'none';
            editSpan.style.cssFloat = 'none';
 
// set edit span font size
            editSpan.style.fontSize = leftEditLinkFontSize;
 
// set heading span right margin
            headingSpan.style.marginRight = leftEditLinkSpacing;
        }
 
// recurse through heading levels
        if (level < 6) {
            LeftEditLink(level + 1);
        }
        return;
    };
 
// call recursive function
    LeftEditLink(1);
 
};
 
$(LeftEditLinkMain);