檢視模組:Collapsible list的原始碼
←
模組:Collapsible list
跳至導覽
跳至搜尋
您沒有權限執行編輯此頁面,由於以下原因:
您請求的操作只有這個群組的使用者能使用:
使用者
您可以檢視並複製此頁面的原始碼。
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
此頁面嵌入了以下頁面:
模組:Collapsible list/doc
(
檢視原始碼
)
返回到「
模組:Collapsible list
」。
導覽選單
個人工具
建立帳號
登入
associated-pages
模組
討論
English
視圖
閱讀
檢視原始碼
檢視歷史
更多
搜尋
導覽
首頁
近期變更
隨機頁面
MediaWiki說明
特殊頁面
工具
連結至此的頁面
相關變更
頁面資訊