Skip to content

Commit

Permalink
Using bootstrap tooltips instead of mootools tips.
Browse files Browse the repository at this point in the history
  • Loading branch information
Achal-Aggarwal committed Apr 15, 2014
1 parent 260312a commit 9c83211
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
Expand Up @@ -11,7 +11,7 @@

// Load tooltips behavior
JHtml::_('behavior.formvalidation');
JHtml::_('behavior.tooltip');
JHtml::_('bootstrap.tooltip');
JHtml::_('formbehavior.chosen', 'select');
?>
<script type="text/javascript">
Expand Down
Expand Up @@ -13,7 +13,7 @@
$template = $app->getTemplate();

// Load the tooltip behavior.
JHtml::_('behavior.tooltip');
JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.formvalidation');
JHtml::_('formbehavior.chosen', 'select');
?>
Expand Down
Expand Up @@ -11,7 +11,7 @@
JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN'));

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.tooltip');
JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('jquery.framework');

Expand Down
2 changes: 1 addition & 1 deletion components/com_config/view/config/tmpl/default.php
Expand Up @@ -11,7 +11,7 @@

// Load tooltips behavior
JHtml::_('behavior.formvalidation');
JHtml::_('behavior.tooltip');
JHtml::_('bootstrap.tooltip');
JHtml::_('formbehavior.chosen', 'select');
?>
<script type="text/javascript">
Expand Down
38 changes: 32 additions & 6 deletions libraries/cms/html/bootstrap.php
Expand Up @@ -468,16 +468,42 @@ public static function tooltip($selector = '.hasTooltip', $params = array())
$opt['delay'] = isset($params['delay']) ? (int) $params['delay'] : null;
$opt['container'] = isset($params['container']) ? $params['container'] : 'body';
$opt['template'] = isset($params['template']) ? (string) $params['template'] : null;
$onShow = isset($params['onShow']) ? (string) $params['onShow'] : null;
$onShown = isset($params['onShown']) ? (string) $params['onShown'] : null;
$onHide = isset($params['onHide']) ? (string) $params['onHide'] : null;
$onHidden = isset($params['onHidden']) ? (string) $params['onHidden'] : null;

$options = JHtml::getJSObject($opt);

// Build the script.
$script = array();
$script[] = "jQuery(document).ready(function(){";
$script[] = "\tjQuery('" . $selector . "').tooltip(" . $options . ");";

if ($onShow)
{
$script[] = "\tjQuery('" . $selector . "').on('show.bs.tooltip', " . $onShow . ");";
}

if ($onShown)
{
$script[] = "\tjQuery('" . $selector . "').on('shown.bs.tooltip', " . $onShown . ");";
}

if ($onHide)
{
$script[] = "\tjQuery('" . $selector . "').on('hide.bs.tooltip', " . $onHide . ");";
}

if ($onHidden)
{
$script[] = "\tjQuery('" . $selector . "').on('hidden.bs.tooltip', " . $onHidden . ");";
}

$script[] = "});";

// Attach tooltips to document
JFactory::getDocument()->addScriptDeclaration(
"jQuery(document).ready(function()
{
jQuery('" . $selector . "').tooltip(" . $options . ");
});"
);
JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));

// Set static array
static::$loaded[__METHOD__][$selector] = true;
Expand Down

0 comments on commit 9c83211

Please sign in to comment.