Automoderated users, autopatrol
25,771
edits
Pandakekok9 (talk | contribs) (merge the rest of the newer code, except the templatestyles load. let's see if it fixes Scarfy) |
Pandakekok9 (talk | contribs) (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 | 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: | 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 = | 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 = | 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(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') | ||
: | :css('clear', 'both') | ||
: | :css('font-weight', 'bold') | ||
:css('text-align', pargs['header_align'] or 'center') | |||
:css('background-color', pargs['header_background'] or 'transparent') | |||
: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 | ||
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 = | 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 | ||
div:tag('div') | div:tag('div') | ||
:addClass(' | :addClass('thumbcaption') | ||
:css(' | :css('clear', 'left') | ||
:css('text-align', pargs['footer_align'] or args['footer_align'] or 'left') | |||
:css('background-color', pargs['footer_background'] or 'transparent') | |||
:wikitext(footer) | |||
end | end | ||
return tostring(root) | return tostring(root) |