MediaWiki:Common.js: Difference between revisions
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
| Line 1: | Line 1: | ||
$(function() { | $(function () { | ||
if (!mw.config.get("wgIsMainPage")) return; | if (!mw.config.get("wgIsMainPage")) return; | ||
var host = | var host = location.hostname; | ||
var dropdown = $(` | var dropdown = $(` | ||
<div id="languageDropdown" style=" | <div id="languageDropdown" style=" | ||
position:fixed; | |||
top:10px; | |||
right:20px; | |||
z-index:99999; | |||
font-size:14px; | |||
"> | "> | ||
<button type="button" style=" | <button type="button" style=" | ||
padding:6px 10px; | |||
cursor:pointer; | cursor:pointer; | ||
">🌐 Language ▾</button> | ">🌐 Language ▾</button> | ||
<div id="languageDropdownContent" style=" | <div id="languageDropdownContent" style=" | ||
display:none; | display:none; | ||
background:#fff; | background:#fff; | ||
border:1px solid #ccc; | border:1px solid #ccc; | ||
margin-top:4px; | |||
box-shadow:0 2px 6px rgba(0,0,0,.2); | |||
box-shadow:0 2px 6px rgba(0,0,0, | |||
"></div> | "></div> | ||
</div> | </div> | ||
`); | `); | ||
var content = dropdown.find("#languageDropdownContent"); | |||
var content = | |||
if (host === "tr.sanarsiv.org") { | if (host === "tr.sanarsiv.org") { | ||
content.append('<a href="https://tr.sanarsiv.org/">Türkçe</a>'); | content.append('<a href="https://tr.sanarsiv.org/">Türkçe</a>'); | ||
content.append('<a href="https://az.sanarsiv.org/wiki/Ana_səhifə">Azərbaycanca</a>'); | content.append('<a href="https://az.sanarsiv.org/wiki/Ana_səhifə">Azərbaycanca</a>'); | ||
} | } else if (host === "az.sanarsiv.org") { | ||
content.append('<a href="https://az.sanarsiv.org/wiki/Ana_səhifə">Azərbaycanca</a>'); | content.append('<a href="https://az.sanarsiv.org/wiki/Ana_səhifə">Azərbaycanca</a>'); | ||
content.append('<a href="https://tr.sanarsiv.org/">Türkçe</a>'); | content.append('<a href="https://tr.sanarsiv.org/">Türkçe</a>'); | ||
} | } | ||
content.find("a").css({ | content.find("a").css({ | ||
display: "block", | display: "block", | ||
padding: "8px 12px", | padding: "8px 12px", | ||
textDecoration: "none", | textDecoration: "none", | ||
color: "#000 | color: "#000" | ||
}); | }); | ||
$("body").append(dropdown); | |||
$(" | |||
$("#languageDropdown button").on("click", function (e) { | |||
$("#languageDropdown button").on("click", function(e) { | |||
e.stopPropagation(); | e.stopPropagation(); | ||
content.toggle(); | |||
}); | }); | ||
$(document).on("click", function () { | |||
$(document).on("click", function() { | content.hide(); | ||
}); | }); | ||
}); | }); | ||