Page 1 of 1

glossary - appearance of tooltip too short

Posted: Wed Oct 26, 2005 1:31 am
by hannelore
Hi,

I just installed the glossary plug in and like it, performance seems good with simple cache.

Only with longer definitions the tooltip disappears too fast, before one could read it to the end.

Is it possible to change this?

Thanks for your help!

Re: glossary - appearance of tooltip too short

Posted: Wed Oct 26, 2005 10:48 am
by garvinhicking
Sadly this is a browser issue and cannot be changed by plugins. The only way to bypass this is to replace the tooltip handler with a custom JavaScript like overLib - but that's much work to do. You might still want to ask the nice plugin author if he'd like to do the job *gg*

Best regards,
Garvin

Solution

Posted: Thu Dec 22, 2005 3:49 pm
by g00dman
---Attention: There's a newer version of this hack in the next post! ---

Well, just in case someone's still waiting for a solution of this problem, I found a solution.

You need the "Tooltips"-Plugin by Enrico Stahn as well as the "Glossary"-Plugin by Rob Antonishen.
Make sure that the Glossary-Plugin appears in the List of Plugins above the Tooltips plugin!

After that you have to edit the file "plugins/serendipity_event_glossary/serendipity_event_glossary.php".
Starting at line 210, you'll find the following code:

Code: Select all

if (serendipity_db_bool($this->get_config('markall',false))) {
                if ($this->get_config('type')=='HILITE') {
                    $text = preg_replace($_pattern, '<span title="' . $glossaryitem[1] . '" class="serendipity_glossaryMarkup">$1</span>', $text);
                } else { /* 'APPEND' */
                    $text = preg_replace($_pattern, '$1<sup><span title="' . $glossaryitem[1] . '" class="serendipity_glossaryMarkup">[?]</span></sup>', $text);
                }
            } else {
                if ($this->get_config('type')=='HILITE') {
                    $text = preg_replace($_pattern, '<span title="' . $glossaryitem[1] . '" class="serendipity_glossaryMarkup">$1</span>', $text, 1);
                } else { /* 'APPEND' */
                    $text = preg_replace($_pattern, '$1<sup><span title="' . $glossaryitem[1] . '" class="serendipity_glossaryMarkup">[?]</span></sup>', $text, 1);
                }            
            }
Now we simply change the code so that no longer a <span>-Tag is used - we want the plugin to use the [s9y-tooltips]-Tag that is being provided by the Tooltips-Plugin:

Code: Select all

if (serendipity_db_bool($this->get_config('markall',false))) {
                if ($this->get_config('type')=='HILITE') {
                    $text = preg_replace($_pattern, '[s9y-tooltips ' . $glossaryitem[1] . ']$1[/s9y-tooltips]', $text);
                } else { /* 'APPEND' */
                    $text = preg_replace($_pattern, '[s9y-tooltips ' . $glossaryitem[1] . ']$1<small>[?]</small>[/s9y-tooltips]', $text);
                }
            } else {
                if ($this->get_config('type')=='HILITE') {
                    $text = preg_replace($_pattern, '[s9y-tooltips ' . $glossaryitem[1] . ']$1[/s9y-tooltips]', $text, 1);
                } else { /* 'APPEND' */
                    $text = preg_replace($_pattern, '[s9y-tooltips ' . $glossaryitem[1] . ']$1<small>[?]</small>[/s9y-tooltips]', $text, 1);
                }            
            }
Please note that I made two other small changes to the code: If you choose to have a small [?] appended to the word, this [?] will be formatted using <small> instead of <sup>. And, last but not least, even if you choose "append", you can point your mouse at the whole word to see the tooltip.
For an exmaple, have a look at this entry at my blog.

Better solution ;-)

Posted: Thu Dec 22, 2005 11:29 pm
by g00dman
Well, I found an even nicer way for combining Tooltips and Glossary plugins:
The "old" method was to replace the acronym with an extended version of it, using the [s9y-tooltips]-tag provided by the tooltips-plugin.
But why use this tag instead of directly inserting the javascript-code to the acronym? This way you still need to have both plugins installed, but you may diable all functions of the tooltips-plugin, so it won't slow down your blog at all.
After that, change your "plugins/serendipity_event_glossary/serendipity_event_glossary.php" again:
The original file had the following code starting at line 210:

Code: Select all

if (serendipity_db_bool($this->get_config('markall',false))) {
                if ($this->get_config('type')=='HILITE') {
                    $text = preg_replace($_pattern, '<span title="' . $glossaryitem[1] . '" class="serendipity_glossaryMarkup">$1</span>', $text);
                } else { /* 'APPEND' */
                    $text = preg_replace($_pattern, '$1<sup><span title="' . $glossaryitem[1] . '" class="serendipity_glossaryMarkup">[?]</span></sup>', $text);
                }
            } else {
                if ($this->get_config('type')=='HILITE') {
                    $text = preg_replace($_pattern, '<span title="' . $glossaryitem[1] . '" class="serendipity_glossaryMarkup">$1</span>', $text, 1);
                } else { /* 'APPEND' */
                    $text = preg_replace($_pattern, '$1<sup><span title="' . $glossaryitem[1] . '" class="serendipity_glossaryMarkup">[?]</span></sup>', $text, 1);
                }            
            }
Replace it by this code:

Code: Select all

if (serendipity_db_bool($this->get_config('markall',false))) {
                if ($this->get_config('type')=='HILITE') {
                    $text = preg_replace($_pattern, '<acronym href="javascript:void(0);" onMouseOver="return overlib(\'' . addslashes($glossaryitem[1]) . '\');" onMouseOut="return nd();">$1</acronym>', $text);
                } else { /* 'APPEND' */
                    $text = preg_replace($_pattern, '<acronym href="javascript:void(0);" onMouseOver="return overlib(\'' . addslashes($glossaryitem[1]) . '\');" onMouseOut="return nd();">$1 <small>[?]</small></acronym>', $text);
                }
            } else {
                if ($this->get_config('type')=='HILITE') {
                    $text = preg_replace($_pattern, '<acronym href="javascript:void(0);" onMouseOver="return overlib(\'' . addslashes($glossaryitem[1]) . '\');" onMouseOut="return nd();">$1</acronym>', $text, 1);
                } else { /* 'APPEND' */
                    $text = preg_replace($_pattern, '<acronym href="javascript:void(0);" onMouseOver="return overlib(\'' . addslashes($glossaryitem[1]) . '\');" onMouseOut="return nd();">$1 <small>[?]</small></acronym>', $text, 1);
                }            
            }