Module:Definitions: Difference between revisions
From SpiritVale Wiki
More actions
No edit summary Tags: Mobile edit Mobile web edit |
No edit summary Tags: Mobile edit Mobile web edit |
||
| Line 9: | Line 9: | ||
-- - CSS namespace: ONLY "sv-def" (plus sv-def--* modifiers). | -- - CSS namespace: ONLY "sv-def" (plus sv-def--* modifiers). | ||
-- - Output classes: sv-def, sv-def-icon, sv-def-icon-img, sv-def-text. | -- - Output classes: sv-def, sv-def-icon, sv-def-icon-img, sv-def-text. | ||
-- - Tooltip/link behavior is handled by Universal Popups (Common.js). | |||
local p = {} | local p = {} | ||
| Line 117: | Line 118: | ||
-- ============================================================================= | -- ============================================================================= | ||
-- Icon rendering | -- Icon rendering | ||
-- - Blank icon: render nothing | -- - Blank icon: render nothing | ||
-- - Missing file: render "?" badge (no redlink image) | -- - Missing file: render "?" badge (no redlink image) | ||
-- ============================================================================= | -- ============================================================================= | ||
| Line 175: | Line 176: | ||
local d_lc = lc(domain) | local d_lc = lc(domain) | ||
-- Missing record: | -- Missing record: visible hint, no tooltip/link attributes. | ||
if rec == nil then | if rec == nil then | ||
local miss_icon = noicon and "" or '<span class="sv-def-icon sv-def-icon--missing" aria-hidden="true">?</span>' | local miss_icon = noicon and "" or '<span class="sv-def-icon sv-def-icon--missing" aria-hidden="true">?</span>' | ||
| Line 194: | Line 195: | ||
local classes = 'sv-def sv-def--' .. enc_attr(d_lc) | local classes = 'sv-def sv-def--' .. enc_attr(d_lc) | ||
if noicon then | if noicon then classes = classes .. ' sv-def--noicon' end | ||
if pill then classes = classes .. ' sv-def--pill' end | |||
if fill then classes = classes .. ' sv-def--fill' end | |||
if pill then | |||
if fill then | |||
local attrs = { | local attrs = { | ||
| Line 209: | Line 204: | ||
'data-sv-def-key="' .. enc_attr(key) .. '"', | 'data-sv-def-key="' .. enc_attr(key) .. '"', | ||
} | } | ||
if pill then | |||
if pill then attrs[#attrs + 1] = 'data-sv-def-pill="1"' end | |||
if fill then attrs[#attrs + 1] = 'data-sv-def-fill="1"' end | |||
if fill then | |||
-- Only include tooltip/link attributes when populated. | -- Only include tooltip/link attributes when populated. | ||
if defn ~= "" then | if defn ~= "" then | ||
attrs[#attrs + 1] = 'data-sv-def-tip="' .. enc_attr(defn) .. '"' | attrs[#attrs + 1] = 'data-sv-def-tip="' .. enc_attr(defn) .. '"' | ||
-- Interactive definitions are focusable for consistent UX. | |||
attrs[#attrs + 1] = 'tabindex="0"' | |||
end | end | ||
if link ~= "" then | if link ~= "" then | ||
attrs[#attrs + 1] = 'data-sv-def-link="' .. enc_attr(link) .. '"' | attrs[#attrs + 1] = 'data-sv-def-link="' .. enc_attr(link) .. '"' | ||
end | end | ||
local ico = noicon and "" or icon_html(icon) | local ico = noicon and "" or icon_html(icon) | ||
return | return | ||
'<span ' .. table.concat(attrs, " ") | '<span ' .. table.concat(attrs, " ") .. '>' .. | ||
ico .. | ico .. | ||
'<span class="sv-def-text">' .. mw.text.nowiki(name) .. '</span>' .. | '<span class="sv-def-text">' .. mw.text.nowiki(name) .. '</span>' .. | ||