Module:Location map and Module:Location map/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
Per edit request |
Marat Turaev (talk | contribs) No edit summary |
||
Line 173: | Line 173: | ||
end |
end |
||
end |
end |
||
local retval = frame:extensionTag{name = 'templatestyles', args = {src = 'Module:Location map/styles.css'}} |
local retval = frame:extensionTag{name = 'templatestyles', args = {src = 'Module:Location map/sandbox/styles.css'}} |
||
if args.float == 'center' then |
if args.float == 'center' then |
||
retval = retval .. '<div class="center">' |
retval = retval .. '<div class="center">' |
||
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 noresize thumb ' |
retval = retval .. '<div class="locmap noviewer' .. (args.noresize ~= false and ' noresize' or '') .. ' 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 291: | Line 291: | ||
end |
end |
||
local function markOuterDiv(x, y, imageDiv, labelDiv |
local function markOuterDiv(x, y, imageDiv, labelDiv) |
||
return mw.html.create('div') |
return mw.html.create('div') |
||
:addClass('od') |
:addClass('od') |
||
:addClass('notheme') -- T236137 |
:addClass('notheme') -- T236137 |
||
:cssText('top:' .. round(y, 3) .. '%;left:' .. round(x, 3) |
:cssText('top:' .. round(y, 3) .. '%;left:' .. round(x, 3) .. '%') |
||
:node(imageDiv) |
:node(imageDiv) |
||
:node(labelDiv) |
:node(labelDiv) |
||
Line 319: | Line 319: | ||
end |
end |
||
local function markLabelDiv(label, label_size, label_width, position, background, x, marksize) |
local function markLabelDiv(label, label_size, label_width, position, background, x, marksize, top, compact) |
||
if tonumber(label_size) == 0 then |
if tonumber(label_size) == 0 then |
||
return mw.html.create('div'):addClass('l0'):wikitext(label) |
return mw.html.create('div'):addClass('l0'):wikitext(label) |
||
end |
end |
||
local builder = mw.html.create('div') |
local builder = mw.html.create('div') |
||
:cssText('width:' .. label_width .. 'em') |
:cssText('font-size:' .. label_size .. '%;width:' .. label_width .. 'em') |
||
local distance = round(marksize / 2 + 1) |
local distance = round(marksize / 2 + 1) |
||
if position == ' |
if position == 'center' then -- specified center |
||
builder:addClass(' |
builder:addClass('pc'):cssText('left:' .. (-label_width / 2) .. 'em') |
||
elseif position == 'top' then -- specified top |
|||
⚫ | |||
elseif position == 'bottom' then -- specified bottom |
elseif position == 'bottom' then -- specified bottom |
||
builder:addClass('pv'):cssText('top:' .. distance .. 'px;left:' .. (-label_width / 2) .. 'em') |
builder:addClass(compact and 'pvc' or 'pv'):cssText('top:' .. distance .. 'px;left:' .. (-label_width / 2) .. 'em') |
||
else |
|||
if position == 'left' or (tonumber(x) > 70 and position ~= 'right') then -- specified left or autodetected to left |
|||
⚫ | |||
⚫ | |||
else -- specified right or autodetected to right |
|||
⚫ | |||
builder:addClass(compact and 'prc' or 'pr'):cssText('left:' .. distance .. 'px') |
|||
end |
|||
if top then |
|||
builder:cssText('top:' .. top .. 'em') |
|||
end |
|||
end |
end |
||
builder = builder:tag('div') |
builder = builder:tag('div') -- not 'span' to avoid Linter errors if the label contains block content |
||
:wikitext(label) |
:wikitext(label) |
||
if background then |
if background then |
||
Line 360: | Line 367: | ||
end |
end |
||
function p.mark(frame, args, map) |
function p.mark(frame, args, map, ...) |
||
if not args then |
if not args then |
||
args = getArgs(frame, {wrappers = 'Template:Location map~'}) |
args = getArgs(frame, {wrappers = 'Template:Location map~'}) |
||
Line 388: | Line 395: | ||
return table.concat(outputs, '#PlaceList#') .. '#PlaceList#' |
return table.concat(outputs, '#PlaceList#') .. '#PlaceList#' |
||
end |
end |
||
local containerArgs = ... |
|||
local x, y, longitude, latitude |
local x, y, longitude, latitude |
||
longitude = decdeg(args.lon_deg, args.lon_min, args.lon_sec, args.lon_dir, args.long, 'longitude') |
longitude = decdeg(args.lon_deg, args.lon_min, args.lon_sec, args.lon_dir, args.long, 'longitude') |
||
Line 494: | Line 502: | ||
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, label_size, args.label_width or 6, args.position, args.background, x, marksize) |
labelDiv = markLabelDiv(args.label, args.label_size or 91, args.label_width or 6, args.position, args.background, x, marksize, args.label_top, containerArgs and containerArgs.CompactLabels) |
||
end |
end |
||
return builder:node(markOuterDiv(x, y, imageDiv, labelDiv |
return builder:node(markOuterDiv(x, y, imageDiv, labelDiv)) |
||
end |
end |
||