Модуль:Comment

Материал из Синяя Энциклопедии
Версия от 13:32, 29 августа 2026; Bloomstorm (обсуждение | вклад)
(разн.) ← Предыдущая версия | Текущая версия (разн.) | Следующая версия → (разн.)
Перейти к навигации Перейти к поиску

Для документации этого модуля может быть создана страница Модуль:Comment/doc

local p = {}
local getArgs = require('Module:Arguments').getArgs

function p.main(frame)
	local args = getArgs(frame, {
		parentFirst = true,
		wrappers = { 'Template:Comment' }
	})
	assert(args[1], 'Не введён отображаемый текст.')
	assert(args[2], 'Не введён текст комментария.')

    local text = args[1]
	local tooltip = mw.text.decode(args[2], true)
	local no_underline = args.noline and 'no-underline' or ''

	-- Десктопный вариант
	local desktop = mw.html.create('span')
		:addClass('sw-desktop-tooltip ' .. no_underline)
		:wikitext(text)
		:attr('title', tooltip)
		:allDone()

	-- Мобильный вариант
	--local mobile = mw.html.create('span')
	--	:addClass('sw-mobile-tooltip mobile-only mw-collapsible mw-made-collapsible mw-collapsed ' .. no_underline)
	--mobile
	--	:tag('span')
	--		:addClass('mw-collapsible-toggle mw-collapsible-toggle-default mw-collapsible-toggle-collapsed ' .. no_underline)
	--		:wikitext(text)
	--		:done()
	--mobile
	--	:tag('span')
	--		:addClass('mw-collapsible-content sw-mobile-tooltip__container')
	--		:css{ display = 'none' }
	--		:wikitext(tooltip)
	--		:done()
	--mobile:allDone()

	--return mw.html.create('span'):addClass('sw-tooltip'):node(desktop):node(mobile):allDone()
	return mw.html.create('span'):addClass('sw-tooltip'):node(desktop):allDone()
end

return p