پودمان:List: تفاوت میان نسخه‌ها

جز ۱ نسخه واردشده
جز ۱ نسخه واردشده
 
(۴ نسخهٔ میانی ویرایش شده توسط ۳ کاربر نشان داده نشد)
خط ۸: خط ۸:


local p = {}
local p = {}
local num_con = require('Module:Numeral converter').convert


local listTypes = {
local listTypes = {
خط ۲۱: خط ۲۳:
local data = {}
local data = {}


-- Classes
-- Classes and TemplateStyles فهرست ساده/styles.css باید فارسی باشد
data.classes = {}
data.classes = {}
data.templatestyles = ''
if listType == 'horizontal' or listType == 'horizontal_ordered' then
if listType == 'horizontal' or listType == 'horizontal_ordered' then
table.insert(data.classes, 'hlist hlist-separated')
table.insert(data.classes, 'hlist')
data.templatestyles = mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Hlist/styles.css' }
}
elseif listType == 'unbulleted' then
elseif listType == 'unbulleted' then
table.insert(data.classes, 'plainlist')
table.insert(data.classes, 'plainlist')
data.templatestyles = mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'فهرست ساده/styles.css' }
}
end
end
table.insert(data.classes, args.class)
table.insert(data.classes, args.class)
خط ۶۷: خط ۷۶:
else
else
data.listTag = 'ul'
data.listTag = 'ul'
end
-- Start number for ordered lists
data.start = num_con("en", args.start)
-- Two new persian translation for the start parameter
if args['آغاز'] then
data.start = num_con("en", args['آغاز'])
end
if args['شروع'] then
data.start = num_con("en", args['شروع'])
end
end


-- Start number for ordered lists
data.start = args.start
if listType == 'horizontal_ordered' then
if listType == 'horizontal_ordered' then
-- Apply fix to get start numbers working with horizontal ordered lists.
-- Apply fix to get start numbers working with horizontal ordered lists.
خط ۸۹: خط ۱۰۸:
data.itemStyle = args.item_style or args.li_style
data.itemStyle = args.item_style or args.li_style
data.items = {}
data.items = {}
for i, num in ipairs(mTableTools.numKeys(args)) do
for _, num in ipairs(mTableTools.numKeys(args)) do
local item = {}
local item = {}
item.content = args[num]
item.content = args[num]
خط ۱۱۲: خط ۱۳۱:
-- Render the main div tag.
-- Render the main div tag.
local root = mw.html.create('div')
local root = mw.html.create('div')
for i, class in ipairs(data.classes or {}) do
for _, class in ipairs(data.classes or {}) do
root:addClass(class)
root:addClass(class)
end
end
خط ۱۳۴: خط ۱۵۳:


-- Render the list items
-- Render the list items
for i, t in ipairs(data.items or {}) do
for _, t in ipairs(data.items or {}) do
local item = list:tag('li')
local item = list:tag('li')
if data.itemStyle then
if data.itemStyle then
خط ۱۴۷: خط ۱۶۶:
end
end


return tostring(root)
return data.templatestyles .. tostring(root)
end
end