Modulo:Navbox: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
aggiunto modulo No globals |
aggiornato all'uso degli apici singoli, virgolette e singolo underscore |
||
Riga 4:
]]
require(
local getArgs = require(
-- Configurazione
local cfg = mw.loadData(
-------------------------------------------------------------------------------
Riga 20:
if not ret then
local id = name:match(
name:match(
if id then
ret = tonumber(id) <= maxList
Riga 38:
for k, v in pairs(args) do
if type(k) ==
ret[k] = v
end
Riga 51:
for k, v in pairs(args) do
local id = k:match(
if id then
table.insert(ret, tonumber(id))
Riga 78:
local thNode
local thStyle = {
[
width =
background =
[
}
setmetatable(self, { __index = Navbox
self.args = args
-- costruzione table
self.tableNode = mw.html.create(
if self.args.debug then
disableCSS(self.tableNode)
end
self:
-- prima row: contiene la navbar e il titolo
thNode = self.tableNode:tag(
:tag(
:attr(
:css(thStyle)
:cssText(self.args.titlestyle)
if self.args.navbar ~=
self:
end
if self.args.title then
self:
end
-- eventuale row per l'above
if self.args.above then
self:
end
-- altre row
self:
-- eventuale row finale per il below
if self.args.below then
self:
end
Line 119 ⟶ 118:
end
function Navbox:
return tostring(self.tableNode)
end
function Navbox:
local tableStyle = {
margin =
width =
clear =
border =
padding =
}
self.tableNode
:addClass(
:addClass(
:addClass(self.args.state ==
(self.args.state ==
(not self.args.state and
:addClass(
:addClass(
:addClass(
:css(tableStyle)
:cssText(self.args.style)
Line 145 ⟶ 144:
end
function Navbox:
local divStyle = {
float =
width =
[
padding =
margin =
}
local tnavbar = mw.getCurrentFrame():expandTemplate {
title =
args = {
[1] = self.args.name,
[
}
}
node:tag(
end
function Navbox:
node:tag(
end
function Navbox:
local tdStyle = {
background =
[
[
}
self.tableNode
:tag(
:tag(
:attr(
:css(tdStyle)
:cssText(argStyle)
Line 182 ⟶ 181:
end
function Navbox:
local tdStyle = {
[
[
width =
}
trNode
:tag(
:attr(
:css(tdStyle)
:cssText(self.args.imagestyle)
Line 196 ⟶ 195:
end
function Navbox:
local listIds, altStyle, altBackground
local thStyle = {
background =
[
padding =
[
}
-- crea una row per ogni listN
listIds = getListIds(self.args)
for _, id in ipairs(listIds) do
local trNode = self.tableNode:tag(
-- i groupN sono visibili solo se c'è la corrispettiva listN
if self.args[
trNode:tag(
:css(thStyle)
:cssText(self.args.groupstyle)
:cssText(self.args[
:wikitext(self.args[
end
if (id % 2) == 0 then
altStyle = self.args.evenstyle
altBackground =
else
altStyle = self.args.oddstyle
altBackground = nil
end
trNode:tag(
:attr(
:css(
:css(
:css(
:css(
:cssText(self.args.liststyle)
:cssText(altStyle)
:cssText(self.args[
:wikitext(self.args[
if id == 1 and self.args.image then
self:
end
end
Line 248 ⟶ 247:
local self = {}
setmetatable(self, { __index = NavboxSubgroup
self.args = args
-- costruzione table
self.tableNode = mw.html.create(
if self.args.debug then
disableCSS(self.tableNode)
end
self:
self:
return self
end
function NavboxSubgroup:
return tostring(self.tableNode)
end
function NavboxSubgroup:
local tableStyle = {
background =
[
padding =
border =
margin =
width =
}
self.tableNode
:addClass(
:addClass(
:css(tableStyle)
:cssText(self.args.bodystyle)
end
function NavboxSubgroup:
local listIds, altStyle
local thStyle = {
background =
padding =
}
-- crea una row per ogni listN
listIds = getListIds(self.args)
for _, id in ipairs(listIds) do
local trNode = self.tableNode:tag(
-- i groupN sono visibili solo se c'è la corrispettiva listN
if self.args[
trNode:tag(
:css(thStyle)
:cssText(self.args.groupstyle)
:wikitext(self.args[
end
if (id % 2) == 0 then
Line 304 ⟶ 302:
altStyle = self.args.oddstyle
end
trNode:tag(
:attr(
:css(
:cssText(self.args.liststyle)
:cssText(altStyle)
:wikitext(self.args[
end
end
Line 320 ⟶ 318:
function p._navbox(args)
return Navbox:new(parseArgs(args)):getHTML()
end
function p._navbox_subgroup(args)
return NavboxSubgroup:new(parseArgs(args, true)):getHTML()
end
|