-- Đây là mô đun hỗ trợ cho Bản mẫu:Navboxes top và Bản mẫu:Navboxes bottom
local p = {}
local function is_empty(s)
return s == nil or s == ''
end
function p.top(frame)
local args = frame:getParent().args
local parts = {}
-- CẬP NHẬT QUAN TRỌNG: Thêm "mw-collapsible" (để ẩn/hiện) và "autocollapse" (tự đóng khi cần)
local table_class = "nowraplinks mw-collapsible"
if args.state == "collapsed" then
table_class = table_class .. " mw-collapsed" -- Mặc định đóng
elseif args.state ~= "expanded" then
table_class = table_class .. " autocollapse" -- Tự động đóng mở thông minh
end
-- Mở bảng chứa với class mới
table.insert(parts, '<table class="' .. table_class .. '" style="width:100%; border-spacing:0; margin:0; padding:0; clear:both;">')
-- Xử lý tiêu đề (nếu có)
if not is_empty(args.title) then
table.insert(parts, '<tr><th class="navbox-title" style="background:' .. (args.bg or '#e8e8eb') .. '; text-align:center;">')
table.insert(parts, args.title)
table.insert(parts, '</th></tr>')
end
-- Bắt đầu nội dung
table.insert(parts, '<tr><td style="padding:0;">')
return table.concat(parts)
end
function p.bottom(frame)
return '</td></tr></table>'
end
return p