mNo edit summary |
mNo edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
NewsNav.tab('Drama', 'News/') | NewsNav.tab('Drama', 'News/') | ||
NewsNav.tab('Business', 'News/') | NewsNav.tab('Business', 'News/') | ||
NewsNav.tab(' | NewsNav.tab('Sponsorships', 'News/') | ||
NewsNav.tab('More', 'News/') | NewsNav.tab('More', 'News/') | ||
NewsNav.tab('Search', 'News/') | |||
for j = 1, #tabArgs do | for j = 1, #tabArgs do | ||
Line 23: | Line 23: | ||
text = '[[' .. tabArgs[j].link .. '|' .. tabArgs[j].name .. ']]' | text = '[[' .. tabArgs[j].link .. '|' .. tabArgs[j].name .. ']]' | ||
end | end | ||
tableContainer:node(mw.html.create('div'):addClass('news-nav-item'):wikitext(text)) | tableContainer:node(mw.html.create('div'):addClass((tabArgs[j].active and 'active-nav ' or '') .. 'news-nav-item'):wikitext(text)) | ||
end | end | ||
Latest revision as of 18:52, 13 March 2024
Documentation for this module may be created at Module:NewsNav/doc
local NewsNav= {} local tabArgs = {} local i = 1 local currentTitle = mw.title.getCurrentTitle().text function NewsNav.main(frame) local empty = true local tableContainer = mw.html.create('div'):addClass('news-nav') NewsNav.tab('News', '') NewsNav.tab('Transfer Market', 'News/') NewsNav.tab('Drama', 'News/') NewsNav.tab('Business', 'News/') NewsNav.tab('Sponsorships', 'News/') NewsNav.tab('More', 'News/') NewsNav.tab('Search', 'News/') for j = 1, #tabArgs do local text if tabArgs[j].active then text = tabArgs[j].name else text = '[[' .. tabArgs[j].link .. '|' .. tabArgs[j].name .. ']]' end tableContainer:node(mw.html.create('div'):addClass((tabArgs[j].active and 'active-nav ' or '') .. 'news-nav-item'):wikitext(text)) end return tableContainer end function NewsNav.tab(title, prefix) local newObj = { name = title, link = prefix .. title } if prefix .. title == currentTitle then newObj.active = true end table.insert (tabArgs, newObj ) i = i + 1 end return NewsNav