WARFRAME Wiki

SCRIPT ERRORS!!
But don't worry, the admin and editor team are aware of them and they will be resolved over the next few days as our Weapons Module goes through a much needed overhaul.
Sorry for any inconvenience!
FINNER (talk), 05:04, 20 January 2022 (UTC)


Free feel to use Internet Archive https://archive.org/ for an archived version of a page. Official drop tables are still available on https://www.warframe.com/droptables

READ MORE

WARFRAME Wiki
Advertisement
WARFRAME Wiki


Tooltips builds tooltip links and icons.

Stylesheet for tooltips and tooltip text can be found on MediaWiki:Tooltips.css. The JS script that enables tooltips is sourced from https://dev.fandom.com/wiki/Tooltips

On this Wiki, Tooltips is used in:

Usage

Direct Invocation

{{#invoke:Tooltip|function|input1|input2|...}}

Examples

How it works

  1. When you call a tooltip builder function (e.g. Tooltips.getFullTooltip(itemName, moduleName, ...)), it uses Module:Tooltips/icon to get the item image and page link from a module's /data subpage and builds the basic HTML tooltip tags to put on wiki articles (<span class="tooltip tooltip-text" data-param="..." data-param2="..."></span>).
  2. The JS script https://dev.fandom.com/wiki/Tooltips (imported on MediaWiki:ImportJS) does the fetching of data based on data-param (containing item name) and data-param2 (containing name of module which has a /data database containing the item's data) attributes in tooltip tags to build the actual tooltip defined by wikitext in Module:Tooltips/tip.
    • For example, <span class="tooltip tooltip-full tooltips-init-complete" data-param="Artemis Bow" data-param2="Weapons">...</span> will display a Template:Weapon tooltip of Artemis Bow (Weapon) while <span class="tooltip tooltip-full tooltips-init-complete" data-param="Artemis Bow" data-param2="Ability">...</span> will display a Template:A ("A" is a shorthand for abilities) tooltip of Artemis Bow.
    • The processed wikitext for tooltips will be located in a div container on the bottom of articles with an id of tooltip-storage.
    • Data fetching uses MediaWiki's Action API.
    • Note that tooltips do not work properly on module pages because they do not have the same HTML structure as article pages.

Directory

  • Module:Tooltips - main module for invoking tooltip function on articles; tooltip builder
    • Module:Tooltips/tip - submodule for defining styling of tooltip box that appears on hover over
    • Module:Tooltips/icon - submodule for defining where to fetch data for the contents of tooltip box as well as the styling of the icon next to tooltip element

Documentation

Package items

tooltips.getFullTooltip(name, source, skipData) (function)
Get the tooltip icon. (frame.args.i, frame.args.l are index, link; frame.args.r is display of link) TODO: Remove unused c and d arguments
Parameters:
  • name (string)
  • source Name of module containing object entry (can pass table instead) (string, table)
  • skipData Skip loading data? (will also remove icon) (nil, -> load) (boolean)
      • frame.args.i Index for data replacement (will also prevent data from loading) (string)
      • frame.args.l Link for data replacement (string)
      • frame.args.noIcon Remove icon? (nil, -> keep) (boolean)
      • frame.args.r Replacement for displayed link text (nil, -> <name>) (string)
Returns: Tooltip tags, icon, & link in wikitext (string)
tooltips.getText(name, source) (function)
Get the tooltip text with no icon.
Parameters:
  • name (string)
  • source Name of module containing object entry (string)
Returns: Tooltip text in wikitext (string)
tooltips.getImage(name, source, doTip) (function)
Get the tooltip icon with no text.
Parameters:
  • name (string)
  • source Name of module containing object entry (can pass table instead) (string, table)
  • doTip Whether to add tooltip span (nil, -> tooltip) (boolean)
Returns: Tooltip (if enabled) & icon in wikitext (string)
tooltips.getTip(name, b) (function)
Get the tooltip. (uses frame:preprocess if no tooltip function is found)
Parameters:
  • name (string)
  • b source (string)
Returns: Tooltip (string)
tooltips.__readout(frame) (function)
Returns serialized table of Module:Tooltips/data.
Parameter: frame Frame object (table)
Returns: Serialized table (string)

Created with Docbunto

See Also

Code


--- '''Tooltips''' builds tooltip links and icons.<br />
--  
--	Stylesheet for tooltips and tooltip text can be found on [[MediaWiki:Tooltips.css]].
--	The JS script that enables tooltips is sourced from https://dev.fandom.com/wiki/Tooltips
--	
--	@module		tooltips
--	@author		[[User:Gigamicro|Gigamicro]]
--	@image		TooltipPic.PNG
--	@require	[[w:c:dev:MediaWiki:Tooltips.js|MediaWiki:Tooltips.js]]
--	@require	[[Module:Tooltips/icon]]
--	@require	[[Module:Tooltips/tip]]
--	@release	stable
--	<nowiki>

local iconNotFoundErrorMsg = 'M:Tooltips.%s: icon not found in "%s" for "%s" (Are you using the wrong tooltip template or made a typo? If not, you likely have to edit [[Module:%s/data]]. If content is outdated, please replace tooltip template call with a normal wikitext link.)'

return {
--- Get the tooltip icon. (frame.args.i, frame.args.l are index, link; frame.args.r is display of link)
--	TODO: Remove unused c and d arguments
--	@function		p.getFullTooltip
--	@param			{string} name
--	@param			{string, table} source Name of module containing object entry (can pass table instead)
--	@param			{boolean} skipData Skip loading data? (will also remove icon) (nil,'' -> load)
--	@param			{string} frame.args.i Index for data replacement (will also prevent data from loading)
--	@param			{string} frame.args.l Link for data replacement
--	@param			{boolean} frame.args.noIcon Remove icon? (nil,'' -> keep)
--	@param			{string} frame.args.r Replacement for displayed link text (nil, '' -> <name>)
--	@return			{string} Tooltip <span> tags, icon, & link in wikitext
getFullTooltip = function(frame, b, c, d)
	local name, source, skipData, nextvar = (function(t) return t[1], t[2], t[3], t[4] end)(frame.args or { frame, b, c, d })
	--assert(name and name ~= '', 'p.getIcon(): No name provided')
	if #(name or '') == 0 then
		return "N/A"
	end
	name = mw.text.decode(name) -- Replacing HTML codes in text with their ASCII character equivalent
	
	-- Checking if content exists in a particular /data database
	local index = require('Module:Tooltips/icon')[source](name) or 
		error(iconNotFoundErrorMsg:format('getFullTooltip()', source, name, source))
	
	local icon = (frame.args and frame.args["noicon"] or '') == '' and (type(index.icon) == 'table' and index.icon[1] or index.icon) or ''
	return string.format('<span class="tooltip tooltip-full" data-param="%s" data-param2="%s">%s%s[[%s|<span style="border-bottom:2px dotted;%s">%s</span>]]</span>',
		index[2] or name,	-- param1 (item name)
		index[1] or '',	-- param2 (item type/source)
		icon,
		icon == '' and '' or '&nbsp;', -- spacing
		index[3] ~= name and index[3] or name, -- link destination
		index.color and (' color:%s;'):format(index.color) or '', -- coloring
		(frame.args and frame.args.r ~= '' and frame.args.r or index.name):gsub(' ', '&nbsp;') -- displayed name
	)
end,

--- Get the tooltip text with no icon.
--	@function		p.getText
--	@param			{string} name
--	@param			{string} source Name of module containing object entry
--	@return			{string} Tooltip text in wikitext
getText = function(frame, b)
	local name, source = (function(t) return t[1], t[2] end)(frame.args or { frame, b })
	name = mw.text.decode(name) -- Replacing HTML codes in text with their ASCII character equivalent
	
	local index = require('Module:Tooltips/icon')[source](name) or
		error(iconNotFoundErrorMsg:format('getText()', source, name, source))
		
	return string.format('<span class="tooltip tooltip-text" data-param="%s" data-param2="%s">[[%s|<span style="border-bottom:2px dotted;">%s</span>]]</span>',
		index[2] or name,	-- Item name
		index[1] or '',		-- Module name
		index[3] ~= name and index[3] or name,	-- Article name on wiki
		index.name:gsub(' ', '&nbsp;')	-- Displayed link text
	)
end,

--- Get the tooltip icon with no text.
--	@function		p.getImage
--	@param			{string} name
--	@param			{string, table} source Name of module containing object entry (can pass table instead)
--	@param			{boolean} doTip Whether to add tooltip span (nil, '' -> tooltip)
--	@return			{string} Tooltip </span> (if enabled) & icon in wikitext
getImage = function(frame, b, c)
	local name, source, doTip = (function(t) return t[1], t[2], t[3] end)(frame.args or { frame, b, c })
	--assert(name and name ~= '', 'p.getImage(): No name provided')
	if #(name or '') == 0 then
		return "N/A"
	end
	local index = require('Module:Tooltips/icon')[source](name) or
		error(iconNotFoundErrorMsg:format('getImage()', source, name, source))

	return doTip ~= 'false' and doTip ~= '' and string.format('<span class="tooltip tooltip-icon" data-param="%s" data-param2="%s">%s</span>',
		index[2] or name,	-- param1 (item name)
		index[1] or '',	-- param2 (item type/source)
		(type(index.icon) == 'table' and index.icon[1] or index.icon) or '' -- icon
	) or (type(index.icon) == 'table' and index.icon[1] or index.icon) or ''
end,

--- Get the tooltip. (uses frame:preprocess if no tooltip function is found)
--	@function		p.getTip
--	@param			{string} name
--	@param			{string} b source
--	@return			{string} Tooltip
getTip = function(frame, b)
	local name, source = (function(t) return t[1], t[2] end)(frame.args or {frame, b})
	assert(name, 'p.getTip(): No name provided')

	return (require('Module:Tooltips/tip')[source] or 
		-- Default tooltip (note that using parser function may be expensive)
		function(name)
			local s = frame:preprocess('{'..'{#lst:'..name..'|intro}}') -- or frame:preprocess('{'..'{#lsth:'..frame.args[1]..'}}')
			return s ~= '' and ([[
<div style="display:inline-block; position:relative;">
{| style="background-color:#ddd; border:3px solid rgba(49,50,52,0.3); border-spacing:0; border-radius:4px; padding:0; color: #1C1C1C; font-size: 14px; width: 200px;"
| style="background-color:var(--theme-page-background-color); color:var(--theme-page-text-color); font-size:11px; width:100px; white-space:inherit; margin:0; padding:2px; line-height:normal;" |%s
|}
</div>]]):format(s) or ''
		end)(name)
end,

--- Returns serialized table of [[Module:Tooltips/data]].
--	@function		p.__readout
--	@param			{table} frame Frame object
--	@return			{string} Serialized table
__readout = function(frame)
	local data = mw.loadData('Module:Tooltips/data')
	local f = function(data, argTable) for i, v in ipairs(argTable) do data = data[v] end return data end
	return mw.dumpObject(f(data, frame.args))
end,
}
Advertisement