MediaWiki:Common.js

De Vitalinux
Saltar a: navegación, buscar

Nota: tras guardar, quizás necesites actualizar la caché de tu navegador para ver los cambios.

  • Firefox/Safari: Mantén presionada la tecla Mayús mientras pulsas el botón Actualizar, o presiona Ctrl+F5 o Ctrl+R (⌘+R en Mac)
  • Google Chrome: presiona Ctrl+Shift+R (⌘+Mayús+R en Mac)
  • Internet Explorer: mantén presionada Ctrl mientras pulsas Actualizar, o presiona Ctrl+F5
  • Opera: dirígete a Menú → Configuración (Opera → Preferencias en Mac) y luego a Privacidad y seguridad → Borrar datos de navegación → Imágenes y archivos en caché.
/* Tablas que se colapsan */
/**
 * Collapsible tables
 *
 * @version 2.0.2 (2014-03-14)
 * @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
 * @author [[User:R. Koot]]
 * @author [[User:Krinkle]]
 * @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
 * is supported in MediaWiki core.
 */
/*global $, mw */
var autoCollapse = 2;
var collapseCaption = '▲';
var expandCaption = '▼';
 
function collapseTable( tableIndex ) {
	var Button = document.getElementById( 'collapseButton' + tableIndex );
	var Table = document.getElementById( 'collapsibleTable' + tableIndex );
 
	if ( !Table || !Button ) {
		return false;
	}
 
	var Rows = Table.rows;
	var i;
 
	if ( Button.firstChild.data === collapseCaption ) {
		for ( i = 1; i < Rows.length; i++ ) {
			Rows[i].style.display = 'none';
		}
		Button.firstChild.data = expandCaption;
	} else {
		for ( i = 1; i < Rows.length; i++ ) {
			Rows[i].style.display = Rows[0].style.display;
		}
		Button.firstChild.data = collapseCaption;
	}
}
 
function createClickHandler( tableIndex ) {
	return function ( e ) {
		e.preventDefault();
		collapseTable( tableIndex );
	};
}
 
function createCollapseButtons() {
	var tableIndex = 0;
	var NavigationBoxes = {};
	var Tables = document.getElementsByTagName( 'table' );
	var i;
 
	for ( i = 0; i < Tables.length; i++ ) {
		if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {
			/* only add button and increment count if there is a header row to work with */
			var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
			if ( !HeaderRow ) {
				continue;
			}
			var Header = HeaderRow.getElementsByTagName( 'th' )[0];
			if ( !Header ) {
				continue;
			}
 
			NavigationBoxes[tableIndex] = Tables[i];
			Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex );
 
			var Button = document.createElement( 'span' );
			var ButtonLink = document.createElement( 'a' );
			var ButtonText = document.createTextNode( collapseCaption );
 			// TODO: Declare styles in [[MediaWiki:Gadget-collapsibleTables.css]]
			// Button.className = 'collapseButton';
			Button.style.styleFloat = 'right';
			Button.style.cssFloat = 'right';
			Button.style.fontWeight = 'normal';
			Button.style.textAlign = 'right';
			Button.style.width = '6em';
 
			ButtonLink.style.color = Header.style.color;
			ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
			ButtonLink.setAttribute( 'href', '#' );
			$( ButtonLink ).on( 'click', createClickHandler( tableIndex ) );
			ButtonLink.appendChild( ButtonText );
 
			Button.appendChild( document.createTextNode( '[' ) );
			Button.appendChild( ButtonLink );
			Button.appendChild( document.createTextNode( ']' ) );
 
			Header.insertBefore( Button, Header.firstChild );
			tableIndex++;
		}
	}
 
	for ( i = 0; i < tableIndex; i++ ) {
		if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) ||
			( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) )
		) {
			collapseTable( i );
		}
	}
}
 
mw.hook( 'wikipage.content' ).add( createCollapseButtons );




/* Eliminar cabecera y otros objetos cuando se ve la página desde un iframe */
$(function() {
  var g;
  /* hide some navigation and other unnecessary elements if displayed in an iFrame */
  if (window.self != window.top) {
    var content = document.getElementById('content');
    if (content) {
      content.style.margin = 0;
      content.style.borderStyle = 'none';
    }
    var reva = /(\d+:\d+, \d+ \w+ \d+)/.exec($('#mw-revision-info').text());
    var revinfo = reva ? reva[0] : '';
    reva = /oldid=(\d+)/.exec($('#mw-revision-nav').find('a').attr('href'));
    var oldid = reva ? reva[1] : '';
    var removals = ['mw-page-base', 'mw-head-base', 'mw-navigation', 'mw-head', 'mw-panel', 'column-one', 'siteNotice', 'contentSub', 'siteSub', 'catlinks', 'page-base', 'head-base', 'head', 'panel', 'firstHeading', 'p-cactions', 'footer-info-lastmod', 'footer-info-viewcount', 'footer-places', 'footer-icons', 'footer-icon-poweredby', 'f-poweredbyico', 'lastmod', 'viewcount', 'privacy', 'about', 'disclaimer', 'notiframe'];
    for (var i=0; i<removals.length; i++) {
      g = document.getElementById(removals[i]);
      if (g) {
        g.style.display = 'none';
      }
    }
    $('.editsection,.mw-editsection').css('visibility', 'hidden');
    $('#content, #footer').css('background-image', 'none');
    document.body.style.background='none';
    $('.iframeonly').removeClass('iframeonly');
    var q = {};
    var qs = document.location.search;
    qs = qs.substring(1).toLowerCase().split('&');
    for (i=0; i<qs.length; i++) {
      g = qs[i].split('=');
      q[g[0]] = (g.length === 1) ? true : g[1];
    }
    if (q.nonav) {
      var divs = document.getElementsByTagName('div');
      for (i=0; i<divs.length; i++) {
        if (divs[i].className.match(/navigation/i)) {
          divs[i].style.display = 'none';
        }
      }
    }
    g = document.getElementById('footer');
    if (g) {
      g.style.marginLeft = 0;
      /* g.style.position = 'absolute';
      g.style.bottom = 0;
      g.style.width = "98%"; */
    }
    var foot = document.getElementById('f-list') || document.getElementById('footer-info');
    if (foot) {
      var li = document.createElement('li');
      var wgServer = window.self.location.origin + '/';
      g = wgServer + 'index.php/' + wgPageName;
      var footerfrom;
      if (revinfo) {
        footerfrom = 'Revisión ' + revinfo + ' obtenida de <a href="' + g + '?oldid=' + oldid;
      } else {
        footerfrom = 'Obtenida de <a href="' + g;
      }
      li.innerHTML = footerfrom + '">' + g + '</a>';
      li.style.display = 'block';
      foot.insertBefore(li, document.getElementById('copyright') || document.getElementById('footer-info-copyright'));
    }
    if ((wgCanonicalNamespace == 'Special') && (wgCanonicalSpecialPageName == 'Userlogin')) {
      $('#footer-icon-copyright').hide();
    }
    if (q.links) {
      var largs = q.links.split('|');
      for (var j=0; j<largs.length; j++) {
        q[largs[j]] = true;
      }
      var hilight = q.highlight ? ' background: yellow;' : '';
      var hover = q.hover ? ' background: yellow;' : '';
      if (q.none || q.highlight || q.hover) {
        WEAddStyles('a.link {text-decoration: none; padding: 0px; background: none; ' + hilight + '} a.visited {text-decoration: none;' + hilight +'} a:active {text-decoration: none;' + hilight + '} a:hover {text-decoration: none;' + hilight + hover + '}');
      }
      var as = document.getElementsByTagName('a');
      for (j=0; j<as.length; j++) {
        var href = as[j].getAttribute('href');
        if (href) {
          if (q.none || q.show || q.hover || q.highlight) {
            as[j].setAttribute('onclick', 'return false;');
          }
          if (q.window) {
            as[j].setAttribute('target', '_VL');
          }
        }
      }
    }
    if (q.editable) {
      $('.editsection,.mw-editsection').css('visibility', 'visible');
    }
    if (q.noheading) {
      $('#firstHeading').css('display', 'none');
    }
    // if postMessage is supported, try to let the parent know our size
    if (parent.postMessage) {
      var ht = content.offsetHeight;
      var ftr = document.getElementById('footer');
      if (ftr) { ht = ht + ftr.offsetHeight; }
      var loc = document.location.href;
      parent.postMessage('height^' + ht + '^' + loc, "*");
    }
  }
});