|
Cookbook /
CSSToolTipsToGoSummary: markup for tooltip functionality
Version: 2010-10-09.v0.1
Prerequisites:
Status: New
Maintainer: Joan Vilaseca
Discussion: CSSToolTipsToGo-Talk
Download: csstooltipstogo.phpΔ
Questions answered by this recipe
DescriptionDownload csstooltipstogo.phpΔ, copy to cookbook folder and add to config.php: include_once("$FarmD/cookbook/csstooltipstogo.php");
CSSToolTipsToGo allows the easy definition and usage of tooltips.. Tooltips, or popups, are here defined as contents that appear when hovering determinated text areas on a page. This recipe address the creation of those text areas and his associated popup/tooltip contents. Tooltips classesTooltips are grouped into classes. Each class defines the visual behaviour of the the text hovering area and his associated popup/tooltip. Tooltip individual instances of a class can also be further styled. To define a class, use the Syntax:
(:tooltips [class='classname'] [aspect='css-code'] [hover='css-code'] [popup='css-code'] [add='css-code']:)All the params are optional. if no classname is specified, a default (noname) class is used. The tooltips are positioned by default relative to the hovering area.
By default, a no name class, with minimal hide/show mechanics is always implemented. You can also change the behaviour of this class just by using Each tooltip class translates to an entry in the Tooltip classes can be made global to a group by declaring the Tooltips instancesTo create a tooltip of a given class, use the
Because a default class is already created, you can create tooltips even without previous That will show the text to make appear this tooltip when hovering over hover over this text, not a very useful example.
Defines a more interesting class; the text-hovering area is left unaffected, but the tooltip is styled in more detail. Left and top attributes defines where the popup will be show (relative to the start of the hovering area). The tooltips of that class gets also a background color, a rounded box, paddings and a minimal width. So We can also get a more interesting text for the tooltip by including whole page sections or page text variable: Refining instancesYou can also specify inline css for each instance of a class by adding instance-params to the classname field of the markup with the following syntax: instance-params can specify three different named clauses:
So Going furtherThe 'add' clause of the The 'add' clause has the following sintax: add[sufix]='css-code'. The 'sufix' part is only made to split long css declaration in more manageable chunks. So to create a class of tooltips with support for links enclosed in the text hovering area, we can use the following css code: add='span.L@CLASS@ a:visited {color: red;} span.L@CLASS@ a:link {color: red;} span.L@CLASS@ a:active {color: red;} span.L@CLASS@ a:hover {color: black; text-decoration: none;}' or alternatively: add='span.L@CLASS@ a:visited {color: red;}' add0='span.L@CLASS@ a:link {color: red;}' add1='span.L@CLASS@ a:active {color: red;}' add2='span.L@CLASS@ a:hover {color: black; text-decoration: none;}' Note that the Note that here we have two hovering sections/estates, the global of the text hovering area, and the text of the link. Each with his own hover css styles. Of course those areas can overlap completely if the text hovering is made of s single link. On a concrete example: (:tooltips class=LK aspect='color: #000;'
hover='background:#ccc;'
popup='left:2em; top:2em; border:solid; background: #fff;'
add='span.L@CLASS@ a:visited {color: red;}'
add0='span.L@CLASS@ a:link {color: red;}'
add1='span.L@CLASS@ a:active {color: red;}'
add2='span.L@CLASS@ a:hover {color: black; text-decoration: none;}' :)
Defines a class of tooltips with the hovering text area in black and the links in red; on hovering, the text gets a gray background, and the link becomes black and without decoration. The same technique could also be used for other html tags contained inside the text hovering area. CaveatsBrowser support has been only tested for Konqueror, Firefox and IE. CSS support varies wildly between browser versions, so much test is needed, as this is just an alfa version of the recipe. For technical details about the inner works of the recipe, the source code explains the generated css/html code and code/markup structure. NotesRelease notes
See also
ContributorsCommentsSee discussion at CSSToolTipsToGo-Talk User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |