glossary - appearance of tooltip too short

Creating and modifying plugins.
Post Reply
hannelore
Regular
Posts: 11
Joined: Tue Oct 18, 2005 3:16 pm
Location: Kissimmee, Florida
Contact:

glossary - appearance of tooltip too short

Post 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!
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: glossary - appearance of tooltip too short

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
g00dman
Regular
Posts: 11
Joined: Sat Oct 22, 2005 11:57 pm
Contact:

Solution

Post 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.
Last edited by g00dman on Thu Dec 22, 2005 11:30 pm, edited 1 time in total.
g00dman
Regular
Posts: 11
Joined: Sat Oct 22, 2005 11:57 pm
Contact:

Better solution ;-)

Post 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);
                }            
            }
Post Reply