79 548
contributi
(Creata pagina con "--This module holds CSS-generating functions. Its main usefulness are reducing calls to Colore module and adding vendor prefixes -- local css = {} local str = requir...") |
(Added new functions *** sovrascritto il testo esistente ***) |
||
This module holds CSS-generating functions.
Its main usefulness are reducing calls to
Colore module and adding vendor prefixes
--]]
local w = require('Modulo:Wikilib')
local c = mw.loadData('Modulo:Colore/data')
-- Prepends a comma to non-empty strings only
local prependComma = function(text)
return text ~= '' and text .. ', ' or text
end
--[[
vendorMappings.gradient = {
moz = {
[''] = '',
['to right'] = 'left'
},
webkit = {
[''] = '',
['to right'] = 'left'
}
Empty first variants default to 'normal',
empty second variants default to first ones.
If the first argument isn't a known color
it is assumed that first and second arguments
are hexes
--]]
processInput.gradient = function(args)
local p = w.trimAll(args, true)
if not c[p[1]] then
return p[1], p[2]
end
local from = {
-- Generates styles for linear gradients
styles.gradient.linear = function(conf, from, to)
return string.interp('background-size: 100%; background-image: -moz-linear-gradient(${mozConf}
{
conf = prependComma(conf),
mozConf = prependComma(vendorMappings.gradient.moz[conf]),
webkitConf = prependComma(vendorMappings.gradient.webkit[conf]),
from = from,
to = to
})
end
Wikicode interface to generate
horizontal linear gradients styles
--]]
end
css.horizGrad, css.horiz_grad = css['horiz-grad'], css['horiz-grad']
--[[
Wikicode interface to generate
horizontal linear gradients styles
--]]
css['vert-grad'] = function(frame)
return styles.gradient.linear('',
processInput.gradient(mw.clone(frame.args)))
end
css.vertGrad, css.vert_grad = css['vert-grad'], css['vert-grad']
for name, funct in pairs(css) do
|