Jump to content

Module:Sandbox/Dat Hack3r: Difference between revisions

Dat Hack3r (talk | contribs)
m Integrated "prepad" and "postpad" for seamless hidden spacing in navigation.
Dat Hack3r (talk | contribs)
m Forgot to add the colon (":") after the namespace.
 
(5 intermediate revisions by the same user not shown)
Line 20: Line 20:
if i < s_start then
if i < s_start then
prepad = prepad..'<span style="visibility: hidden;"> • '..string.format(text_format, i)..'</span>'
prepad = prepad..'<span style="visibility: hidden;"> • '..string.format(text_format, i)..'</span>'
elseif i > s_end then
elseif s_end and i > s_end then
postpad = postpad..'<span style="visibility: hidden;"> • '..string.format(text_format, i)..'</span>'
postpad = postpad..'<span style="visibility: hidden;"> • '..string.format(text_format, i)..'</span>'
else
else
if mw.title.new(string.format(title_format, i), title.namespace).exists then
if mw.title.new(string.format(title_format, i), title.namespace).exists then
table.insert(navlist, '[['..title.namespace..string.format(title_format, i)..'|'..string.format(text_format, i)..']]')
table.insert(navlist, '[['..title.nsText..':'..string.format(title_format, i)..'|'..string.format(text_format, i)..']]')
else
else
table.insert(navlist, '<span class="seriesNavigation-item-inactive">'..string.format(text_format, i)..'</span>')
table.insert(navlist, '<span class="seriesNavigation-item-inactive">'..string.format(text_format, i)..'</span>')
Line 30: Line 30:
end
end
end
end
navlist[1] = prepad..navlist[1]
navlist[#navlist] = navlist[#navlist]..postpad


local templatestyles = mw.getCurrentFrame():extensionTag{
local templatestyles = mw.getCurrentFrame():extensionTag{
Line 35: Line 37:
args = {src = 'Module:Series navigation/styles.css'}
args = {src = 'Module:Series navigation/styles.css'}
}
}
return templatestyles..'<div class="toccolours seriesNavigation" role="navigation" aria-label="Range">'..prepad..horizontal(navlist)..postpad..'</div>'
return templatestyles..'<div class="toccolours seriesNavigation" role="navigation" aria-label="Range">'..horizontal(navlist)..'</div>'
end
end


function p.main(frame)
function p.main(frame)
local s_start      = frame:getParent().args['start'] or 1
local s_start      = tonumber(frame:getParent().args['start']) or 1
local s_end        = frame:getParent().args['end']
local s_end        = tonumber(frame:getParent().args['end'])
local increment    = frame:getParent().args['increment'] or 1
local increment    = tonumber(frame:getParent().args['increment']) or 1
local title        = mw.title.getCurrentTitle()
local title        = mw.title.getCurrentTitle()
local title_format = frame:getParent().args['title_format']
local title_format = frame:getParent().args['title_format']