MediaWiki:Common.js e Wikiquote:Página de testes: diferenças entre as páginas
(Diferenças entre páginas)
Conteúdo apagado Conteúdo adicionado
mSem resumo de edição |
m Migração para o MediaWiki 1.17: acesso às variáveis wg** com mw.config.get, -addOnloadHook; Correção de erros apontados pelo http://jshint.org ao tentar validar o código conforme sugerido nas convenções |
||
Linha 1: | Linha 1: | ||
/* Código Javascript colocado aqui será carregado para todos os utilizadores em cada carregamento de página */ |
/* Código Javascript colocado aqui será carregado para todos os utilizadores em cada carregamento de página */ |
||
// <source lang="javascript"> |
|||
if (wgAction |
if ($.inArray( mw.config.get( 'wgAction' ), [ "edit" , "submit" ]) > -1) |
||
{ |
{ |
||
var load_edittools = true; |
var load_edittools = true; |
||
importScript("MediaWiki:Edittools.js") |
importScript("MediaWiki:Edittools.js"); |
||
importScript("MediaWiki:Extrabo.js") |
importScript("MediaWiki:Extrabo.js"); |
||
importScript("MediaWiki:Forcepreview.js") |
importScript("MediaWiki:Forcepreview.js"); |
||
} |
} |
||
else if (wgPageName == "Especial:Busca" ) |
else if (mw.config.get( 'wgPageName' ) == "Especial:Busca" ) |
||
{ |
{ |
||
importScript("MediaWiki:Search.js") |
importScript("MediaWiki:Search.js"); |
||
} |
} |
||
else if (navigator.appName == "Microsoft Internet Explorer") |
else if (navigator.appName == "Microsoft Internet Explorer") |
||
{ |
{ |
||
importScript("MediaWiki:IEFixes.js") |
importScript("MediaWiki:IEFixes.js"); |
||
} |
} |
||
else if( wgRestrictionEdit |
else if( $.inArray( mw.config.get( 'wgRestrictionEdit' ), [ "autoconfirmed" , "sysop" ]) > -1) |
||
{ |
{ |
||
importScript("MediaWiki:Topicon.js") |
importScript("MediaWiki:Topicon.js"); |
||
} |
} |
||
Linha 28: | Linha 27: | ||
* Upload form |
* Upload form |
||
*/ |
*/ |
||
importScript('MediaWiki:UploadForm.js') |
importScript('MediaWiki:UploadForm.js'); |
||
Linha 36: | Linha 35: | ||
********************************************************************************************/ |
********************************************************************************************/ |
||
mw.util.addCSS( '#interProject, #sisterProjects {display: none; speak: none;} #p-tb .pBody {padding-right: 0;}' ); |
|||
function iProject() { |
function iProject() { |
||
if (document.getElementById("interProject")) { |
if (document.getElementById("interProject")) { |
||
var |
var iProjectElem = document.getElementById("interProject").innerHTML, |
||
interProject = document.createElement("div"); |
|||
interProject.style.marginTop = "0.7em"; |
interProject.style.marginTop = "0.7em"; |
||
interProject.innerHTML = '<h5>Correlatos<\/h5><div class="pBody">'+ |
interProject.innerHTML = '<h5>Correlatos<\/h5><div class="pBody">'+iProjectElem+'<\/div>'; |
||
document.getElementById("p-tb").appendChild(interProject); |
document.getElementById("p-tb").appendChild(interProject); |
||
} |
} |
||
} |
} |
||
$(iProject); |
|||
/** Commons ****************************************************************************** |
/** Commons ****************************************************************************** |
||
Linha 76: | Linha 75: | ||
if (!window.aOnloadFunctions) { |
if (!window.aOnloadFunctions) { |
||
var aOnloadFunctions = |
var aOnloadFunctions = []; |
||
} |
} |
||
Linha 85: | Linha 84: | ||
} |
} |
||
} |
} |
||
} |
}; |
||
// END Enable multiple onload functions |
// END Enable multiple onload functions |
||
Linha 120: | Linha 119: | ||
function toggleNavigationBar(indexNavigationBar) |
function toggleNavigationBar(indexNavigationBar) |
||
{ |
{ |
||
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar) |
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar), |
||
NavFrame = document.getElementById("NavFrame" + indexNavigationBar), |
|||
NavChild; |
|||
if (!NavFrame || !NavToggle) { |
if (!NavFrame || !NavToggle) { |
||
Linha 130: | Linha 130: | ||
if (NavToggle.firstChild.data == NavigationBarHide) { |
if (NavToggle.firstChild.data == NavigationBarHide) { |
||
for ( |
for ( |
||
NavChild = NavFrame.firstChild; |
|||
NavChild != null; |
NavChild !== null; |
||
NavChild = NavChild.nextSibling |
NavChild = NavChild.nextSibling |
||
) { |
) { |
||
Linha 146: | Linha 146: | ||
} else if (NavToggle.firstChild.data == NavigationBarShow) { |
} else if (NavToggle.firstChild.data == NavigationBarShow) { |
||
for ( |
for ( |
||
NavChild = NavFrame.firstChild; |
|||
NavChild != null; |
NavChild !== null; |
||
NavChild = NavChild.nextSibling |
NavChild = NavChild.nextSibling |
||
) { |
) { |
||
Linha 164: | Linha 164: | ||
function createNavigationBarToggleButton() |
function createNavigationBarToggleButton() |
||
{ |
{ |
||
var indexNavigationBar = 0; |
var indexNavigationBar = 0, i; |
||
// iterate over all < div >-elements |
// iterate over all < div >-elements |
||
for( |
for( |
||
⚫ | |||
var i=0; |
|||
NavFrame; |
|||
⚫ | |||
i++ |
|||
i++ |
|||
) { |
|||
// if found a navigation bar |
// if found a navigation bar |
||
if (NavFrame.className == "NavFrame") { |
if (NavFrame.className == "NavFrame") { |
||
Linha 194: | Linha 195: | ||
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); |
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); |
||
} |
} |
||
NavFrame = document.getElementsByTagName("div")[i]; |
|||
} |
} |
||
// if more Navigation Bars found than Default: hide all |
// if more Navigation Bars found than Default: hide all |
||
if (NavigationBarShowDefault < indexNavigationBar) { |
if (NavigationBarShowDefault < indexNavigationBar) { |
||
for( |
for( |
||
i=1; |
|||
i<=indexNavigationBar; |
i<=indexNavigationBar; |
||
i++ |
i++ |
||
Linha 215: | Linha 217: | ||
{ |
{ |
||
// iterate over all <span>-elements |
// iterate over all <span>-elements |
||
for(var i=0 |
for(var i=0, a = document.getElementsByTagName("span")[0]; a; i++) { |
||
// if found a linkInfo span |
// if found a linkInfo span |
||
if(a.className == "interwiki-info") { |
if(a.className == "interwiki-info") { |
||
Linha 221: | Linha 223: | ||
var count=0; |
var count=0; |
||
for(var j=0 |
for(var j=0, b = document.getElementsByTagName("li")[0]; b; j++) { |
||
if(b.className == "interwiki-" + a.id) { |
if(b.className == "interwiki-" + a.id) { |
||
b.innerHTML = b.innerHTML + " "+a.title; |
b.innerHTML = b.innerHTML + " "+a.title; |
||
if(a.title == "(vo)") { b.title = "Texto original"; } |
if(a.title == "(vo)") { b.title = "Texto original"; } |
||
} |
} |
||
else if(b.className == "interwiki-" + a.id.substr(0,a.id.length-1)) { |
|||
count = count+1; |
count = count+1; |
||
if(a.id.charAt(a.id.length-1) == count) { |
if(a.id.charAt(a.id.length-1) == count) { |
||
Linha 232: | Linha 234: | ||
} |
} |
||
} |
} |
||
b = document.getElementsByTagName("li")[j]; |
|||
} |
} |
||
} |
} |
||
a = document.getElementsByTagName("span")[i]; |
|||
} |
} |
||
} |
} |
||
Linha 243: | Linha 247: | ||
* Autores: [[:en:User:Gmaxwell]], [[:en:User:MZMcBride]] |
* Autores: [[:en:User:Gmaxwell]], [[:en:User:MZMcBride]] |
||
******************************************************************************/ |
******************************************************************************/ |
||
importScript('MediaWiki:WikiBanners.js') |
importScript('MediaWiki:WikiBanners.js'); |
||
/** Altera o título da página ************************************************************** |
/** Altera o título da página ************************************************************** |
||
Linha 271: | Linha 275: | ||
/* Algo deu errado. */ |
/* Algo deu errado. */ |
||
} |
} |
||
} |
}; |
||
$(rewritePageH1); |
|||
/** Transforma determinadas páginas em páginas de discussão ** |
/** Transforma determinadas páginas em páginas de discussão ** |
||
Linha 284: | Linha 288: | ||
document.body.className = 'ns-talk'; |
document.body.className = 'ns-talk'; |
||
} |
} |
||
$(TransformeEmPaginaDeDiscussao); |
|||
// </source> |