MediaWiki:Gadget-ShowNavbarInNavbox.js

Z Wikipedie, otevřené encyklopedie

Poznámka: Po uložení musíte vyprázdnit mezipaměť vašeho prohlížeče, jinak změny neuvidíte.

/**
 * "Navbar" - tlačítka pro práci se šablonou u navigačních šablon
 * 
 * dependencies:
 *   mediawiki.Title
 * 
 * @author [[User:Danny B.]]
 */
$(function() {
  $("div.navbox").each(function(index) {
    title = $(this).attr("title");
    if(title) {
      try {
      	subjectTitle = new mw.Title("Šablona:" + title);
	      talkTitle = new mw.Title("Diskuse k šabloně:" + title);
      } catch (e) {
      	// Error: Unable to parse title
      	return;
      }
      navbar =
        $("<div>", {
          class: "navbox-navbar"
        })
        .append($("<a>", {
          href: subjectTitle.getUrl(),
          title: "zobrazit " + subjectTitle.getPrefixedText(),
          text: "z"
        }))
        .append(" • ")
        .append($("<a>", {
          href: talkTitle.getUrl(),
          title: "zobrazit " + talkTitle.getPrefixedText(),
          text: "d"
        }))
        .append(" • ")
        .append($("<a>", {
          href: subjectTitle.getUrl() + "?action=edit",
          title: "editovat " + subjectTitle.getPrefixedText(),
          text: "e"
        }))
      ;
    } else {
      navbar =
        $("<div>", {
          class: "navbox-navbar error",
          text: "CHYBA"
        })
      ;
    }
    $(this).find("th.navbox-title").first().prepend(navbar);
  });
});