Module:Sidebar and Module:Sidebar/sandbox: Difference between pages
(Difference between pages)
imported>Jdlrobson Fixes https://phabricator.wikimedia.org/F54694313 |
imported>Sapphaline this doesn't even look that bad even though i just replaced all table elements with div |
||
| Line 1: | Line 1: | ||
require('strict') | require('strict') | ||
local cfg = mw.loadData('Module:Sidebar/configuration') | local cfg = mw.loadData('Module:Sidebar/configuration/sandbox') | ||
local p = {} | local p = {} | ||
| Line 127: | Line 127: | ||
end | end | ||
return templatestyles_markers | return templatestyles_markers | ||
end | |||
local function add_notpageimage_class(image_arg) | |||
if string.match(image_arg, '^%[%[File:') or string.match(image_arg, '^%[%[Image:') then | |||
image_arg = mw.text.trim(image_arg) | |||
if image_arg:find('class=') then | |||
image_arg = image_arg:gsub('class=', 'class=notpageimage ') | |||
else | |||
image_arg = image_arg:sub(1, -3) .. '|class=notpageimage]]' | |||
end | |||
return image_arg | |||
end | |||
end | end | ||
| Line 142: | Line 154: | ||
local child = args.child and mw.text.trim(args.child) == cfg.i18n.child_yes | local child = args.child and mw.text.trim(args.child) == cfg.i18n.child_yes | ||
root = root:tag(' | root = root:tag('div') | ||
if not child then | if not child then | ||
root | root | ||
| Line 148: | Line 160: | ||
-- force collapsibleclass to be sidebar-collapse otherwise output nothing | -- force collapsibleclass to be sidebar-collapse otherwise output nothing | ||
:addClass(collapsibleClass == cfg.i18n.class.collapse and cfg.i18n.class.collapse or nil) | :addClass(collapsibleClass == cfg.i18n.class.collapse and cfg.i18n.class.collapse or nil) | ||
:addClass(args.float == cfg.i18n.float_none and cfg.i18n.class.float_none or nil) | :addClass(args.float == cfg.i18n.float_none and cfg.i18n.class.float_none or nil) | ||
:addClass(args.float == cfg.i18n.float_left and cfg.i18n.class.float_left or nil) | :addClass(args.float == cfg.i18n.float_left and cfg.i18n.class.float_left or nil) | ||
:addClass(args.wraplinks ~= cfg.i18n.wrap_true and cfg.i18n.class.wraplinks or nil) | :addClass(args.wraplinks ~= cfg.i18n.wrap_true and cfg.i18n.class.wraplinks or nil) | ||
:addClass(args.bodyclass or args.class) | :addClass(args.bodyclass or args.class) | ||
:attr('role', 'navigation') | |||
:css('width', args.width or nil) | :css('width', args.width or nil) | ||
:cssText(args.bodystyle or args.style) | :cssText(args.bodystyle or args.style) | ||
| Line 158: | Line 170: | ||
if args.outertitle then | if args.outertitle then | ||
root | root | ||
:tag(' | :tag('div') | ||
:addClass(cfg.i18n.class.outer_title) | :addClass(cfg.i18n.class.outer_title) | ||
:addClass(args.outertitleclass) | :addClass(args.outertitleclass) | ||
| Line 166: | Line 178: | ||
if args.topimage then | if args.topimage then | ||
local imageCell = root:tag(' | local imageCell = root:tag('div'):tag('div') | ||
imageCell | imageCell | ||
| Line 172: | Line 184: | ||
:addClass(args.topimageclass) | :addClass(args.topimageclass) | ||
:cssText(args.topimagestyle) | :cssText(args.topimagestyle) | ||
:wikitext(args.topimage) | :wikitext(add_notpageimage_class(args.topimage)) | ||
if args.topcaption then | if args.topcaption then | ||
| Line 185: | Line 197: | ||
if args.pretitle then | if args.pretitle then | ||
root | root | ||
:tag(' | :tag('div') | ||
:tag(' | :tag('div') | ||
:addClass(args.topimage and cfg.i18n.class.pretitle_with_top_image | :addClass(args.topimage and cfg.i18n.class.pretitle_with_top_image | ||
or cfg.i18n.class.pretitle) | or cfg.i18n.class.pretitle) | ||
| Line 207: | Line 219: | ||
else | else | ||
root | root | ||
:tag(' | :tag('div') | ||
:tag(' | :tag('div') | ||
:addClass(args.pretitle and cfg.i18n.class.title_with_pretitle | :addClass(args.pretitle and cfg.i18n.class.title_with_pretitle | ||
or cfg.i18n.class.title) | or cfg.i18n.class.title) | ||
| Line 214: | Line 226: | ||
:cssText(args.basestyle) | :cssText(args.basestyle) | ||
:cssText(args.titlestyle) | :cssText(args.titlestyle) | ||
:css('font-weight', 'bold') | |||
:wikitext(args.title) | :wikitext(args.title) | ||
end | end | ||
| Line 219: | Line 232: | ||
if args.image then | if args.image then | ||
local imageCell = root:tag(' | local imageCell = root:tag('div'):tag('div') | ||
imageCell | imageCell | ||
| Line 225: | Line 238: | ||
:addClass(args.imageclass) | :addClass(args.imageclass) | ||
:cssText(args.imagestyle) | :cssText(args.imagestyle) | ||
:wikitext(args.image) | :wikitext(add_notpageimage_class(args.image)) | ||
if args.caption then | if args.caption then | ||
| Line 238: | Line 251: | ||
if args.above then | if args.above then | ||
root | root | ||
:tag(' | :tag('div') | ||
:tag(' | :tag('div') | ||
:addClass(cfg.i18n.class.above) | :addClass(cfg.i18n.class.above) | ||
:addClass(args.aboveclass) | :addClass(args.aboveclass) | ||
| Line 266: | Line 279: | ||
if heading then | if heading then | ||
root | root | ||
:tag(' | :tag('div') | ||
:tag(' | :tag('div') | ||
:addClass(cfg.i18n.class.heading) | :addClass(cfg.i18n.class.heading) | ||
:addClass(args.headingclass) | :addClass(args.headingclass) | ||
| Line 274: | Line 287: | ||
:cssText(args.headingstyle) | :cssText(args.headingstyle) | ||
:cssText(args['heading' .. num .. 'style']) | :cssText(args['heading' .. num .. 'style']) | ||
:css('font-weight', 'bold') | |||
:newline() | :newline() | ||
:wikitext(heading) | :wikitext(heading) | ||
| Line 281: | Line 295: | ||
if content then | if content then | ||
root | root | ||
:tag(' | :tag('div') | ||
:tag(' | :tag('div') | ||
:addClass(hasSubgroup(content) and cfg.i18n.class.content_with_subgroup | :addClass(hasSubgroup(content) and cfg.i18n.class.content_with_subgroup | ||
or cfg.i18n.class.content) | or cfg.i18n.class.content) | ||
| Line 300: | Line 314: | ||
if args.below then | if args.below then | ||
root | root | ||
:tag(' | :tag('div') | ||
:tag(' | :tag('div') | ||
:addClass(cfg.i18n.class.below) | :addClass(cfg.i18n.class.below) | ||
:addClass(args.belowclass) | :addClass(args.belowclass) | ||
| Line 311: | Line 325: | ||
if not child and has_navbar(args.navbar, args.name) then | if not child and has_navbar(args.navbar, args.name) then | ||
root | root | ||
:tag(' | :tag('div') | ||
:tag(' | :tag('div') | ||
:addClass(cfg.i18n.class.navbar) | :addClass(cfg.i18n.class.navbar) | ||
:cssText(args.navbarstyle) | :cssText(args.navbarstyle) | ||