跳转到内容
打开/关闭搜索
搜索
打开/关闭菜单
397
文件
1978
用户
1.2万
编辑
Gal中文百科
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
在其他项目中
打开/关闭外观设置菜单
无法加载偏好设置。请检查您的网络连接并重试。
重试
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
讨论
贡献
创建账号
登录
编辑“︁
Module
:
Collapsible list
”︁
来自Gal中文百科
查看
阅读
编辑源代码
查看历史
associated-pages
模块
讨论
更多操作
更多
工具
链入页面
相关更改
页面信息
警告:
您没有登录。如果您进行任何编辑,您的IP地址会公开展示。如果您
登录
或
创建账号
,您的编辑会以您的用户名署名,此外还有其他益处。
反垃圾检查。
不要
加入这个!
local p = {} local yesno = require('Module:Yesno') local function getListItem( data ) if not type( data ) == 'string' then return '' end local emptyList = mw.html.create('li') :cssText('line-height: inherit') :cssText('margin: 0') :wikitext(data) return tostring(emptyList) end -- Returns an array containing the keys of all positional arguments -- that contain data (i.e. non-whitespace values). local function getArgNums( args ) local nums = {} for k, v in pairs( args ) do if type( k ) == 'number' and k >= 1 and math.floor( k ) == k and type( v ) == 'string' and mw.ustring.match( v, '%S' ) then table.insert( nums, k ) end end table.sort( nums ) return nums end -- TODO: use Module:List. Since the update for this comment is routine, -- Modification: uses module:yesno and mw.html.create local function buildList( args ) local argNums = getArgNums( args ) if #argNums == 0 then return '' end -- ordered list option added local isOrdered = yesno(args.ordered, false) local isBullets = yesno(args.bullets, false) -- hack:collapsible button jumps with title local textAlignmentCentered = 'text%-align%s*:%s*center' local centeredTitle = (args.title_style and args.title_style:lower():match(textAlignmentCentered)) or (args.titlestyle and args.titlestyle:lower():match(textAlignmentCentered)) local centeredTitleSpacing = centeredTitle and 'margin: 0 4em' or nil local hlist_templatestyles = '' if args.hlist then hlist_templatestyles = mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = 'Hlist/styles.css' } } end local collapsedClazz = '' if not args.expand then collapsedClazz='mw-collapsed' end -- collapsible frame local root = mw.html.create('div') :addClass('collapsible-list') :addClass('mw-collapsible') :addClass(collapsedClazz) :cssText('text-align: left;') :cssText(args.frame_style or args.framestyle) -- title local titleWrapper = root:tag('div') :css('line-height', '1.6em') :css('font-weight', 'bold') :cssText(args.title_style or args.titlestyle) titleWrapper:tag('div') :cssText(centeredTitleSpacing) :wikitext(args.title or '列表') -- list(ul / ol) local list = root:tag(isOrdered and 'ol' or 'ul') :addClass('mw-collapsible-content') :addClass(args.hlist and 'hlist') :css('margin-top', 0) :css('margin-bottom', 0) :css('line-height', 'inherit') :cssText(args.list_style or args.liststyle) if not isOrdered and not isBullets then list :css('list-style', 'none') :css('margin-left', 0) end -- list items for _, num in ipairs( argNums ) do list:tag('li') :css('line-height', 'inherit') :css('margin', 0) :wikitext(args[num]) end return hlist_templatestyles .. tostring(root) end function p.main( frame ) local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs( frame.args ) do origArgs = frame.args break end else origArgs = frame end local args = {} for k, v in pairs( origArgs ) do if type( k ) == 'number' or v ~= '' then args[ k ] = v end end return buildList( args ) end return p
摘要:
请注意,所有对Gal中文百科的贡献均可能会被其他贡献者编辑、修改或删除。如果您不希望您的文字作品被随意编辑,请不要在此提交。
您同时也向我们承诺,您提交的内容为您自己所创作,或是复制自公共领域或类似自由来源(详情请见
Gal中文百科:著作权
)。
未经许可,请勿提交受著作权保护的作品!
取消
编辑帮助
(在新窗口中打开)
此页面嵌入的页面:
Module:Collapsible list/doc
(
编辑
)
编辑“︁
Module
:
Collapsible list
”︁
来自Gal中文百科