/** * Add javascript support for Bootstrap accordians and insert the accordian * * @param string $selector The ID selector for the tooltip. * @param array $params An array of options for the tooltip. * Options for the tooltip can be: * - parent selector If selector then all collapsible elements under the specified parent will be closed when this * collapsible item is shown. (similar to traditional accordion behavior) * - toggle boolean Toggles the collapsible element on invocation * - active string Sets the active slide during load * * @return string HTML for the accordian */ public static function startAccordion($selector = 'myAccordian', $params = array()) { $sig = md5(serialize(array($selector, $params))); if (!isset(static::$loaded[__METHOD__][$sig])) { // Include Bootstrap framework static::framework(); // Setup options object $opt['parent'] = isset($params['parent']) && $params['parent'] ? (bool) $params['parent'] : false; $opt['toggle'] = isset($params['toggle']) && $params['toggle'] ? (bool) $params['toggle'] : true; $opt['active'] = isset($params['active']) && $params['active'] ? (string) $params['active'] : ''; $options = RHtml::getJSObject($opt); // Attach accordion to document JFactory::getDocument()->addScriptDeclaration("(function(\$){\n\t\t\t\t\t\$('#{$selector}').collapse({$options});\n\t\t\t\t})(jQuery);"); // Set static array static::$loaded[__METHOD__][$sig] = true; static::$loaded[__METHOD__]['active'] = $opt['active']; } return '<div id="' . $selector . '" class="accordion">'; }
/** * Add javascript support for Bootstrap modals * * @param string $selector The ID selector for the modal. * @param array $params An array of options for the modal. * Options for the modal can be: * - backdrop boolean Includes a modal-backdrop element. * - keyboard boolean Closes the modal when escape key is pressed. * - show boolean Shows the modal when initialized. * - remote string An optional remote URL to load * * @return void */ public static function modal($selector = 'modal', $params = array()) { $sig = md5(serialize(array($selector, $params))); if (!isset(static::$loaded[__METHOD__][$sig])) { // Include Bootstrap framework static::framework(); // Setup options object $opt['backdrop'] = isset($params['backdrop']) && $params['backdrop'] ? (bool) $params['backdrop'] : true; $opt['keyboard'] = isset($params['keyboard']) && $params['keyboard'] ? (bool) $params['keyboard'] : true; $opt['show'] = isset($params['show']) && $params['show'] ? (bool) $params['show'] : true; $opt['remote'] = isset($params['remote']) && $params['remote'] ? $params['remote'] : ''; $options = RHtml::getJSObject($opt); // Attach the modal to document JFactory::getDocument()->addScriptDeclaration("(function(\$){\n\t\t\t\t\t\$('#{$selector}').modal({$options});\n\t\t\t\t\t})(jQuery);"); // Set static array static::$loaded[__METHOD__][$sig] = true; } return; }
/** * Creates a tab pane * * @param string $selector The pane identifier. * @param array $params The parameters for the pane * * @return string */ public static function startTabSet($selector = 'myTab', $params = array()) { $sig = md5(serialize(array($selector, $params))); if (!isset(static::$loaded[__METHOD__][$sig])) { // Include Bootstrap framework static::framework(); // Setup options object $opt['active'] = isset($params['active']) && $params['active'] ? (string) $params['active'] : ''; $options = RHtml::getJSObject($opt); // Attach tabs to document JFactory::getDocument()->addScriptDeclaration(RLayoutHelper::render('libraries.cms.html.bootstrap.starttabsetscript', array('selector' => $selector))); // Set static array static::$loaded[__METHOD__][$sig] = true; static::$loaded[__METHOD__][$selector]['active'] = $opt['active']; } $html = RLayoutHelper::render('libraries.cms.html.bootstrap.starttabset', array('selector' => $selector)); return $html; }