Jump to content

Module:Gallery and Module:Gallery/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
Returning to the new version + fixes tested in the sandbox and in a local mediawiki. The problem was because the parser was interpreting the pipe as part of the url in the reported case.
 
Automatically detecting if in main or Sandbox. Reducing the difference between versions helps working with it and prevents mistakes. (I also tested on a local mediawiki)
 
Line 3: Line 3:
local p = {}
local p = {}


local moduleName = mw.getCurrentFrame():getTitle()
local templatestyles = 'Module:Gallery/styles.css'
local isSandbox = mw.ustring.match(moduleName, "sandbox") ~= nil

local templatestyles = 'Module:Gallery'.. (isSandbox and '/sandbox' or '') ..'/styles.css'
local cssRootClass = 'mod-gallery' .. (isSandbox and '-sb' or '')

local yesno = require('Module:Yesno')
local yesno = require('Module:Yesno')
local plaintextModule = require('Module:Plain text')
local plaintextModule = require('Module:Plain text')
Line 100: Line 105:


local tbl = mw.html.create('div')
local tbl = mw.html.create('div')
tbl:addClass('mod-gallery')
tbl:addClass(cssRootClass)

if args.state then
if args.state then
tbl
tbl
:addClass('mod-gallery-collapsible')
:addClass(cssRootClass .. '-collapsible')
:addClass('collapsible')
:addClass('collapsible')
:addClass(args.state)
:addClass(args.state)
Line 112: Line 117:
tbl:cssText(args.style)
tbl:cssText(args.style)
else
else
tbl:addClass('mod-gallery-default')
tbl:addClass(cssRootClass .. '-default')
end
end
if args.align then
if args.align then
tbl:addClass('mod-gallery-' .. args.align:lower())
tbl:addClass(cssRootClass .. '-' .. args.align:lower())
end
end