Module:Calendar widget: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 84:
--[[--------------------------< G E T _ D I S P L A Y _ Y E A R >----------------------------------------------
 
for yearlyindividual month calendar: returns year from props with wikilink if appropriate
 
TODO: add support for new parameters |lk_pref_y= and |lk_suff_y=?
TODO: share this with yearly calendar header (call from get_year_header())?
 
]]
Line 93 ⟶ 94:
local year_text = props.year;
 
if props.lk_y then -- if to be linked
year_text = make_wikilink (props.year);
end
Line 153 ⟶ 154:
local tags = {}; -- table of <tag>...</tag> tag strings
local opt_attr = options.attr or {}; -- if options not supplied, use empty table
local opt_csscss_opts = options.css or {};
for i, item in ipairs (items) do
Line 160 ⟶ 161:
:addClass (options.class)
:attr (opt_attr)
:css (opt_csscss_opts)
:wikitext (item) -- get a calendar for month number mnum
:done() -- close <td>
Line 356 ⟶ 357:
--[[--------------------------< G E T _ Y E A R _ H E A D E R >------------------------------------------------
 
create html header for yearly calendar;
 
TODO: for accessibility, tables require headers. Instead of rendering no header when |hide_year=yes, create it with display:none?
 
]]
 
local function get_year_header (props)
local css_opts = {};
if not props.hide_year then
local header = mw.html.create('tr');
if props.hide_year and not props.title then -- for accesibility, when |hide_year=yes
header:tag ('tr')
css_opts['display'] = 'none'; -- use css to hide the year header (but not when |title= has a value)
:addClass ('ycalhdr')
:tag ('th')
:addClass ('ycal')
:attr ('colspan', props.cols)
:wikitext (props.title or props.year);
return tostring (header)
end
local header = mw.html.create('tr');
return '';
header
:addClass ('ycalhdr')
header:tag ('trth')
:tagaddClass ('thycal')
:css(css_opts)
:attr ('colspan', props.cols)
:wikitext (props.title or props.year); -- use get_display_year() so that yearly calendar header can be linked?
return tostring (header)
end