MediaWiki:Common.js: Difference between revisions

From Wikizilla, the kaiju encyclopedia
Jump to navigationJump to search
No edit summary
(ok the new editor now has everything + a tabber)
Line 671: Line 671:
id: "mw-customeditbutton-infoboxtabberbutton",
id: "mw-customeditbutton-infoboxtabberbutton",
icon: "//vignette1.wikia.nocookie.net/wikizilla-files/images/0/08/Editor_Button_-_Tabber.png",
icon: "//vignette1.wikia.nocookie.net/wikizilla-files/images/0/08/Editor_Button_-_Tabber.png",
label: 'Video game infobox',
label: 'Tabber',
insertBefore: '<tabs style="color:black; padding: 0px; margin: 0px;">\r<tab name="NAMEHERE">[[File:|300px| in ]]</tab>\r',
insertBefore: '<tabs style="color:black; padding: 0px; margin: 0px;">\r<tab name="NAMEHERE">[[File:|300px| in ]]</tab>\r',
insertAfter: '\r<tab name="NAMEHERE2">[[File:|300px| in ]]</tab>\r</tabs>',
insertAfter: '\r<tab name="NAMEHERE2">[[File:|300px| in ]]</tab>\r</tabs>',

Revision as of 05:30, 7 May 2017

/*Nota, el contenido del Common.js se encuentra en [[MediaWiki:Common.js/Code.js]], y se importa desde MediaWiki:(skinname).js/Code.js <pre>*/
 
function loadTrueCommonJS() {
	// Hash para evitar que puedan usar URLs que afecten a cómo se ve la página
	var jsHashKey = window.wgStyleVersion;
	var reloadjs = false;
	var debug = false;
	var skipCommon = false;
	var skipSkinjs = false;
	var curLocation = window.location.href;
	if (curLocation.indexOf('jsHashKey='+jsHashKey) != -1) {
		reloadjs = (curLocation.indexOf('reloadjs=true') != -1);
		debug = (curLocation.indexOf('debug=true') != -1);
		skipCommon = (curLocation.indexOf('skipCommon=true') != -1);
		skipSkinjs = (curLocation.indexOf('skipSkinjs=true') != -1);
	}
	if (reloadjs) {
		var d = new Date();
		window.importScriptURI = function(oldImportScriptURI, ts) {
				return function(url) {
					return oldImportScriptURI(url+(url.indexOf('?') != -1 ? '&' : '?')+ts);
				}
			}(window.importScriptURI, d.getTime());
	}
	if (!skipCommon) {
		var page = 'Common.js';
		switch(window.skin) {
			case 'monobook':
				page = 'Monobook.js';
				break;
			case 'vector':
				page = 'Vector.js';
				break;
		}
		var code = (debug ? 'Debug' : 'Code');
		importScriptURI(wgServer+wgScriptPath+wgScript+'?title=MediaWiki:'+page+'/'+code+'.js&action=raw&ctype=text/javascript&templates=expand&t=4');
	}
	if (skipSkinjs) {
		throw 'skipSkinjs especificado. Aborting...';
	}
}
 
loadTrueCommonJS();
/*</pre>*/
/* Any JavaScript here will be loaded for all users on every page load. */
/* <pre> v238 */

/* Control de errores */
function trataError(e) {
	setTimeout(function(err) {
		return function() {
			throw err;
		};
	}(e), 10);
}

/* Esta función evita que se detenga la carga de otros scripts en el onload si uno de ellos falla*/
function safeOnLoadHook(fn) {
	if ($) {
		$(function() {
			try {
				fn();
			} catch(e) {
				typeof(window.trataError)=='function'&&trataError(e);
			}
		});
	}
}

//// Intento de mejora de LinkSuggest. Modificado por [[User:Ciencia Al Poder]]
function improveLinkSuggest(){
	if (!window.YAHOO || !YAHOO.example || !YAHOO.example.AutoCompleteTextArea) return;
	YAHOO.example.AutoCompleteTextArea.prototype._sendQuery = function(sQuery) {
		var text = this._elTextbox.value.replace(/\r/g, "");
		var caret = this.getCaret(this._elTextbox);
		var sQueryStartAt;
		var closedTemplateFound = false;
		var closedLinkFound = false;

		// also look forward, to see if we closed this one
		for(var i = caret; i < text.length; i++) {
			var c = text.charAt (i) ;
			// Characters that are invalid inside a link. It makes no sense to continue forward to see if it's closed.
			if (c == "\n" || c == "[" || c == "{"){
				break;
			}/*
			if((c == "[") && (text.charAt(i - 1) == "[")) {
				break ;
			}
			if((c == "{") && (text.charAt(i - 1) == "{")) {
				break ;
			}*/
			if((c == "]") && (text.charAt(i - 1) == "]")) {
				// An opened template inside a closed link won't work if we return here. We'll need to check later if it's a template or a link
				//return ;
				closedLinkFound = true;
				break;
			}
			if((c == "}") && (text.charAt(i - 1) == "}")) {
				// An opened link inside a closed template won't work if we return here. We'll need to check later if it's a template or a link
				//return ;
				closedTemplateFound = true;
				break;
			}
		}

		for(var i = caret; i >= 0; i--) {
			var c = text.charAt(i);
			if(c == "]" || c == "|") {
				if ( (c == "|") || ( (c == "]") && (text.charAt(i-1) == "]") ) ) {
					this._toggleContainer(false) ;
				}
				return;
			}
			if(c == "}" || c == "|") {
				if ( (c == "|") || ( (c == "}") && (text.charAt(i-1) == "}") ) ) {
					this._toggleContainer(false) ;
				}
				return;
			}
			if((c == "[") && (text.charAt(i - 1) == "[")) {
				if (closedLinkFound){
					this._toggleContainer(false) ;
					return;
				}
				this._originalQuery = text.substr(i + 1, (caret - i - 1));
				sQueryReal = this._originalQuery
				if (this._originalQuery.indexOf(':')==0){
					this._bIsColon = true;
					sQueryReal = sQueryReal.replace(':','');
				} else {
					this._bIsColon = false;
				}
				this._bIsTemplate = false;
				sQueryStartAt = i;
				break;
			}
			if((c == "{") && (text.charAt(i - 1) == "{")) {
				if (closedTemplateFound){
					this._toggleContainer(false) ;
					return;
				}
				this._originalQuery = text.substr(i + 1, (caret - i - 1));
				this._bIsColon = false;
				if (this._originalQuery.length >= 6 && this._originalQuery.toLowerCase().indexOf('subst:') == 0){
					sQueryReal = "Template:"+this._originalQuery.replace(/subst:/i,'');
					this._bIsSubstTemplate = true;
				} else if (this._originalQuery.indexOf(':')==0){
					sQueryReal = this._originalQuery.replace(':','');
					this._bIsColon = true;
				} else {
					sQueryReal = "Template:"+this._originalQuery;
					this._bIsSubstTemplate = false;
				}
				this._bIsTemplate = true;
				sQueryStartAt = i;
				break;
			}
		}

		if(sQueryStartAt >= 0 && sQueryReal.length > 2) {
			YAHOO.example.AutoCompleteTextArea.superclass._sendQuery.call(this, encodeURI(sQueryReal.replace(/\x20/g,'_')));
		}
	};
}

(typeof(window.safeOnLoadHook)=='function'?safeOnLoadHook:$)(improveLinkSuggest);

/* === Sortable corregido/mejorado para ordenar imágenes === */
// Buscar celdas con imagen o ref (limitado a primer elemento hijo, por rendimiento) y agrega un data-sort-value ignorando el ref y traduciendo correctamente la imagen
var tablesorter_fixImagenesRefs = function() {
	var cache = [], text, $node, cn, ee, cambios = false, i, j;
	for ( i = 1; i < this.rows.length; i++ ) {
		cache[i] = [];
		for ( j = 0; j < this.rows[i].cells.length; j++ ) {
			if ( $( '> a.image,> sup.reference', this.rows[i].cells[j] ).length ) {
				if ( this.rows[i].cells[j].getAttribute( 'data-sort-value' ) ) {
					// Skip existing
					continue;
				}
				text = '';
				cn = this.rows[i].cells[j].childNodes;
				for ( ee = 0; ee < cn.length; ee++ ) {
					if ( cn[ee].nodeType == 3 ) {
						text += cn[ee].data;
					} else {
						$node = $( cn[ee] );
						if ( $node.is( 'a.image' ) ) {
							text += cn[ee].title;
						} else if ( ! $node.is( 'sup.reference' ) ) { // Nos saltamos los <ref>
							text += $node.text();
						}
					}
				}
				cache[i][j] = $.trim( text );
				cambios = cambios || ( cache[i][j] && true );
			}
		}
	}
	if ( !cambios ) {
		return;
	}
	for ( i = 1; i < this.rows.length; i++ ) {
		for ( j = 0; j < this.rows[i].cells.length; j++ ) {
			if ( cache[i][j] ) {
				this.rows[i].cells[j].setAttribute( 'data-sort-value', cache[i][j] );
			}
		}
	}
};

(typeof(window.safeOnLoadHook)=='function'?safeOnLoadHook:$)( function() {
	$( 'table.sortable', '#mw-content-text' ).each( function() {
		// Attach del evento en mousedown porque se ejecutará antes que el click del tablesorter
		// Una vez se ejecute el click, se guarda en caché los valores de columna, por lo que modificar el DOM después no funcionará
		$(this).find( 'th' ).on( 'mousedown.fixpending_sortimgref', function() {
			// Retiramos el evento para que no se vuelva a ejecutar
			var ts = $(this).closest( 'table.sortable' );
			ts.find( 'th' ).off( 'mousedown.fixpending_sortimgref' );
			tablesorter_fixImagenesRefs.call(ts[0]);
		} );
	} );
} );
/* == Herramientas de edición == */

// Datos para scripts que se cargan de forma asíncrona:
var postloadFunctionData = {
	'tablemanager': [],
	'charinsert': {
		"MediaWiki": [ '\x7E\x7E\x7E\x7E', ['\x7B{','}}'], ['[[',']]'], ['[[Categoría:',']]'], ['#REDIRECCIÓN [[',']]'], ['<ref>','</ref>'], '<references />', ['<includeonly>','</includeonly>'], ['<noinclude>','</noinclude>'], ['<nowiki>','</nowiki>'], ['\x3Cgallery widths="190px">\n','\n</gallery>'], ['<code>','</code>'], '\x7B{PAGENAME}}', ['\x7B{t|','}}'], ['\x7B{S|','}}'] ],
		"Japonés - Katakana": ['ア','ァ','イ','ィ','ウ','ヴ','ゥ','エ','ェ','オ','ォ','カ','ガ','キ','ギ','ク','グ','ケ','ゲ','コ','ゴ','サ','ザ','シ','ジ','ス','ズ','セ','ゼ','ソ','ゾ','タ','ダ','チ','ヂ','ツ','ヅ','ッ','テ','デ','ト','ド','ナ','ニ','ヌ','ネ','ノ','ハ','バ','パ','ヒ','ビ','ピ','フ','ブ','プ','ヘ','ベ','ペ','ホ','ボ','ポ','マ','ミ','ム','メ','モ','ヤ','ャ','ユ','ュ','ヨ','ョ','ラ','リ','ル','レ','ロ','ワ','ヷ','ヰ','ヸ','ヱ','ヹ','ヲ','ヺ','ン','、','。',['「','」'],['『','』'],'ゝ','ゞ','々','ヽ','ヾ'],
		"Japonés - R\u014Dmaji": ['Ā','ā','Ē','ē','Ī','ī','Ō','ō','Ū','ū'],
		"Alfabeto fonético": ['ɨ','ʉ','ɯ','ɪ','ʏ','ʊ','ø','ɘ','ɵ','ɤ','ə','ɛ','œ','ɜ','ɞ','ʌ','ɔ','æ','ɐ','ɶ','ɑ','ɒ','ɚ','ɝ','ʰ','ʱ','ʲ','ʴ','ʷ','˞','ˠ','ˤ','ʼ','ˈ','ˌ','ː','ˑ','.','ʈ','ɖ','ɟ','ɢ','ʔ','ɱ','ɳ','ɲ','ŋ','ɴ','ʙ','ʀ','ɾ','ɽ','ɸ','β','θ','ð','ʃ','ʒ','ʂ','ʐ','ʝ','ɣ','χ','ʁ','ħ','ʕ','ɦ','ɬ','ɮ','ʋ','ɹ','ɻ','ɰ','ɭ','ʎ','ʟ','ʍ','ɥ','ʜ','ʢ','ʡ','ɕ','ʑ','ɺ','ɧ','ɡ','ɫ'],
		"Plantillas de licencias": [['\x7B{Art Oficial|','}}'], '\x7B{CC-BY}}', '\x7B{CC-BY}}', '\x7B{CC-SA}}', '\x7B{CC-BY-SA}}', '\x7B{Carátula}}', '\x7B{Fair use}}', ['\x7B{Fanart|','}}'], '\x7B{GFDL}}', '\x7B{Imagen de Sugimori}}', '\x7B{Imagen de commons}}', '\x7B{LAL}}', '\x7B{PD}}', '\x7B{Pokémon sprite}}', '\x7B{Scan}}', '\x7B{ScreenshotJuego}}', '\x7B{ScreenshotTV}}'],
	}
};

function loadEditJS(){
	if (mw.config.get('wgAction', '') == 'edit' || mw.config.get('wgAction', '') == 'submit' ||
		mw.config.get('wgCanonicalSpecialPageName', '') == 'Upload' ||
		mw.config.get('wgCanonicalSpecialPageName', '') == 'MultipleUpload') {
		importScript('MediaWiki:Common.js/Clases/CharInsert-min.js');
		if (window.location.toString().indexOf('undo=') == -1 && window.location.toString().indexOf('undoafter=') == -1) {
			if (mw.config.get('wgNamespaceNumber', 0) == 0) {
				mw.loader.using(['jquery.ui.dialog', 'mediawiki.api'], function() {
					if (typeof(window.fixBugMixedUIversionsDialog)=='function') { fixBugMixedUIversionsDialog(); }
					importScript('MediaWiki:Common.js/Clases/AvisoCuriosidades.js');
				});
			}
			if (mw.config.get('wgNamespaceNumber', 0) == 2 && window.location.toString().indexOf('action=edit') != -1) {
				mw.loader.using(['jquery.ui.dialog', 'mediawiki.api'], function() {
					if (typeof(window.fixBugMixedUIversionsDialog)=='function') { fixBugMixedUIversionsDialog(); }
					importScript('MediaWiki:Common.js/Clases/DisableFirstSubmit.js');
				});
			}
		}
	}
}

(typeof(window.safeOnLoadHook)=='function'?safeOnLoadHook:$)(loadEditJS);

/* == Acopla tablas ==
Para unir las filas en una sola tabla. [[MediaWiki:Mergetables.js]]
*/
function acopla_tablas(){
	switch(mw.config.get('wgPageName')){
		case 'Lista_de_Pokémon':
		case 'Lista_de_movimientos':
			importScript('MediaWiki:Common.js/Clases/MergeTables.js');
			break;
	}
}

(typeof(window.safeOnLoadHook)=='function'?safeOnLoadHook:$)(acopla_tablas);

/*
* LazyLoadVideo - Muestra un botón para activar (mostrar) el reproductor de vídeos, para que no se carguen desde el inicio
* Copyright (C) 2012 - 2015 Jesús Martínez Novo ([[User:Ciencia Al Poder]])
* 
* This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation; either version 2 of the License, or
*   (at your option) any later version
*/
(function($) {

var _title = (window.lazyloadvideotitle || 'Clic para activar el vídeo'),
_thumbUrl = 'http://i1.ytimg.com/vi/{0}/hqdefault.jpg',
_init = function() {
	// OBSOLETO
	$('#'+window.bodyContentId).find('div.video > .thumbinner > .youtube > object, div.video > .youtube > object').each(_muestraThumbInObject);
	// NUEVO
	$('#'+window.bodyContentId).find('div.video > .youtube').each(_muestraThumb);
},
// OBSOLETO - Agrega una imagen del vídeo en la posición del vídeo
_muestraThumbInObject = function() {
	var oVideo = $(this), dataUrl = oVideo.find('> param[name="movie"]').attr('value'), vid = null, idx = dataUrl.indexOf('&'), w, h;
	if (idx != -1) {
		dataUrl = dataUrl.substr(0, idx);
		idx = dataUrl.lastIndexOf('/');
		if (idx != -1) {
			vid = dataUrl.substr(idx + 1);
		}
	}
	// Se comprueba que esté oculto, para sincronizar con CSS
	if (vid !== null && oVideo.css('display') == 'none') {
		w = oVideo.attr('width');
		h = oVideo.attr('height');
		oVideo.parent().append(
			$(document.createElement('img')).attr('src', _thumbUrl.replace('{0}', vid)).attr({width: w, height: h}).addClass('videothumb')).append(
			$('<div class="videodiscoveryoverlay"></div>').css({width: w.concat('px'), height: h.concat('px')}).attr('title', _title).bind('click', _discoverVideo));
	}
},
// OBSOLETO - Evento al hacer clic en el overlay
_discoverVideo = function() {
	var p = $(this).parent(), oVideo = p.find('> object'), mparam;
	// En Safari ya versión 2 ya no funciona, porque redirecciona desde otro dominio y no lo permite por seguridad. Hay que cambiar a la versión 3
	// http://code.google.com/p/gdata-issues/issues/detail?id=4887
	mparam = oVideo.find('> param[name="movie"]');
	oVideo.attr('data', oVideo.attr('data').replace('version=2', 'version=3'));
	mparam.attr('value', mparam.attr('value').replace('version=2', 'version=3'));
	oVideo.css('display', 'inline');
	p.find('> img.videothumb').add(this).unbind().remove();
},
// Agrega una imagen del vídeo en la posición del contenedor
_muestraThumb = function() {
	var oDiv = $(this), vid = oDiv.data('youtubevid'), w, h;
	// Se comprueba que esté oculto, para sincronizar con CSS
	if (vid && vid.length == 11 && oDiv.find('> iframe').length === 0) {
		w = oDiv.width().toString();
		h = oDiv.height().toString();
		oDiv.append(
			$('<img class="videothumb">').attr('src', _thumbUrl.replace('{0}', vid)).attr({width: w, height: h})).append(
			$('<div class="videodiscoveryoverlay">').css({width: w.concat('px'), height: h.concat('px')}).attr('title', _title).bind('click', _insertVideo));
	}
},
// Evento al hacer clic en el overlay
_insertVideo = function() {
	var p = $(this).parent(), iframe;
	p.empty();
	iframe = $('<iframe>').attr({
		'type': 'text/html',
		width: p.css('width'),
		height: p.css('height'),
		src: 'http://www.youtube.com/embed/' + p.data('youtubevid') + '?iv_load_policy=3&rel=0',
		frameborder: '0',
		allowfullscreen: ''
	}).appendTo(p);
};

// Muy lazy load
(typeof(window.safeOnLoadHook)=='function'?window.safeOnLoadHook:$)(function() {
	window.setTimeout(_init, 2000);
});

})(jQuery);

if (mw.config.get('wgCanonicalSpecialPageName', '') != 'MyHome') {
	window.wgEnableImageLightboxExt = false;
	// Por si ya se ha cargado (a veces pasa)
	(typeof(window.safeOnLoadHook)=='function'?safeOnLoadHook:$)(function() {
		$('#'+(window.bodyContentId||'bodyContent')).unbind('.lightbox');
	});
}

// Incluir Gadget-HotCat.js
// Para desactivar, agrega "window.noHotCat = true" en tu Monobook.js
if (mw.config.get('skin') != 'oasis' && mw.config.get('wgAction') == 'view' &&
		(mw.config.get('wgNamespaceNumber') == 0 || mw.config.get('wgNamespaceNumber') == 6 || mw.config.get('wgNamespaceNumber') == 14) &&
		window.location.toString().indexOf('diff=') == -1) {
	(typeof(window.safeOnLoadHook)=='function'?safeOnLoadHook:$)(function() {
		if (!document.getElementById('csAddCategorySwitch') && !window.noHotCat) {
			if ($('#catlinks').length == 0) {
				$('#'+(window.bodyContentId||'bodyContent')).children('div.printfooter').after('<div id="catlinks" class="catlinks"></div>');
			}
			if ($('#mw-normal-catlinks').length == 0) {
				$('#catlinks').prepend('<div id="mw-normal-catlinks"><a title="Special:Categories" href="'+mw.config.get('wgArticlePath', '').replace('$1', 'Special:Categories')+'">Categories</a></div>');
			}
			$('#mw-normal-catlinks').children('a').eq(0).after('<span class="noprint">&nbsp;<span>(<a style="cursor: pointer;" title="Modify categories"><span>+<sup>+</sup></span></a>)</span></span>').next().find('a').click(function() {
				$(this).unbind().closest('span.noprint').eq(0).remove();
				importScript('MediaWiki:Common.js/Clases/Gadget-HotCat.js');
				return false;
			});
			$('#catlinks').removeClass('catlinks-allhidden');
		}
	});
} else if (mw.config.get('wgCanonicalSpecialPageName', '') == 'Upload') {
	(typeof(window.safeOnLoadHook)=='function'?safeOnLoadHook:$)(function() {
		importScript('MediaWiki:Common.js/Clases/Gadget-HotCat.js');
	});
}

/***EVERYTHING ABOVE THIS LINE WORKS ****/
/****************************************/

if (mw.config.get('wgNamespaceNumber', 0) != -1) {
	(typeof(window.safeOnLoadHook)=='function'?safeOnLoadHook:$)(function() {
		importScript('MediaWiki:Common.js/Clases/SVGDirecto.js');
	});
}

// Impedir el renombrado de página de usuario
function disableUserpageMove() {
	var url = window.location.toString();
	var pn = mw.config.get('wgPageName', '');
	var pos = url.indexOf(pn);
	if (pos == -1) {
		url = decodeURIComponent(url);
	}
	pos = url.indexOf(pn);
	if (pos == -1) return; // fail :(
	var page = url.substr(url.indexOf(pn)+pn.length+1);
	pos = page.indexOf('?');
	if (pos != -1) {
		page = page.substr(0, pos);
	}
	pos = page.indexOf('/');
	if (pos != -1) {
		// Si hay barra es que se está trasladando una subpágina. Ok, lo permitimos
		return;
	}
	// Es página de usuario?
	var re_user = new RegExp('^(user|'+mw.config.get('wgFormattedNamespaces')['2']+'):', 'i');
	if (re_user.test(page)) {
		// Excluir admin y otros
		for (var i = 0; i < mw.config.get('wgUserGroups', []).length; i++) {
			if (mw.config.get('wgUserGroups')[i] == 'sysop' || mw.config.get('wgUserGroups')[i] == 'asistente' || mw.config.get('wgUserGroups')[i] == 'rollback') {
				return true;
			}
		}
		window.location = mw.config.get('wgArticlePath', '').replace('$1', 'Ayuda:Renombrar_mi_cuenta');
	}
}

if (mw.config.get('wgCanonicalSpecialPageName', '') == 'Movepage') {
	try {
		disableUserpageMove();
	} catch(e) {
		typeof(window.trataError)=='function'&&trataError(e);
	}
}

if (mw.config.get('wgIsMainPage')) {
	importScript('MediaWiki:Slider.js');
}

function inicializarAjaxRC() {
	if (mw.config.get('wgNamespaceNumber') == -1) {
		switch (mw.config.get('wgCanonicalSpecialPageName')) {
			case 'Recentchanges':
			case 'WikiActivity':
			case 'Newpages':
			case 'Watchlist':
				window.AjaxRCRefreshText = 'Actualizar automáticamente';
				window.AjaxRCRefreshHoverText = 'With the box checked, this page will automatically update itself every 60 seconds';
				window.ajaxRefresh = 60000;
				window.ajaxPages = [ mw.config.get('wgPageName') ];
				importScriptPage('AjaxRC/code.js', 'dev');
				break;
		}
	}
}

(typeof(window.safeOnLoadHook)=='function'?safeOnLoadHook:$)(inicializarAjaxRC);

function mejorarEspecialNuevasImagenes() {
	$('.wikia-gallery-item').each(function() {
		var $item = $(this), $img = $item.find('.thumbimage'), title = $img.attr('alt'), inm = $img.data('image-name'), capt = $item.find('.lightbox-caption'), $a;
		if (title) {
			// alt no incluye la extensión
			title += inm.substr(inm.lastIndexOf('.'));
			// Corrección de valor en image-key, vienen cosas como data-image-key="Logo_serie_XY_%26amp%3B_Z.png" que confunden a thickbox
			$img.data('image-key', encodeURIComponent(title.replace(/ /g, '_')));
			$a = $('<a>').text(title).attr( {title: title, href: $item.find('.image').attr('href')} );
			capt.prepend('<br>');
			capt.prepend($a);
		}
	});
}

if (mw.config.get('wgCanonicalSpecialPageName') === 'Newimages' || mw.config.get('wgCanonicalSpecialPageName') === 'Images') {
	(typeof(window.safeOnLoadHook)=='function'?safeOnLoadHook:$)(mejorarEspecialNuevasImagenes);
}



// Page tracker
try {
	(typeof(window.safeOnLoadHook)=='function'?safeOnLoadHook:$)(function() {
		if (!window._gaq || typeof window._gaq.length == 'undefined') return;
		var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	});
} catch(e) {
	typeof(window.trataError)=='function'&&trataError(e);
}
// End Page tracker
//</pre>



/* ############################################# */
/* ##          CUSTOM EDIT BUTTONS            ## */
/* ############################################# */
if ( mw.toolbar ) {
    mw.toolbar.addButton( {
            imageFile: 'http://images.wikia.com/493titanollante/images/9/90/Wikia_Button_-_Reference.png',
            speedTip: 'Reference',
            tagOpen: '<ref name="">[http://',
            tagClose: ']</ref>',
            sampleText: ''
    } );
}
if ( mw.toolbar ) {
    mw.toolbar.addButton( {
            imageFile: 'http://vignette1.wikia.nocookie.net/493titanollante/images/d/d5/Edit_Button_-_Cite_Book.png',
            speedTip: 'Book Citation',
            tagOpen: '<ref name="">{{cite book|title= |author= |date= |publisher= |page=!!OR!!|pages= ',
            tagClose: '|isbn=}}</ref>',
            sampleText: '...not all of these parameters are needed...see Template:Cite_book for documentation...delete this...'
    } );
}

//above guaranteed to work

if ( mw.toolbar ) {
    mw.toolbar.addButton( {
            imageFile: 'http://images.wikia.com/493titanollante/images/0/05/Wikia_Button_-_Kaiju_Infobox.png',
            speedTip: 'Kaiju Infobox',
            tagOpen: '{{Kaiju Infobox\r|type1            =???\r|type2            =???\r|header           ={{Toho Kaiju}} \r|copyrighticon    =\r|image            =\r|caption          =\r|name             =\r|subtitle =\r|species          =\r|nicknames        =\r|height           =?? meters\r|length           =?? meters\r|weight           =?? tons\r|forms            =\r|allies           =\r|enemies          =\r|relationships    =\r|controlled       =\r|created          =\r|portrayed        =\r|debut  =\r|last =\r|suits            =\r|roar             =[[File:.ogg|180px|center|noicon]]{{More Roars}}\r}}',
            tagClose: '',
            sampleText: ''
    } );
}
if ( mw.toolbar ) {
    mw.toolbar.addButton( {
            imageFile: 'http://images3.wikia.nocookie.net/__cb20140330215758/493titanollante/images/8/88/Wikia_Button_-_Character_Infobox.png',
            speedTip: 'Character Infobox',
            tagOpen: '{{Character Infobox\r|type1           =\r|type2           =\r|header          ={{Toho Character}}\r|image           =\r|caption         =\r|species         =\r|nationality     =\r|relationships   =\r|occupation      =\r|firstappearance =\r|played          =\r}}',
            tagClose: '',
            sampleText: ''
    } );
}
if ( mw.toolbar ) {
    mw.toolbar.addButton( {
            imageFile: 'http://images3.wikia.nocookie.net/493titanollante/images/9/98/Wikia_Button_-_Film_Infobox.png',
            speedTip: 'Film Infobox',
            tagOpen: '{{Infopelicula\r|type1       =\r|type2       =\r|image       =\r|caption     =The Japanese poster for \r|name  =\r|director    =[[\r|producer    =[[\r|writer      =[[\r|composer    =[[\r|distributor =[[Toho Company Ltd.]]{{sup|[[Japan|JP]]}}<br>[[{{sup|[[United States|US]]}}\r|rating      =<br><br>\r|budget      =¥\r|gross       =¥\r|runtime     =?? minutes{{sup|[[Japan|JP]]}}<br />{{Small|(? hour, ?? minutes)}}<br />?? minutes{{sup|[[United States|US]]}}<br />{{Small|(? hour, ?? minutes)}}\r|designs     =[[\r}}',
            tagClose: '',
            sampleText: ''
    } );
}
if ( mw.toolbar ) {
    mw.toolbar.addButton( {
            imageFile: 'http://images4.wikia.nocookie.net/__cb20140318050025/493titanollante/images/3/35/Wikia_Button_-_Game_Infobox.png',
            speedTip: 'Game Infobox',
            tagOpen: '{{Game Infobox\r|type1       =\r|type2       =\r|header      =\r|image       =\r|caption     =\r|name        =\r|published   =\r|developed   =\r|platforms   =\r|languages   =\r|genre       =\r}}',
            tagClose: '',
            sampleText: ''
    } );
}
if ( mw.toolbar ) {
    mw.toolbar.addButton( {
            imageFile: 'http://images2.wikia.nocookie.net/__cb20140219034760/493titanollante/images/8/83/Wikia_Button_-_Tab_and_Nav.png',
            speedTip: 'Tab and Navigation (Movie)',
            tagOpen: '{{Mtab}}\r{{Nav\r|type1       =\r|type2       =\r|type        =[[:Category:|Category:]]\r|name        =\r|prev        =\r|prevname    =\r|next        =\r|nextname    =\r}}',
            tagClose: '',
            sampleText: ''
    } );
}
if ( mw.toolbar ) {
    mw.toolbar.addButton( {
            imageFile: 'http://images3.wikia.nocookie.net/__cb20140219034760/493titanollante/images/1/1e/Wikia_Button_-_Staff_and_Cast.png',
            speedTip: 'Staff and Cast Templates',
            tagOpen: '==Staff==\r{{Staffs\r|Directed by=[[\r|Written by=\r|Produced by=\r|Executive Producing by=\r|Music by=\r|Cinematography by=\r|Edited by=\r|Production Design by=\r|Assistant Directing by=\r|Special Effects by=\r}}\r==Cast==\r{{Cast\r||\r||\r||\r||\r||\r||\r||\r||\r||\r||\r||\r}}',
            tagClose: '',
            sampleText: ''
    } );
}
if ( mw.toolbar ) {
    mw.toolbar.addButton( {
            imageFile: 'http://images.wikia.com/493titanollante/images/c/cd/Wikia_Button_-_DVD.png',
            speedTip: 'DVD Info',
            tagOpen: '<b>COMPANY</b> (YEAR)<ref name="">[http:// Amazon.com: ]</ref>\\r*Region: \r*Audio: \r*Special Features: \r*Notes:  ',
            tagClose: '',
            sampleText: ''
    } );
}
if ( mw.toolbar ) {
    mw.toolbar.addButton( {
            imageFile: 'http://www.wikizilla.org/wiki/images/9/90/Edit_Button_-_YouTube.png',
            speedTip: 'YouTube Embed',
            tagOpen: '<youtube width="300" height="169">',
            tagClose: '</youtube>',
            sampleText: '...Put YT video ID here; remove "width="300" height="169"" to make video the default size ~ 300x169 is specifically for infoboxes...'
    } );
}
//if ( mw.toolbar ) {
//    mw.toolbar.addButton( {
//            imageFile: '',
//            speedTip: '',
//            tagOpen: '',
//            tagClose: '',
//            sampleText: ''
//    } );
//}
/******************************************************************************************************************************/

/******************************************************************************************************************************/

/******************************************************************************************************************************/

/*********************************************************************** W I K I  E D I T O R B U T T O N S *******************/

/************************************************ WikiEditor Buttons/Customization ********************************************/

/******************************************************************************************************************************/

/******************************************************************************************************************************
 * Extra buttons in toolbar
 * @stats [[File:Krinkle_InsertWikiEditorButton.js]]
 ******************************************************************************************************************************/
$.ajax({
	url: 'https://meta.wikimedia.org/w/index.php?title=User:Krinkle/Scripts/InsertWikiEditorButton.js&action=raw&ctype=text/javascript',
	dataType: 'script',
	cache: true
}).done(function () {

	// REFERENCE with ID
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-refidbutton",
		icon: "//vignette3.wikia.nocookie.net/wikizilla-files/images/9/97/Editor_Button_-_Reference.png",
		label: 'Reference with ID',
		insertBefore: '<ref name="">[http://',
		insertAfter: ']</ref>',
		sampleText: ''
	});
	// BOOK CITATION
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-citebookbutton",
		icon: "//vignette4.wikia.nocookie.net/wikizilla-files/images/7/73/Editor_Button_-_Reference_Book.png",
		label: 'Cite book',
		insertBefore: '<ref name="">{{cite book|title= |author= |date= |publisher= |page=!!OR!!|pages= ',
		insertAfter: '|isbn=}}</ref>',
		sampleText: '...not all parameters required.--see Template:Cite_book for documentation...'
	});

	// CORRECT FORMAT GALLERY
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-gallerybutton",
		icon: "//vignette4.wikia.nocookie.net/wikizilla-files/images/f/f6/Editor_Button_-_Correct_Gallery.png",
		label: 'Gallery',
		insertBefore: '<gallery widths="120" position="center" captionalign="center" spacing="small">\r',
		insertAfter: '\r</gallery>',
		sampleText: 'Test Image.png'
	});

	// YOUTUBE EMBED
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-youtubebutton",
		icon: "//vignette3.wikia.nocookie.net/wikizilla-files/images/d/de/Editor_Button_-_YouTube.png",
		label: 'YouTube embed',
		insertBefore: '<youtube width="300" height="169">',
		insertAfter: '</youtube>',
		sampleText: '...Put YT video ID here; remove _width="300" height="169"_ to make default size ~ 300x169 is specifically for infoboxes...'
	});

	// TABBER
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-infoboxtabberbutton",
		icon: "//vignette1.wikia.nocookie.net/wikizilla-files/images/0/08/Editor_Button_-_Tabber.png",
		label: 'Tabber',
		insertBefore: '<tabs style="color:black; padding: 0px; margin: 0px;">\r<tab name="NAMEHERE">[[File:|300px| in ]]</tab>\r',
		insertAfter: '\r<tab name="NAMEHERE2">[[File:|300px| in ]]</tab>\r</tabs>',
		sampleText: '<!---- add multiple tabs by copy pasting and changing the values ---- to replace the infobox image with a tabber, change |image = with |altimage = ---->'
	});

	// DVD INFO
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-dvdbutton",
		icon: "//vignette2.wikia.nocookie.net/wikizilla-files/images/4/4f/Editor_Button_-_DVD_Info.png",
		label: 'Insert DVD information',
		insertBefore: '<b>COMPANY</b> (YEAR)<ref name="">[http:// Amazon.com: ]</ref>\\r*Region: \r*Audio: \r*Special Features: \r*Notes:  ',
		insertAfter: '',
		sampleText: ''
	});

	// STAFF and CAST Information
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-staffcastbutton",
		icon: "//vignette2.wikia.nocookie.net/wikizilla-files/images/e/eb/Editor_Button_-_Staff_and_Cast.png",
		label: 'Insert Staff and Cast information',
		insertBefore: '==Staff==\r{{Staffs\r|Directed by=[[\r|Written by=\r|Produced by=\r|Executive Producing by=\r|Music by=\r|Cinematography by=\r|Edited by=\r|Production Design by=\r|Assistant Directing by=\r|Special Effects by=\r}}\r==Cast==\r{{Cast\r||\r||\r||\r||\r||\r||\r||\r||\r||\r||\r||\r}}',
		insertAfter: '',
		sampleText: ''
	});

	// FILM Tab and Nav
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-filmtabnavbutton",
		icon: "//vignette1.wikia.nocookie.net/wikizilla-files/images/9/95/Editor_Button_-_Nav.png",
		label: 'Tab and navigation (film)',
		insertBefore: '{{Mtab}}\r{{Nav\r|type1       =\r|type2       =\r|type        =[[:Category:|Category:]]\r|name        =\r|prev        =\r|prevname    =\r|next        =\r|nextname    =\r}}',
		insertAfter: '',
		sampleText: ''
	});


	// INFOBOX KAIJU
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-infoboxkaijubutton",
		icon: "//vignette4.wikia.nocookie.net/wikizilla-files/images/b/b8/Editor_Button_-_Infobox_Kaiju.png",
		label: 'Kaiju infobox',
		insertBefore: '{{Kaiju Infobox\r|type1            =???\r|type2            =???\r|header           ={{Toho Kaiju}} \r|copyrighticon    =\r|image            =\r|caption          =\r|name             =\r|subtitle         =\r|species          =\r|nicknames        =\r|height           =?? meters\r|length           =?? meters\r|weight           =?? tons\r|forms            =\r|allies           =\r|enemies          =\r|relationships    =\r|controlled       =\r|created          =\r|portrayed        =\r|debut            =\r|last             =\r|suits            =\r|roar             =[[File:.ogg|180px|center|noicon]]{{More Roars}}\r}}',
		insertAfter: '',
		sampleText: ''
	});

	// INFOBOX FILM
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-infoboxfilmbutton",
		icon: "//vignette3.wikia.nocookie.net/wikizilla-files/images/6/68/Editor_Button_-_Infobox_Film.png",
		label: 'Film infobox',
		insertBefore: '{{Infopelicula\r|type1       =\r|type2       =\r|image       =\r|caption     =The Japanese poster for \r|name        =\r|us-title    =\r|jp-title    =\r|director    =[[\r|producer    =[[\r|writer      =[[\r|composer    =[[\r|distributor =[[Toho]]{{sup|[[Japan|JP]]}}<br>[[]]{{sup|[[United States|US]]}}\r|rating      =\r|budget      =¥\r|gross       =¥\r|runtime     =?? minutes{{sup|[[Japan|JP]]}}<br>{{Small|(? hour, ?? minutes)}}<br />?? minutes{{sup|[[United States|US]]}}<br>{{Small|(? hour, ?? minutes)}}\r|designs     =[[\r}}',
		insertAfter: '',
		sampleText: ''
	});

	// INFOBOX CHARACTER
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-infoboxcharacterbutton",
		icon: "//vignette1.wikia.nocookie.net/wikizilla-files/images/f/f6/Editor_Button_-_Infobox_Character.png",
		label: 'Character infobox',
		insertBefore: '{{Character Infobox\r|type1           =\r|type2           =\r|header          ={{Character}}\r|image           =\r|caption         =\r|species         =\r|nationality     =\r|relationships   =\r|occupation      =\r|firstappearance =\r|played          =\r}}',
		insertAfter: '',
		sampleText: ''
	});

	// INFOBOX TV SHOW
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-infoboxtvshowbutton",
		icon: "//vignette1.wikia.nocookie.net/wikizilla-files/images/2/22/Editor_Button_-_Infobox_TV.png",
		label: 'TV show infobox',
		insertBefore: '{{Infobox Series\r|header        ={{Series}}\r|type1         =\r|type2         =\r|name          =\r|image         =\r|creator       =\r|producer      =\r|distributor   =\r|genre         =\r|aired         =\r|channel       =\r|episodes      =\r}}',
		insertAfter: '',
		sampleText: ''
	});

	// INFOBOX BOOK
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-infoboxbookbutton",
		icon: "//vignette3.wikia.nocookie.net/wikizilla-files/images/7/70/Editor_Button_-_Infobox_Book.png",
		label: 'Book infobox',
		insertBefore: '{{Infobox Book\r|type1        =\r|type2        =\r|image        =\r|name         =\r|author       =\r|publisher    =\r|publishdate  =\r|genre        =\r|isbn         =[[Special:BookSources/|ISBN-10: ]]<br>[[Special:BookSources/|ISBN-13: ]]\r}}',
		insertAfter: '',
		sampleText: ''
	});

	// INFOBOX VIDEO GAME
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-infoboxvideogamebutton",
		icon: "//vignette1.wikia.nocookie.net/wikizilla-files/images/f/fb/Editor_Button_-_Infobox_Game.png",
		label: 'Video game infobox',
		insertBefore: '{{Game Infobox\r|type1       =\r|type2       =\r|header      =\r|image       =\r|caption     =\r|name        =\r|published   =\r|developed   =\r|platforms   =\r|languages   =\r|genre       =\r}}',
		insertAfter: '',
		sampleText: ''
	});

});

/**************************************************/

/*************** END WikiEditor ******************/

/************************************************/

/**
 * Dynamic Navigation Bars. See [[Wikipedia:NavFrame]]
 * 
 * Based on script from en.wikipedia.org, 2008-09-15.
 *
 * @source www.mediawiki.org/wiki/MediaWiki:Gadget-NavFrame.js
 * @maintainer Helder.wiki, 2012–2013
 * @maintainer Krinkle, 2013
 */
( function () {

// Set up the words in your language
var collapseCaption = 'hide';
var expandCaption = 'show';

var navigationBarHide = '[' + collapseCaption + ']';
var navigationBarShow = '[' + expandCaption + ']';

/**
 * Shows and hides content and picture (if available) of navigation bars.
 *
 * @param {number} indexNavigationBar The index of navigation bar to be toggled
 * @param {jQuery.Event} e Event object
 */
function toggleNavigationBar( indexNavigationBar, e ) {
	var navChild,
		navToggle = document.getElementById( 'NavToggle' + indexNavigationBar ),
		navFrame = document.getElementById( 'NavFrame' + indexNavigationBar );

	// Prevent browser from jumping to href "#"
	e.preventDefault();

	if ( !navFrame || !navToggle ) {
		return false;
	}

	// If shown now
	if ( navToggle.firstChild.data == navigationBarHide ) {
		for ( navChild = navFrame.firstChild; navChild != null; navChild = navChild.nextSibling ) {
			if ( hasClass( navChild, 'NavPic' ) ) {
				navChild.style.display = 'none';
			}
			if ( hasClass( navChild, 'NavContent' ) ) {
				navChild.style.display = 'none';
			}
		}
		navToggle.firstChild.data = navigationBarShow;

	// If hidden now
	} else if ( navToggle.firstChild.data == navigationBarShow ) {
		for ( navChild = navFrame.firstChild; navChild != null; navChild = navChild.nextSibling ) {
			if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
				navChild.style.display = 'block';
			}
		}
		navToggle.firstChild.data = navigationBarHide;
	}
}

/**
 * Adds show/hide-button to navigation bars.
 *
 * @param {jQuery} $content
 */
function createNavigationBarToggleButton( $content ) {
	var i, j, navFrame, navToggle, navToggleText, navChild,
		indexNavigationBar = 0,
		navFrames = $content.find( 'div.NavFrame' ).toArray();

	// Iterate over all (new) nav frames
	for ( i = 0; i < navFrames.length; i++ ) {
		navFrame = navFrames[i];
		// If found a navigation bar
		indexNavigationBar++;
		navToggle = document.createElement( 'a' );
		navToggle.className = 'NavToggle';
		navToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
		navToggle.setAttribute( 'href', '#' );
		$( navToggle ).on( 'click', $.proxy( toggleNavigationBar, null, indexNavigationBar ) );

		navToggleText = document.createTextNode( navigationBarHide );
		for ( navChild = navFrame.firstChild; navChild != null; navChild = navChild.nextSibling ) {
			if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
				if ( navChild.style.display == 'none' ) {
					navToggleText = document.createTextNode( navigationBarShow );
					break;
				}
			}
		}

		navToggle.appendChild( navToggleText );
		// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
		for ( j = 0; j < navFrame.childNodes.length; j++ ) {
			if ( $( navFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
				navFrame.childNodes[j].appendChild( navToggle );
			}
		}
		navFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
	}
}

mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );

}());



/////// Customizing Enhanced Toolbar