Module:Location map: Difference between revisions

No edit summary
and the other two places
Line 1: Line 1:
--require('strict')
require('strict')


local p = {}
local p = {}
Line 135: Line 135:
if args.AlternativeMap then
if args.AlternativeMap then
return args.AlternativeMap
return args.AlternativeMap
elseif args.relief and map('image1') ~= '' then
elseif args.relief then
return map('image1')
        local digits = mw.ustring.match(args.relief,'^[1-9][0-9]?$') or '1' -- image1 to image99
else
        if map('image' .. digits) ~= '' then
return map('image')
            return map('image' .. digits)
        end
end
end
    return map('image')
end
end


Line 176: Line 178:
end
end
if args.caption and args.caption ~= '' and args.border ~= 'infobox' then
if args.caption and args.caption ~= '' and args.border ~= 'infobox' then
retval = retval .. '<div class="locmap noviewer thumb '
retval = retval .. '<div class="locmap noresize thumb '
if args.float == '"left"' or args.float == 'left' then
if args.float == '"left"' or args.float == 'left' then
retval = retval .. 'tleft'
retval = retval .. 'tleft'
Line 207: Line 209:
local currentTitle = mw.title.getCurrentTitle()
local currentTitle = mw.title.getCurrentTitle()
retval = string.format(
retval = string.format(
'%s[[File:%s|%spx|%s%s|class=notpageimage]]',
'%s[[File:%s|%spx|%s%s|class=notpageimage noviewer]]',
retval,
retval,
image,
image,
Line 220: Line 222:
end
end
if args.overlay_image then
if args.overlay_image then
return retval .. '<div style="position:absolute;top:0;left:0">[[File:' .. args.overlay_image .. '|' .. width .. 'px|class=notpageimage]]</div>'
return retval .. '<div style="position:absolute;top:0;left:0">[[File:' .. args.overlay_image .. '|' .. width .. 'px|class=notpageimage noviewer]]</div>'
else
else
return retval
return retval
Line 289: Line 291:
end
end


local function markOuterDiv(x, y, imageDiv, labelDiv)
local function markOuterDiv(x, y, imageDiv, labelDiv, label_size)
return mw.html.create('div')
return mw.html.create('div')
:addClass('od')
:addClass('od')
:cssText('top:' .. round(y, 3) .. '%;left:' .. round(x, 3) .. '%')
:addClass('notheme') -- T236137
:cssText('top:' .. round(y, 3) .. '%;left:' .. round(x, 3) .. '%;font-size:' .. label_size .. '%')
:node(imageDiv)
:node(imageDiv)
:node(labelDiv)
:node(labelDiv)
Line 304: Line 307:
if marksize ~= 0 then
if marksize ~= 0 then
builder:wikitext(string.format(
builder:wikitext(string.format(
'[[File:%s|%dx%dpx|%s|link=%s%s|class=notpageimage]]',
'[[File:%s|%dx%dpx|%s|link=%s%s|class=notpageimage noviewer]]',
mark,
mark,
marksize,
marksize,
Line 321: Line 324:
end
end
local builder = mw.html.create('div')
local builder = mw.html.create('div')
:cssText('font-size:' .. label_size .. '%;width:' .. label_width .. 'em')
:cssText('width:' .. label_width .. 'em')
local distance = round(marksize / 2 + 1)
local distance = round(marksize / 2 + 1)
if position == 'top' then -- specified top
if position == 'top' then -- specified top
Line 491: Line 494:
local marksize = tonumber(args.marksize) or tonumber(map('marksize')) or 8
local marksize = tonumber(args.marksize) or tonumber(map('marksize')) or 8
local imageDiv = markImageDiv(mark, marksize, args.label or mw.title.getCurrentTitle().text, args.link or '', args.alt, args[2])
local imageDiv = markImageDiv(mark, marksize, args.label or mw.title.getCurrentTitle().text, args.link or '', args.alt, args[2])
local label_size = args.label_size or 91
local labelDiv
local labelDiv
if args.label and args.position ~= 'none' then
if args.label and args.position ~= 'none' then
labelDiv = markLabelDiv(args.label, args.label_size or 91, args.label_width or 6, args.position, args.background, x, marksize)
labelDiv = markLabelDiv(args.label, label_size, args.label_width or 6, args.position, args.background, x, marksize)
end
end
return builder:node(markOuterDiv(x, y, imageDiv, labelDiv))
return builder:node(markOuterDiv(x, y, imageDiv, labelDiv, label_size))
end
end