Module:Multiple image: Difference between revisions

didn't fix Scarfy. I found a workaround though. Reverting back to the second revision, which is tested and works well on every page {{Multiple image}} is used except Scarfy.
(merge the rest of the newer code, except the templatestyles load. let's see if it fixes Scarfy)
(didn't fix Scarfy. I found a workaround though. Reverting back to the second revision, which is tested and works well on every page {{Multiple image}} is used except Scarfy.)
 
Line 7: Line 7:
local function isnotempty(s)
local function isnotempty(s)
return s and s:match( '^%s*(.-)%s*$' ) ~= ''
return s and s:match( '^%s*(.-)%s*$' ) ~= ''
end
local function removepx(s)
return tostring(s or ''):match('^(.*)[Pp][Xx]%s*$') or s
end
end


Line 49: Line 45:
local captiondiv = root:tag('div')
local captiondiv = root:tag('div')
captiondiv:addClass('thumbcaption')
captiondiv:addClass('thumbcaption')
captiondiv:css('clear', 'left')
if isnotempty(textalign) then
if isnotempty(textalign) then
captiondiv:addClass('text-align-' .. textalign)
captiondiv:css('text-align', textalign)
end
end
captiondiv:wikitext(caption)
captiondiv:wikitext(caption)
Line 93: Line 90:
local pargs = frame:getParent().args
local pargs = frame:getParent().args
local args = frame.args
local args = frame.args
local width = removepx(pargs['width'] or '')
local width = pargs['width'] or ''
local dir = pargs['direction'] or ''
local dir = pargs['direction'] or ''
local border = pargs['border'] or args['border'] or ''
local border = pargs['border'] or args['border'] or ''
local align = pargs['align'] or args['align'] or (border == 'infobox' and 'center' or '')
local align = pargs['align'] or args['align'] or (border == 'infobox' and 'center' or '')
local capalign = pargs['caption_align'] or args['caption_align'] or ''
local capalign = pargs['caption_align'] or args['caption_align'] or ''
local totalwidth = removepx(pargs['total_width'] or args['total_width'] or '')
local totalwidth = pargs['total_width'] or args['total_width'] or ''
local imgstyle = pargs['image_style'] or args['image_style']
local imgstyle = pargs['image_style'] or args['image_style']
local header = pargs['header'] or pargs['title'] or ''
local header = pargs['header'] or pargs['title'] or ''
Line 218: Line 215:
root:addClass('thumb')
root:addClass('thumb')
root:addClass('tmulti')
root:addClass('tmulti')
-- root:addClass('tmulti-sandbox')
root:addClass(thumbclass[align] or 'tright')
root:addClass(thumbclass[align] or 'tright')


if( align == 'center' or align == 'centre' ) then
if( align == 'center' or align == 'centre' ) then
root:addClass('center')
root:addClass('center')
end
if( pargs['margin_top'] or args['margin_top']) then
root:css('margin-top', pargs['margin_top'] or args['margin_top'])
end
if( pargs['margin_bottom'] or args['margin_bottom']) then
root:css('margin-bottom', pargs['margin_bottom'] or args['margin_bottom'])
end
end
if( bg ~= '' ) then
if( bg ~= '' ) then
Line 241: Line 243:
if( isnotempty(header) ) then
if( isnotempty(header) ) then
div:tag('div')
div:tag('div')
:addClass('trow')
:css('clear', 'both')
:tag('div')
:css('font-weight', 'bold')
:addClass('theader')
:css('text-align', pargs['header_align'] or 'center')
:css('text-align', pargs['header_align'])
:css('background-color', pargs['header_background'] or 'transparent')
:css('background-color', pargs['header_background'])
:wikitext(header)
:wikitext(header)
end
end
-- loop through the images
-- loop through the images
local k = 0
local k = 0
for r=1,rowcount do
for r=1,rowcount do
local rowdiv = div:tag('div'):addClass('trow');
for j=1,perrow[r] do
for j=1,perrow[r] do
k = k + 1
k = k + 1
if( k <= imagecount ) then
if( k <= imagecount ) then
local imagediv = rowdiv:tag('div')
local imagediv = div:tag('div')
imagediv:addClass('tsingle')
imagediv:addClass('tsingle')
if dir ~= 'vertical' then
imagediv:css('float', 'left')
end
if bg ~= '' then
if bg ~= '' then
imagediv:css('background-color', bg);
imagediv:css('background-color', bg);
end
end
imagediv:css('margin', '1px')
if ((imagegap > 1) and (j < perrow[r])) then
if ((imagegap > 1) and (j < perrow[r])) then
imagediv:css('margin-right', tostring(imagegap) .. 'px')
imagediv:css('margin-right', tostring(imagegap) .. 'px')
Line 272: Line 276:
pargs['thumbtime' .. i], pargs['caption' .. i], capalign, imgstyle))
pargs['thumbtime' .. i], pargs['caption' .. i], capalign, imgstyle))
end
end
end
-- only float content gives a parent height:0, so add a clearing div
if dir ~= 'vertical' then
div:tag('div')
:css('clear', 'left')
end
end
end
end
-- add the footer
-- add the footer
if( isnotempty(footer) ) then
if( isnotempty(footer) ) then
local falign = string.lower(pargs['footer_align'] or args['footer_align'] or 'left')
falign = (falign == 'centre') and 'center' or falign
div:tag('div')
div:tag('div')
:addClass('trow')
:addClass('thumbcaption')
:css('display', (falign ~= 'left') and 'flow-root' or 'flex')
:css('clear', 'left')
:tag('div')
:css('text-align', pargs['footer_align'] or args['footer_align'] or 'left')
:addClass('thumbcaption')
:css('background-color', pargs['footer_background'] or 'transparent')
:css('text-align', (falign ~= 'left') and falign or nil)
:wikitext(footer)
:css('background-color', pargs['footer_background'])
:wikitext(footer)
end
end
return tostring(root)
return tostring(root)
25,771

edits