MediaWiki:Common.js: Difference between revisions

No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 1: Line 1:
$(function() {
$(function () {
    // Sadece anasayfada çalışacak
     if (!mw.config.get("wgIsMainPage")) return;
     if (!mw.config.get("wgIsMainPage")) return;


     var host = window.location.hostname;
     var host = location.hostname;


    // Dropdown HTML
     var dropdown = $(`
     var dropdown = $(`
         <div id="languageDropdown" style="
         <div id="languageDropdown" style="
             display:inline-block;
             position:fixed;
             position:relative;
            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;
                padding:6px 10px;
             ">🌐 Language ▾</button>
             ">🌐 Language ▾</button>


             <div id="languageDropdownContent" style="
             <div id="languageDropdownContent" style="
                 display:none;
                 display:none;
                position:absolute;
                top:100%;
                left:0;
                 background:#fff;
                 background:#fff;
                 border:1px solid #ccc;
                 border:1px solid #ccc;
                 min-width:160px;
                 margin-top:4px;
                z-index:9999;
                 box-shadow:0 2px 6px rgba(0,0,0,.2);
                 box-shadow:0 2px 6px rgba(0,0,0,0.2);
             "></div>
             "></div>
         </div>
         </div>
     `);
     `);


    // İçerik ekleme
     var content = dropdown.find("#languageDropdownContent");
     var content = $("#languageDropdownContent", dropdown);


     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") {
    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>');
     }
     }


    // Link stilleri (olmazsa üst üste yapışırlar)
     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"
        whiteSpace: "nowrap"
     });
     });


    // Hover efekti, çünkü insanız
     $("body").append(dropdown);
    content.find("a").hover(
        function() { $(this).css("background", "#f0f0f0"); },
        function() { $(this).css("background", "#fff"); }
    );
 
    // Sayfaya ekle
     $("#content").append(dropdown);


    // Aç/kapa
     $("#languageDropdown button").on("click", function (e) {
     $("#languageDropdown button").on("click", function(e) {
         e.stopPropagation();
         e.stopPropagation();
         $("#languageDropdownContent").toggle();
         content.toggle();
     });
     });


    // Dışarı tıklayınca kapat
     $(document).on("click", function () {
     $(document).on("click", function() {
         content.hide();
         $("#languageDropdownContent").hide();
     });
     });
});
});