MediaWiki:Gadget-edittop.js: Difference between revisions

From Sarkarverse
Jump to navigation Jump to search
m (1 revision)
m (Let's try a different version of this)
Line 5: Line 5:
// **                                                                  **
// **                                                                  **
// **********************************************************************
// **********************************************************************
// Imported from [[User:Alex Smotrov/edittop.js]], version as of: 2007-06-19T04:28:52
// Imported from [[User:Alex Smotrov/edittop.js]], version as of: 2008-10-06T04:28:52
// Updated from [[User:TheDJ/Gadget-edittop.js]], version as of: 2009-04-28T11:54:22


if ($.inArray( mw.config.get('wgAction'), [ 'view', 'purge' ]) !== -1 && mw.config.get( 'wgNamespaceNumber' ) >=0) {
if ((wgAction == 'view' || wgAction == 'purge') && wgNamespaceNumber >=0)
  $(function edittop_hook () {
addOnloadHook(function edittop_hook(){
    var localtitles = {
var h2s = document.getElementsByTagName('H2');
      cs: 'Editovat úvodní sekci',
var h2 = h2s[0];
      en: 'Edit lead section',
if (!h2) return;
      fa: 'ویرایش بخش آغازین',
if (h2.parentNode.id == 'toctitle') h2 = h2s[1];
      fr: 'Modifier le résumé introductif',
if (!h2) return;
      id: 'Sunting bagian atas',
var span = h2.firstChild;
      it: 'Modifica della sezione iniziale',
if (!span || span.className != 'editsection') return;
      ja: '導入部を編集',
var zero = span.cloneNode(true);
      min: 'Suntiang bagian ateh',
if (document.getElementById('featured-star')) zero.style.marginRight = '25px';
      ko: '도입부를 편집',
if (document.getElementById('spoken-icon')) zero.style.marginRight = '45px';
      pa: 'ਸੋਧ',
if (document.getElementById('protected-icon') && zero.style.marginRight) zero.style.marginRight = '70px';
      pt: 'Editar a seção superior',
var parent = document.getElementsByTagName('H1')[0];
      'pt-br': 'Editar a seção superior',
parent.insertBefore(zero, parent.firstChild);
      sr: 'Уреди уводни део',
var a = zero.getElementsByTagName('A')[0];
      vi: 'Sửa phần mở đầu'
if (a.href.indexOf('&section=T') == -1){
    };
  a.title = a.title.replace(/:.*$/,': 0')
 
  a.setAttribute('href', a.href.replace(/&section=\d+/,'&section=0'));
    var our_content = $("#content, #mw_content").first();
}else{//transcluded
    var span1 = our_content.find("span.mw-editsection:not(.plainlinks)").first();
  a.title = 'Edit section: 0'
    if (!span1.length) {
  a.setAttribute('href', wgScript+'?title='+encodeURIComponent(wgPageName)+'&action=edit&section=0')
      return;
}
    }
})
    var span0 = span1.clone();
 
    if ( mw.user.options.get( 'gadget-righteditlinks' ) == 1 ) {
      var editwidth = span1.outerWidth() + (mw.config.get("skin") == "monobook" ? 10 : 0);
      $("div.topicon, #mw-fr-revisiontag").css("margin-right", editwidth + "px");
    }
    $("#mw_header h1, #content h1").first().append(span0);
    span0.find("a").each(function (idx) {
      var a = $(this);
      a.attr("title", localtitles[mw.config.get( 'wgUserLanguage' )] || localtitles.en);
      if (a.attr("href").indexOf("&section=T") == -1) {
        a.attr("href", a.attr("href").replace(/&section=\d+/, "&section=0"));
      }
      else { //transcluded
        a.attr("href", mw.util.wikiGetlink( mw.config.get( 'wgPageName' ) ) + "?action=edit&section=0");
      }
    });
  });
}

Revision as of 23:29, 31 October 2013

// **********************************************************************
// **                 ***WARNING GLOBAL GADGET FILE***                 **
// **             changes to this file affect many users.              **
// **           please discuss on the talk page before editing         **
// **                                                                  **
// **********************************************************************
// Imported from [[User:Alex Smotrov/edittop.js]], version as of: 2008-10-06T04:28:52

if ((wgAction == 'view' || wgAction == 'purge') && wgNamespaceNumber >=0)
addOnloadHook(function edittop_hook(){
 var h2s = document.getElementsByTagName('H2');
 var h2 = h2s[0];
 if (!h2) return;
 if (h2.parentNode.id == 'toctitle') h2 = h2s[1];
 if (!h2) return;
 var span = h2.firstChild;
 if (!span || span.className != 'editsection') return;
 var zero = span.cloneNode(true);
 if (document.getElementById('featured-star')) zero.style.marginRight = '25px';
 if (document.getElementById('spoken-icon')) zero.style.marginRight = '45px';
 if (document.getElementById('protected-icon') && zero.style.marginRight) zero.style.marginRight = '70px';
 var parent = document.getElementsByTagName('H1')[0];
 parent.insertBefore(zero, parent.firstChild);
 var a = zero.getElementsByTagName('A')[0];
 if (a.href.indexOf('&section=T') == -1){
   a.title = a.title.replace(/:.*$/,': 0')
   a.setAttribute('href', a.href.replace(/&section=\d+/,'&section=0'));
 }else{//transcluded
   a.title = 'Edit section: 0'
   a.setAttribute('href', wgScript+'?title='+encodeURIComponent(wgPageName)+'&action=edit&section=0')
 }
})