MediaWiki:Gadget-defaultVisibilityToggles.js: diferenças entre revisões

m
- emitindo alerta
(novo)
 
m (- emitindo alerta)
"use strict";
 
var NavigationBarHide = "ocultar";
var NavigationBarShow = "exibir";
 
function checkAndSetToggleified(element) {
var text = jQuery(heading).text()
.toLowerCase()
// jQuery's .text() is inconsistent about whitespace:
.replace(/^\s+|\s+$/g, "").replace(/\s+/g, " ")
// remove numbers added by the "Auto-number headings" pref:
.replace(/^[1-9][0-9.]+ ?/, "");
if (/^[a-zA-Z0-9\s_-]+$/.test(text))
if (!(navHead && navContent))
return;
 
// Step 1, don't react when a subitem is clicked.
$(navHead).find("a").on("click", function (e) {
e.stopPropagation();
});
 
// Step 2, toggle visibility when bar is clicked.
var $navToggle = $("<a>").attr("role", "button").attr("tabindex", "0");
}
 
function setupHiddenQuotes(li) {
/* == View Switching == */
if (checkAndSetToggleified(li)) {
return;
}
var HQToggle, liComp, dl;
var HQShow = "citações";
var HQHide = "citações";
function show() {
HQToggle.html(HQHide);
$(li).children("ul").show();
}
function hide() {
HQToggle.html(HQShow);
$(li).children("ul").hide();
}
for (var k = 0; k < li.childNodes.length; k++) {
// Look at each component of the definition.
liComp = li.childNodes[k];
if (liComp.nodeName.toLowerCase() === "dl" && !dl) {
dl = liComp;
}
 
if (/^(ul|UL)$/.test(liComp.nodeName)) {
HQToggle = $("<a>").attr("role", "button").attr("tabindex", "0");
$(dl || liComp).before($("<span>").addClass("HQToggle").append(HQToggle));
HQToggle.on("click", window.VisibilityToggles.register("quotations", show, hide));
break;
}
}
}
 
function viewSwitching(rootElement) {
var $rootElement = $(rootElement);
var showButtonText = $rootElement.data("vs-showtext") || "mais";
var hideButtonText = $rootElement.data("vs-hidetext") || "menos";
var toSkip = $rootElement.find(".vsSwitcher").find("*");
e.stopPropagation();
});
 
// Add the toggle button.
var toggleButton = $("<a>").attr("role", "button").attr("tabindex", "0");
$("<span>").addClass("NavToggle").append(toggleButton).prependTo(toggleElement);
 
// Determine the visibility toggle category (for the links in the bar on the left).
var toggleCategory = $rootElement.data("toggle-category");
if (!toggleCategory) {
if (!toggleCategory)
toggleCategory = "others";
 
// Register the visibility toggle.
toggleElement.css("cursor", "pointer");
toggleElement.on("click", window.VisibilityToggles.register(toggleCategory,
}
 
/* ==List switching== */
window.listSwitcherRowCount = window.listSwitcherRowCount || 3;
 
var $rootElement = $(rootElement);
var $termList = $rootElement.find(".term-list");
// Find the element to place the toggle button in.
var $toggleElement = $rootElement.find(".list-switcher-element");
var columnCount = parseInt($termList.data("column-count"), 10);
if (!(columnCount && columnCount > 0)) {
var $listItems = $rootElement.find("ul").first().find("li");
var $toHide = getListItemsToHide($listItems, columnCount, rowsInShowState);
 
// Don't do anything if there aren't any items to hide.
if ($toHide.length === 0) {
$toggleElement.hide();
$toggleElement.css("cursor", "pointer");
// Add the toggle button.
var $toggleButton = $("<a>").attr("role", "button").attr("tabindex", "0");
$navToggle.css(rootBackgroundColor ? "background-color" : "background",
rootBackgroundColor || rootBackground);
 
// The $toggleElement becomes clickable in its entirety, but
// we need to prevent this if a contained link is clicked instead.
$toggleElement.children("a").on("click", function (e) {
e.stopPropagation();
});
 
var toggleCategory = $rootElement.data("toggle-category")
|| getToggleCategory($rootElement[0], "other lists");
var showButtonText = $toggleElement.data("showtext") || "mais";
var hideButtonText = $toggleElement.data("hidetext") || "menos";
// Determine the text for the $toggleButton.
 
var showButtonText = $toggleElement.data("showtext") || "mais ᐯ";
var hideButtonText = $toggleElement.data("hidetext") || "menos ᐱ";
// Register the visibility toggle.
$toggleElement.on("click", window.VisibilityToggles.register(toggleCategory,
function show() {
$toHide.hide();
}));
 
// Add the toggle button to the DOM tree.
$navToggle.append($toggleButton).prependTo($toggleElement);
$toggleElement.show();
window.getToggleCategory = getToggleCategory;
 
/* == Apply four functions defined above == */
mw.hook('wikipage.content').add(function($content) {
// NavToggles
createNavToggle(this);
});
 
//quotes
if (mw.config.get('wgNamespaceNumber') === 0) {
// First, find all the ordered lists, i.e. all the series of definitions.
$('ol > li', $content).each(function(){
setupHiddenQuotes(this);
}
 
//view switching
$('.vsSwitcher', $content).each(function(){
viewSwitching(this);
});
 
// list switching
$(".list-switcher", $content).each(function () {
enableListSwitch(this, window.listSwitcherRowCount);