MediaWiki:VectorPlus.js: Difference between revisions

Jump to navigation Jump to search
(Created page with "$(document).ready(function() { // Check if the current page has a "Tools" menu if ($("#p-tb").length) { // Create a new dropdown menu var dropdown = $("<li>", { "class": "interlanguage-link interwiki-tools" }); var dropdownLink = $("<a>", { "href": "#", "text": "Tools" }); var dropdownList = $("<ul>"); // Move the "What links here" link to the dropdown menu var whatLinksHere = $("#t-whatlinkshere"); if (whatLinksHere.length) { dropd...")
 
mNo edit summary
Line 1: Line 1:
// Add a custom dropdown for the specified tools
$(document).ready(function() {
$(document).ready(function() {
   // Check if the current page has a "Tools" menu
   // Create the dropdown
   if ($("#p-tb").length) {
   var toolsDropdown = '<div class="custom-tools-dropdown">' +
     // Create a new dropdown menu
     '<button class="dropbtn">Tools</button>' +
     var dropdown = $("<li>", { "class": "interlanguage-link interwiki-tools" });
     '<div class="dropdown-content">' +
     var dropdownLink = $("<a>", { "href": "#", "text": "Tools" });
     $('#t-whatlinkshere, #t-recentchanges, #t-permalink, #t-info').prop('outerHTML') +
     var dropdownList = $("<ul>");
    '</div>' +
     '</div>';


    // Move the "What links here" link to the dropdown menu
  // Insert the dropdown after the "View history" button
    var whatLinksHere = $("#t-whatlinkshere");
  $('#ca-history').after(toolsDropdown);
    if (whatLinksHere.length) {
      dropdownList.append($("<li>").append(whatLinksHere));
    }


    // Move the "Related changes" link to the dropdown menu
  // Remove the original tools
    var relatedChanges = $("#t-recentchangeslinked");
  $('#t-whatlinkshere, #t-recentchanges, #t-permalink, #t-info').remove();
    if (relatedChanges.length) {
      dropdownList.append($("<li>").append(relatedChanges));
    }
 
    // Move the "Permanent link" link to the dropdown menu
    var permanentLink = $("#t-permalink");
    if (permanentLink.length) {
      dropdownList.append($("<li>").append(permanentLink));
    }
 
    // Move the "Page information" link to the dropdown menu
    var pageInfo = $("#t-info");
    if (pageInfo.length) {
      dropdownList.append($("<li>").append(pageInfo));
    }
 
    // Add the dropdown menu to the "Tools" menu
    dropdown.append(dropdownLink);
    dropdown.append(dropdownList);
    $("#p-tb ul").prepend(dropdown);
 
    // Remove the original links from the "Tools" menu
    $("#t-whatlinkshere, #t-recentchangeslinked, #t-permalink, #t-info").remove();
  }
});
});

Revision as of 01:16, 23 February 2024

// Add a custom dropdown for the specified tools
$(document).ready(function() {
  // Create the dropdown
  var toolsDropdown = '<div class="custom-tools-dropdown">' +
    '<button class="dropbtn">Tools</button>' +
    '<div class="dropdown-content">' +
    $('#t-whatlinkshere, #t-recentchanges, #t-permalink, #t-info').prop('outerHTML') +
    '</div>' +
    '</div>';

  // Insert the dropdown after the "View history" button
  $('#ca-history').after(toolsDropdown);

  // Remove the original tools
  $('#t-whatlinkshere, #t-recentchanges, #t-permalink, #t-info').remove();
});