انتقل إلى المحتوى

ميدياويكي:Topiconfix.js

من ويكيبيديا، الموسوعة الحرة

ملاحظة: بعد الحفظ، قد يلزمك إفراغ الكاش لرؤية التغييرات.

/* Of [[:w:en:User:Splarka/topiconfix.js]] */

if((mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'view') && mw.config.get('wgNamespaceNumber') > -1) $(fixTopicon)
function fixTopicon() {
  if(!document.getElementById('siteNotice') && !window.siteNoticeValue && !window.wgNotice) return
  var h1 = getElementsByClassName(document,'h1','firstHeading');
  if(h1.length == 0) return
  h1 = h1[0];

  var coord = document.getElementById('coordinates');
  if(coord) {
    mw.util.addCSS('h1.firstHeading #coordinatesH1 {border: none;background: none;float: left;margin: 0.0em;padding: 0.0em;line-height: 1.5em;text-align: left;text-indent: 0;font-size: 45%;text-transform: none;white-space: nowrap;}')
    var nc = coord.cloneNode(true);
    coord.parentNode.removeChild(coord);
    nc.id = 'coordinatesH1';
    h1.appendChild(nc);
  }

  mw.util.addCSS('h1.firstHeading .topiconJS {float:left; display: block !important;margin-left:4px;}')
  var prot = document.getElementById('protected-icon');
  if(prot) {
    var np = prot.cloneNode(true);
    prot.parentNode.removeChild(prot);
    np.style.position = '';
    np.style.left = '';
    np.style.top = '';
    np.className += ' topiconJS';
    try { 
      h1.insertBefore(np,h1.firstChild);
    } catch (e) {
      h1.appendChild(np);
    }
  }

  var topi = getElementsByClassName(document,'*','topicon');
  for(var i=topi.length-1;i>=0;i--) {
    var nt = topi[i].cloneNode(true);
    topi[i].parentNode.removeChild(topi[i]);
    nt.className = nt.className.replace(/topicon/ig,'topiconJS');
    nt.style.left = '';
    try { 
      h1.insertBefore(nt,h1.firstChild);
    } catch (e) {
      h1.appendChild(nt);
    }
  }
}