<?php if (!defined('PmWiki')) exit(); /* +----------------------------------------------------------------------+ | linkcsstooltip.php for PmWiki. Copyright 2008 Hans Bracker | This program is free software; you can redistribute it and/or modify | it under the terms of the GNU General Public License, Version 2, as | published by the Free Software Foundation. | http://www.gnu.org/copyleft/gpl.html | This program is distributed in the hope that it will be useful, | but WITHOUT ANY WARRANTY; without even the implied warranty of | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | GNU General Public License for more details. +----------------------------------------------------------------------+ | Adds link markup [[target | link text |: tooltip text :]] | for links with styled tooltip. The tooltip text can be styled using | wiki styles, Attached images, page text variables or included text +----------------------------------------------------------------------+ */ $RecipeInfo['LinkCSSToolTip']['Version'] = '2020-07-26'; ## [[target | text |: tooltip :]] linktext plus tooltip ## or [[target | + |: tooltip :]] title plus tooltip Markup('[[||','<if', "/(?>\\[\\[([^|\\]]*)\\|\\s*)([^|\\]]*?)\\s*\\|:\\s*(.*?)\\s*:\\]\\]($SuffixPattern)/s", "ToolTipLinkTextMarkup"); function ToolTipLinkTextMarkup($m) { extract($GLOBALS['MarkupToHTML']); if ($m[3]=='+') $m[3] = PageVar(MakePageName($pagename, $m[1]), '$Title'); return ToolTipLink($pagename, $m[1], $m[2], $m[3], $m[4]); } function ToolTipLink($pagename, $tgt, $txt, $tt='', $suffix='') { global $LinkToolTipFmt, $WikiStyleCSS; $WikiStyleCSS[] = 'left|top'; static $cnt = 50; $cnt++; $tt = str_replace("\\\\",'\\\\(:nl:)',$tt); $tt = MarkupToHTML($pagename, $tt); preg_match("/style='(.*?)'/", $tt, $m); $tt = str_replace($m[0],'',$tt); $txt = MarkupToHTML($pagename, $txt); $txt = str_replace("<p>",'',$txt); $txt = str_replace("</p>",'',$txt); $txt = trim($txt); $ttdiv = (!$tt=='') ? "<span id='ttip{$cnt}' class='ttip' style='z-index:{$cnt}; $m[1]'>$tt</span>" : ''; if ($tgt=='#') $link = "<span class='ttterm'>".$txt."</span>"; else $link = MakeLink($pagename, $tgt, $txt, $suffix, ''); return Keep("<div class='ttwrap'>".$link.$ttdiv."</div>", 'L'); } $HTMLStylesFmt['ttip'] = " div.ttwrap { position:relative; display:inline; } div.ttwrap span.ttterm { color:#006; border-bottom:1px dotted gray; } div.ttwrap span.ttip { display:none; } div.ttwrap:hover span.ttip { display:block; position:absolute; left:2em; top:1.6em; min-width:12em; border:1px solid #cc9; -moz-border-radius:8px; -webkit-border-radius: 8px; padding:0.3em 0.7em; background:#ffc; color: #333; font-size:75%; line-height:1.3em; /*text-align: center;*/ text-decoration:none; } * html div.ttwrap:hover { z-index:50; background:; } /* background:; for tricking IE*/ * html div.ttwrap:hover span.ttip { width:12em; } /* min-width for IE */ div.ttwrap:hover span.ttip div { display:inline; padding:0; margin:0; } /* for images wrapped in a div */ ";