Actions

API15

JHTMLBehavior/tooltip

From Joomla! Documentation

< API15:JHTMLBehavior
Revision as of 17:21, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

[Edit Descripton]

Description:JHTMLBehavior/tooltip

Contents

Syntax

tooltip($selector='.hasTip', $params=array())
Parameter Name Default Value Description
$selector '.hasTip'
$params array()

Defined in

libraries/joomla/html/html/behavior.php

Importing

jimport( 'joomla.html.html.behavior' );

Source Body

function tooltip($selector='.hasTip', $params = array())
{
        static $tips;
 
        if (!isset($tips)) {
                $tips = array();
        }
 
        // Include mootools framework
        JHTMLBehavior::mootools();
 
        $sig = md5(serialize(array($selector,$params)));
        if (isset($tips[$sig]) && ($tips[$sig])) {
                return;
        }
 
        // Setup options object
        $opt['maxTitleChars']   = (isset($params['maxTitleChars']) && ($params['maxTitleChars'])) ? (int)$params['maxTitleChars'] : 50 ;
        // offsets needs an array in the format: array('x'=>20, 'y'=>30)
        $opt['offsets']                 = (isset($params['offsets']) && (is_array($params['offsets']))) ? $params['offsets'] : null;
        $opt['showDelay']               = (isset($params['showDelay'])) ? (int)$params['showDelay'] : null;
        $opt['hideDelay']               = (isset($params['hideDelay'])) ? (int)$params['hideDelay'] : null;
        $opt['className']               = (isset($params['className'])) ? $params['className'] : null;
        $opt['fixed']                   = (isset($params['fixed']) && ($params['fixed'])) ? '\\true' : '\\false';
        $opt['onShow']                  = (isset($params['onShow'])) ? '\\'.$params['onShow'] : null;
        $opt['onHide']                  = (isset($params['onHide'])) ? '\\'.$params['onHide'] : null;
 
        $options = JHTMLBehavior::_getJSObject($opt);
 
        // Attach tooltips to document
        $document =& JFactory::getDocument();
        $tooltipInit = '                window.addEvent(\'domready\', function(){ var JTooltips = new Tips($$(\''.$selector.'\'), '.$options.'); });';
        $document->addScriptDeclaration($tooltipInit);
 
        // Set static array
        $tips[$sig] = true;
        return;
}

[Edit See Also] SeeAlso:JHTMLBehavior/tooltip

Examples

<CodeExamplesForm />