Differenze tra le versioni di "Modulo:Css"

500 byte aggiunti ,  04:02, 6 gen 2017
Added new functions *** sovrascritto il testo esistente ***
 
(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}, #${from}, #${to}); background-image: -webkit-gradient(linear, 0% 50%, 100% 50%, color-stop(0%, #${from}), color-stop(100%, #${to})); background-image: -webkit-linear-gradient(${webkitConf}, #${from}, #${to}); background-image: linear-gradient(${conf}, #${from}, #${to});',
{
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
79 548

contributi