This is the documentation page for Module:Tooltips
Tooltips builds tooltip links and icons. It can be used as a static or instantiated class.
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:
- {{A}}
- {{M}}
- {{WF}}
- {{Companion}}
- {{Relic}}
- {{Weapon}}
- {{Arcane}}
- {{D}}
- {{Resource}}
- {{Focus}}
- {{Faction}}
- {{Gear}}
- {{Stat}}
Usage
Direct Invocation
{{#invoke:Tooltip|function|input1|input2|...}}
Examples
Note that these only work on pages with the wikitext content model such as here. In addition, tooltips will not work if a page is added via <tabview>
tags.
- Haven
- Serration
- Mirage
- Adarza Kavat
- Axi A1
- Vectis
- Arcane Energize
- Heat, Flesh, Ignite
- Auron
- Protective Sling
- Grineer
- Requiem Ultimatum
How it works
- When you call a tooltip builder function (e.g.
Tooltips.full(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>
). - The JS script https://dev.fandom.com/wiki/Tooltips (imported in MediaWiki:ImportJS, configured in MediaWiki:Tooltips.js) does the fetching of data based on
data-param
(containing item name) anddata-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 and css in MediaWiki:Tooltips.css.- 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.
- For example,
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._getText(name, index, rep)
(function)- Returns formatted tooltip link text.
- Parameters:
name
Name of object entry to make a tooltip of (string)index
Tooltip index table (table)rep
Replacement args (table)
- Returns: Wikitext link (string)
tooltips._getIcon(_, index)
(function)- Returns tooltip icon.
- Parameters:
_
Ignore; unused variable (string)index
Tooltip index table (table)
- Returns: Image wikilink or nil (string)
tooltips.full(name, source, index)
(function)- Get the tooltip text and icon.
- Parameters:
name
Name of object entry to make a tooltip of (can also be used as index) (string)source
Name of module containing object entry (nil to check if a manual index is working) (string)index
Index entry from m:tt/icon, or data point from (source) if source is set (table)frame.args.r
Replacement for displayed link text (nil, -> <name>) (string)frame.args.color
Color replacement for displayed link text (e.g. '#ffffff') (string)frame.args.i
Index for data replacement (will also prevent data from loading) (string)frame.args.l
Link for data replacement (string)frame.args.n
Name for data replacement (string)frame.args.icon
Icon image name for data replacement (e.g. 'Ash.png') (string)
- Returns: Tooltip tags, icon, & link in wikitext (string)
tooltips.text(name, ...)
(function)- Get the tooltip text with no icon.
- Parameters:
name
Name of object entry to make a tooltip of (string)...
see p.full (string)
- Returns: Tooltip text in wikitext (string)
tooltips.icon(name, ...)
(function)- Get the tooltip icon with no text.
- Parameters:
name
Name of object entry to make a tooltip of (string)...
see p.full (string)
- Returns: Tooltip icon in wikitext (string)
tooltips._getIndex(name, source)
(function)- Get the data index.
- Parameters:
name
Item name (string)source
Name of source module containing object entry (string)
- Returns: index table (table)
tooltips.getTip(name, source, slot)
(function)- Get the tooltip.
- Parameters:
name
Name of object entry to make a tooltip of (string)source
Name of source module containing object entry (string)slot
Name of submodule (string)
- Returns: Tooltip (string)
tooltips._source(source)
(function)- Returns a function that serves as a interface to tooltip builders. Another way of thinking about this function is to treat the entire module as a class. When you require(), the module, you are 'instantiating' a new instance of this class and pass in the name of the database to pull data from. Then you call a tooltip function and pass in a database entry name for the desired tooltip.
- Parameter:
source
Name of source module containing object entry (string) - Returns: Wrapper function (function)
- Created with Docbunto
See Also