Modifica di Modulo:Side box

Vai alla navigazione Vai alla ricerca
Attenzione: non hai effettuato l'accesso. Se effettuerai delle modifiche il tuo indirizzo IP sarà visibile pubblicamente. Se accedi o crei un'utenza, le tue modifiche saranno attribuite al tuo nome utente, insieme ad altri benefici.

Questa modifica può essere annullata. Controlla le differenze mostrate sotto fra le due versioni per essere certo che il contenuto corrisponda a quanto desiderato, e quindi pubblicare le modifiche per completare la procedura di annullamento.

Versione attuale Il tuo testo
Riga 1: Riga 1:
-- This module implements {{side box}}.
local yesno = require('Module:Yesno')
local yesno = require('Module:Yesno')
local p = {}
local p = {}


local function makeData(args)
function p.main(frame)
local origArgs = frame:getParent().args
local args = {}
for k, v in pairs(origArgs) do
v = v:match('%s*(.-)%s*$')
if v ~= '' then
args[k] = v
end
end
return p._main(args)
end
 
function p._main(args)
local data = p.makeData(args)
return p.renderSidebox(data)
end
 
function p.makeData(args)
local data = {}
local data = {}


Riga 11: Riga 31:
end
end
if args.position and args.position:lower() == 'left' then
if args.position and args.position:lower() == 'left' then
table.insert(data.classes, 'side-box-left')
table.insert(data.classes, 'mbox-small-left')
else
else
table.insert(data.classes, 'side-box-right')
table.insert(data.classes, 'mbox-small')
end
end
if args.collapsible then
table.insert(data.classes, 'mw-collapsible')
if args.collapsible == "collapsed" then
table.insert(data.classes, 'mw-collapsed')
end
data.collapsible = true
end
table.insert(data.classes, args.class)
table.insert(data.classes, args.class)
Riga 33: Riga 44:
-- Copy over data that does not need adjusting
-- Copy over data that does not need adjusting
local argsToCopy = {
local argsToCopy = {
-- aria qualities
'role',
'labelledby',
-- Classes
-- Classes
'textclass',
'textclass',


-- Styles
-- Styles
'style',
'style',
'textstyle',
'textstyle',
'templatestyles',


-- Above row
-- Above row
Riga 64: Riga 69:
end
end


local function renderSidebox(data)
function p.renderSidebox(data)
-- Renders the sidebox HTML.
-- Renders the sidebox HTML.


-- Table root
-- Table root
local root = mw.html.create('div')
local root = mw.html.create('table')
root:attr('role', data.role)
root:attr('role', 'presentation')
:attr('aria-labelledby', data.labelledby)
:addClass('side-box')
for i, class in ipairs(data.classes or {}) do
for i, class in ipairs(data.classes or {}) do
root:addClass(class)
root:addClass(class)
end
end
root:css{border = '1px solid #aaa', ['background-color'] = '#f9f9f9', color = '#000'}
if data.style then
if data.style then
root:cssText(data.style)
root:cssText(data.style)
Riga 81: Riga 85:
-- The "above" row
-- The "above" row
if data.above then
if data.above then
local above = root:newline():tag('div')
local aboveCell = root:newline():tag('tr'):tag('td')
above:addClass('side-box-abovebelow')
aboveCell
:newline()
:attr('colspan', data.imageright and 3 or 2)
:wikitext(data.above)
:addClass('mbox-text')
if data.textstyle then
if data.textstyle then
above:cssText(data.textstyle)
aboveCell:cssText(data.textstyle)
end
end
if data.abovestyle then
if data.abovestyle then
above:cssText(data.abovestyle)
aboveCell:cssText(data.abovestyle)
end
end
aboveCell
:newline()
:wikitext(data.above)
end
end


-- The body row
-- The body row
local body = root:newline():tag('div')
local bodyRow = root:newline():tag('tr'):newline()
body:addClass('side-box-flex')
:addClass(data.collapsible and 'mw-collapsible-content')
:newline()
if data.image then
if data.image then
body:tag('div')
bodyRow:tag('td')
:addClass('side-box-image')
:addClass('mbox-image')
:wikitext(data.image)
:wikitext(data.image)
else
bodyRow:tag('td'):css('width', '1px')
end
end
local text = body:newline():tag('div')
local textCell = bodyRow:newline():tag('td')
text:addClass('side-box-text')
textCell:addClass('mbox-text')
:addClass(data.textclass or 'plainlist')
textCell:addClass(data.textclass or 'plainlist')
if data.textstyle then
if data.textstyle then
text:cssText(data.textstyle)
textCell:cssText(data.textstyle)
end
end
text:wikitext(data.text)
textCell:wikitext(data.text)
if data.imageright then
if data.imageright then
body:newline():tag('div')
bodyRow:newline():tag('td')
:addClass('side-box-imageright')
:addClass('mbox-imageright')
:wikitext(data.imageright)
:wikitext(data.imageright)
end
end
Riga 118: Riga 124:
-- The below row
-- The below row
if data.below then
if data.below then
local below = root:newline():tag('div')
local belowCell = root:newline():tag('tr'):tag('td')
below
belowCell
:addClass('side-box-abovebelow')
:attr('colspan', data.imageright and 3 or 2)
:wikitext(data.below)
:addClass('mbox-text')
if data.textstyle then
if data.textstyle then
below:cssText(data.textstyle)
belowCell:cssText(data.textstyle)
end
end
belowCell:wikitext(data.below)
end
end


root:newline()
root:newline()
local frame = mw.getCurrentFrame()
return tostring(root)
local templatestyles = ''
if data.templatestyles then
templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = data.templatestyles }
}
end
return frame:extensionTag{
name = 'templatestyles', args = { src = 'Module:Side box/styles.css' }
} .. templatestyles .. tostring(root)
end
 
function p._main(args)
local data = makeData(args)
return renderSidebox(data)
end
 
function p.main(frame)
local origArgs = frame:getParent().args
local args = {}
for k, v in pairs(origArgs) do
v = v:match('%s*(.-)%s*$')
if v ~= '' then
args[k] = v
end
end
return p._main(args)
end
end


return p
return p
Per favore tieni presente che tutti i contributi a Tematiche di genere si considerano pubblicati nei termini d'uso della licenza Creative Commons Attribuzione-Condividi allo stesso modo (vedi Tematiche di genere:Copyright per maggiori dettagli). Se non desideri che i tuoi testi possano essere modificati e ridistribuiti da chiunque senza alcuna limitazione, non inviarli qui.
Inviando il testo dichiari inoltre, sotto tua responsabilità, che è stato scritto da te personalmente oppure è stato copiato da una fonte di pubblico dominio o similarmente libera. Non inviare materiale protetto da copyright senza autorizzazione!
Annulla Guida (si apre in una nuova finestra)

Template utilizzato in questa pagina: