User:JhonaBF/global.js

$( function { 'use strict';  //define o id dos botões base da lateral  var $botaoEditarLateral = '#ca-edit-side-tool';  var $botaoAdicionarTopicoLateral = '#ca-addsection-side-tool';  var $botaoVerFonteLateral = '#ca-viewsource-side-tool';

var $lastButton; if (!$('.ns-talk').length){ $lastButton = $( $botaoEditarLateral ); } else{ $lastButton = $( $botaoAdicionarTopicoLateral ); }	if ( !$lastButton.length ) { $lastButton = $( $botaoVerFonteLateral ); }

//Adiciona o botão de discussão if ( !$('.ns-talk').length && $($botaoEditarLateral).length ) { var $talkEditLink; var $talkButtonBase = $( '#ca-talk' ); if ($talkButtonBase.length){ $talkEditLink = $( '' ) .attr( 'id', 'ca-talk-custom' ) .attr( 'href', $talkButtonBase.attr('href').replace("?action=edit&redlink=1", "") ) .attr( 'title', 'Discussão' ) .addClass( 'page-side-tool' ) .html(' '); // from Heroicons – https://heroicons.dev/ $talkEditLink.insertAfter( $lastButton ); $lastButton = $( '#ca-talk-custom' ); } }  //Adiciona o botão de informação if ( $('.mw-editable').length && ($($botaoEditarLateral).length || $('ca-addsection').length) && !$('.action-edit').length && !$('.action-submit').length) { var $infoLink;

var $editButtonBase = $( $botaoEditarLateral ); if($('.action-info').length){ $infoLink = $( '' ) .attr( 'id', 'ca-info-custom' ) .attr( 'href', $editButtonBase.attr('href').replace("?action=edit", "") ) .attr( 'title', 'Voltar' ) .addClass( 'page-side-tool' ) .html(' '); // from Heroicons – https://heroicons.dev/ } 	else{ $infoLink = $( '' ) .attr( 'id', 'ca-info-custom' ) .attr( 'href', $editButtonBase.attr('href').replace("action=edit", "action=info") ) .attr( 'title', 'Informações da página' ) .addClass( 'page-side-tool' ) .html(' '); // from Heroicons – https://heroicons.dev/ }

$infoLink.insertAfter( $lastButton ); $lastButton = $( '#ca-info-custom' ); } //Adiciona o botão de idioma if ( $('.page-header__languages').length ) { var $langLink; var $idiomas = document.querySelector(".page-header__languages .wds-dropdown .wds-dropdown__content");

if ($idiomas){ var $langLink1 = $( ' ' ) .attr( 'id', 'ca-lang-custom' ) .attr( 'href', "" ) .attr( 'title', 'Idiomas' ) .addClass( 'page-side-tool' ) .html(' '); // from Heroicons – https://heroicons.dev/ $langLink = $( ' ' ) .attr( 'style', 'position: relative;' ) .html($langLink1); $langLink.html($langLink.html + ' ' + $idiomas.innerHTML + ' '); $langLink.insertAfter( $lastButton ); $lastButton = $( '#ca-lang-custom' );

window.onclick = function(ev) { if( ev.target.id !== 'custom-lang-box' && ev.target.id !== 'ca-lang-custom' ){ if (!document.getElementById("custom-lang-box").classList.contains('wds-is-hidden')){ document.getElementById("custom-lang-box").classList.add('wds-is-hidden'); }       }  	  };  	  document.getElementById("ca-lang-custom").onclick = function { if (document.getElementById("custom-lang-box").classList.contains('wds-is-hidden')){ document.getElementById("custom-lang-box").classList.remove('wds-is-hidden'); }       else{ document.getElementById("custom-lang-box").classList.add('wds-is-hidden'); } 	  };    }  } } );