API15

JHTMLBehavior/tooltip

From Joomla! Documentation

< API15:JHTMLBehavior
Revision as of 12:22, 12 May 2013 by JoomlaWikiBot (talk | contribs) (removing red link to edit, no existant pages)

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax[edit]

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

Defined in[edit]

libraries/joomla/html/html/behavior.php

Importing[edit]

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

Source Body[edit]

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;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

<CodeExamplesForm />