Actions

API16

JHtmlBehavior/tooltip

From Joomla! Documentation

< API16:JHtmlBehavior
Revision as of 21:56, 13 May 2013 by JoomlaWikiBot (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.

[<! removed edit link to red link >]

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

Contents

Syntax

static 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

public static function tooltip($selector='.hasTip', $params = array())
{
        static $tips;
 
        if (!isset($tips)) {
                $tips = array();
        }
 
        // Include mootools framework
        JHtml::_('behavior.framework', true);
 
        $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();
        $document->addScriptDeclaration("
        window.addEvent('domready', function() {
                $$('$selector').each(function(el) {
                        var title = el.get('title');
                        if (title) {
                                var parts = title.split('::', 2);
                                el.store('tip:title', parts[0]);
                                el.store('tip:text', parts[1]);
                        }
                });
                var JTooltips = new Tips($$('$selector'), $options);
        });");
 
        // Set static array
        $tips[$sig] = true;
        return;
}

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

Examples

<CodeExamplesForm />