Module:CopyText
This module implements {{CopyText}}.
local p = {}
local lib = require('Module:Feature')
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
parentFirst = true,
wrapper = { 'Template:CopyText' }
})
return p._main(args)
end
function p._main(args)
local copy_text = args[1]
local button_text = args[3] or 'COPY TO CLIPBOARD'
local intro_text = args[2] or lib.ternary(args.no_intro ~= '1', 'Click on the "' .. button_text .. '" button to copy the following text:', '')
local result = mw.html.create()
result:tag("div")
:css({
["height"] = "35px"
})
:tag("span")
:wikitext(intro_text)
:done()
:tag('span')
:addClass('copy-to-clipboard-button wds-button wds-is-secondary wds-is-squished')
:css({
['float'] = lib.ternary(args.no_intro ~= '1', 'right', 'left'),
['cursor'] = 'pointer'
})
:attr('data-text', copy_text)
:wikitext(button_text)
:done()
result:wikitext(' ')
result:tag('span')
:addClass('copy-to-clipboard-text')
:attr('data-text', copy_text)
:wikitext(copy_text)
return result
end
return p