Modulo:Navbox/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m per test
Omega Bot (discussione | contributi)
m Bot: rimuovo no globals obsoleto
 
(10 versioni intermedie di un altro utente non mostrate)
Riga 3:
]]--
 
require('Modulo:No globalsstrict')
 
local getArgs = require('Modulo:Arguments').getArgs
Riga 48:
 
-- Con il debug ridefinisce il metodo mw.html:css,
-- permettendo di eseguire i test senza controllare anche iil cssCSS.
--
-- @param {table} tableNode
Riga 65:
-- Carica il CSS via TemplateStyles quando opportuno
local function loadCSS(name)
local prefix = isTemplatePage(name) and 'mobile-' or ''
local styles = 'Modulo:Navbox/sandbox/' .. prefix .. 'styles.css'
return mw.getCurrentFrame():extensionTag{
name = 'templatestyles',
Line 102 ⟶ 103:
self:_addTnavbar(thNode)
end
thNode:wikitext(if self.args.title) then
self:_addTitle(thNode)
end
-- eventuale riga per l'above
if self.args.above then
Line 133 ⟶ 136:
self.args.state == 'autocollapse' and 'autocollapse' or
not self.args.state and 'autocollapse' or nil)
:addClass('nowraplinks noprint metadata')
:addClass('noprint')
:addClass('metadata')
:attr('id', 'navbox-' .. (self.args.name or ''))
:cssText(self.args.style)
Line 152 ⟶ 153:
}
}
node:tag('div'):addClass('tnavbarnavbox_navbar'):wikitext(tnavbar)
end
 
-- Imposta il titolo del navbox dal parametro "title".
--
-- @param {table} node
function Navbox:_addTitle(node)
node:tag('span'):addClass('navbox_title'):wikitext(self.args.title)
end
 
Line 162 ⟶ 170:
self.tableNode
:tag('tr')
:tag('tdth')
:attr('colspan', self.args.image and '3' or '2')
:addClass('navbox-abovebelownavbox_abovebelow')
:cssText(argStyle)
:wikitext(arg)
Line 174 ⟶ 182:
-- @param {number} rowspan
function Navbox:_addImage(trNode, rowspan)
local tdStyle = {
['vertical-align'] = 'middle',
['padding-left'] = '7px',
width = '0%'
}
trNode
:tag('td')
:attr('rowspan', rowspan)
:cssaddClass(tdStyle'navbox_image')
:cssText(self.args.imagestyle)
:wikitext(self.args.image)
Line 190 ⟶ 193:
function Navbox:_addLists()
local rowIds, altStyle, altBackground
local thStyle = {
background = '#ddf',
['white-space'] = 'nowrap',
padding = '0 10px',
['font-size'] = '90%'
}
-- crea una riga per ogni groupN/listN
rowIds = getIds(self.args, true)
Line 204 ⟶ 201:
trNode:tag('th')
:attr('colspan', self.args['list' .. id] and '1' or '2')
:cssaddClass(thStyle'navbox_group')
:cssText(self.args.groupstyle)
:cssText(self.args['group' .. id .. 'style'])
Line 214 ⟶ 211:
if (i % 2) == 0 then
altStyle = self.args.evenstyle
altBackground = '#f7f7f7navbox_even'
else
altStyle = self.args.oddstyle
altBackground = nil'navbox_odd'
end
trNode:tag('td')
:attr('colspan', self.args['group' .. id] and '1' or '2')
:cssaddClass('width', '100%navbox_list')
:cssaddClass('text-align',not self.args['group' .. id] and 'leftnavbox_center' or 'center'nil)
:css('font-size', '90%')
:addClass('noprint'altBackground)
:css('text-align', self.args['group' .. id] and 'left' or 'center')
:css('background', altBackground)
:cssText(self.args.liststyle)
:cssText(altStyle)
Line 271 ⟶ 267:
-- Configura gli stili CSS della tabella.
function NavboxSubgroup:_setupTableNode()
local tableStyle = {
background = 'transparent',
['font-size'] = '100%',
padding = '0',
border = '0',
margin = '-3px',
width = '100%'
}
self.tableNode
:addClass('subnavbox nowraplinks')
:css(tableStyle)
:cssText(self.args.bodystyle)
end
Line 288 ⟶ 275:
function NavboxSubgroup:_addLists()
local listIds, altStyle
local thStyle = {
background = '#ddf',
padding = '0 10px',
}
-- crea una row per ogni listN
listIds = getIds(self.args)
Line 300 ⟶ 283:
if self.args['group' .. id] then
trNode:tag('th')
:cssaddClass(thStyle'subnavbox_group')
:cssText(self.args.groupstyle)
:wikitext(self.args['group' .. id])
Line 311 ⟶ 294:
trNode:tag('td')
:attr('colspan', self.args['group' .. id] and '1' or '2')
:cssaddClass('text-align',not self.args['group' .. id] and 'leftnavbox_center' or 'center'nil)
:cssText(self.args.liststyle)
:cssText(altStyle)
Line 331 ⟶ 314:
-- Funzione per l'utilizzo da un altro modulo.
function p._navbox_subgroup(args)
return loadCSS(args.name) .. NavboxSubgroup:new(args):getHTML()
end