Changes
Jump to navigation
Jump to search
Line 2:
Line 2:
− local dataset = 'Location map.tab'+
−
Line 163:
Line 162:
− +
+
+
+
− +
Line 181:
Line 183:
− +
Line 226:
Line 228:
− +
Line 280:
Line 282:
− +
+
Line 287:
Line 290:
− +
+
Line 305:
Line 309:
− +
− +
− local spanCss
− +
− +
− +
− spanCss = 'float:right'
− +
− spanCss = 'float:left'
− :css('display', 'inline')
− :cssText('padding:1px')
− :cssText(spanCss)
Line 462:
Line 460:
− +
From sandbox: use TemplateStyles to significantly reduce the post-expand include size
local p = {}
local p = {}
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local function round(n, decimals)
local function round(n, decimals)
end
end
end
end
local retval = args.float == 'center' and '<div class="center">' or ''
local retval = frame:extensionTag{name = 'templatestyles', args = {src = 'Template:Location map/styles.css'}}
if args.float == 'center' then
retval = retval .. '<div class="center">'
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="noviewer thumb '
retval = retval .. '<div class="locmap noviewer 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'
retval = retval .. '"><div style="position:relative;width:' .. width .. 'px' .. (args.border ~= 'none' and ';border:1px solid lightgray">' or '">')
retval = retval .. '"><div style="position:relative;width:' .. width .. 'px' .. (args.border ~= 'none' and ';border:1px solid lightgray">' or '">')
else
else
retval = retval .. '<div style="width:' .. width .. 'px;'
retval = retval .. '<div class="locmap" style="width:' .. width .. 'px;'
if args.float == '"left"' or args.float == 'left' then
if args.float == '"left"' or args.float == 'left' then
retval = retval .. 'float:left;clear:left'
retval = retval .. 'float:left;clear:left'
if not args.caption or args.border == 'infobox' then
if not args.caption or args.border == 'infobox' then
if args.border then
if args.border then
retval = retval .. '<div>'
retval = retval .. '<div style="padding-top:0.2em">'
else
else
retval = retval .. '<div style="font-size:90%;padding-top:3px">'
retval = retval .. '<div style="font-size:90%;padding-top:3px">'
local function markOuterDiv(x, y, imageDiv, labelDiv)
local function markOuterDiv(x, y, imageDiv, labelDiv)
return mw.html.create('div')
return mw.html.create('div')
:cssText('position:absolute;top:' .. round(y, 3) .. '%;left:' .. round(x, 3) .. '%')
:addClass('od')
:cssText('top:' .. round(y, 3) .. '%;left:' .. round(x, 3) .. '%')
:node(imageDiv)
:node(imageDiv)
:node(labelDiv)
:node(labelDiv)
local function markImageDiv(mark, marksize, label, link, alt, title)
local function markImageDiv(mark, marksize, label, link, alt, title)
local builder = mw.html.create('div')
local builder = mw.html.create('div')
:cssText('position:absolute;left:-' .. round(marksize / 2) .. 'px;top:-' .. round(marksize / 2) .. 'px;line-height:0')
:addClass('id')
:cssText('left:-' .. round(marksize / 2) .. 'px;top:-' .. round(marksize / 2) .. 'px')
:attr('title', title)
:attr('title', title)
if marksize ~= 0 then
if marksize ~= 0 then
local function markLabelDiv(label, label_size, label_width, position, background, x, marksize)
local function markLabelDiv(label, label_size, label_width, position, background, x, marksize)
if tonumber(label_size) == 0 then
if tonumber(label_size) == 0 then
return mw.html.create('div'):cssText('font-size:0%;position:absolute'):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('font-size:' .. label_size .. '%;line-height:110%;position:absolute;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 == 'top' then -- specified top
if position == 'top' then -- specified top
builder:cssText('bottom:' .. distance .. 'px;left:' .. (-label_width / 2) .. 'em;text-align:center')
builder:addClass('pv'):cssText('bottom:' .. distance .. 'px;left:' .. (-label_width / 2) .. 'em')
elseif position == 'bottom' then -- specified bottom
elseif position == 'bottom' then -- specified bottom
builder:cssText('top:' .. distance .. 'px;left:' .. (-label_width / 2) .. 'em;text-align:center')
builder:addClass('pv'):cssText('top:' .. distance .. 'px;left:' .. (-label_width / 2) .. 'em')
elseif position == 'left' or (tonumber(x) > 70 and position ~= 'right') then -- specified left or autodetected to left
elseif position == 'left' or (tonumber(x) > 70 and position ~= 'right') then -- specified left or autodetected to left
builder:cssText('top:-0.75em;right:' .. distance .. 'px;text-align:right')
builder:addClass('pl'):cssText('right:' .. distance .. 'px')
else -- specified right or autodetected to right
else -- specified right or autodetected to right
builder:cssText('top:-0.75em;left:' .. distance .. 'px;text-align:left')
builder:addClass('pr'):cssText('left:' .. distance .. 'px')
end
end
builder = builder:tag('div')
builder = builder:tag('div')
:wikitext(label)
:wikitext(label)
if background then
if background then
mw.logObject(args, 'args')
mw.logObject(args, 'args')
if currentTitle.namespace == 0 then
if currentTitle.namespace == 0 then
local key = frame:preprocess('{{FULLPAGENAME}}')
local key = currentTitle.prefixedText
builder:wikitext('[[Category:Location maps with marks outside map and outside parameter not set|' .. key .. ' ]]')
builder:wikitext('[[Category:Location maps with marks outside map and outside parameter not set|' .. key .. ' ]]')
end
end