/** * Load the JavaScript behavior. * * @param string $group The pane identifier. * @param array $params Array of options. * * @return void * * @since 1.6 * @deprecated __DEPLOY_VERSION__ These helpers are dependent on the deprecated MooTools support */ protected static function loadBehavior($group, $params = array()) { static $loaded = array(); if (!array_key_exists((string) $group, $loaded)) { // Include MooTools framework JHtml::_('behavior.framework', true); $opt['onActive'] = isset($params['onActive']) ? '\\' . $params['onActive'] : null; $opt['onBackground'] = isset($params['onBackground']) ? '\\' . $params['onBackground'] : null; $opt['display'] = isset($params['startOffset']) ? (int) $params['startOffset'] : null; $opt['titleSelector'] = "dt.tabs"; $opt['descriptionSelector'] = "dd.tabs"; // When use storage is set and value is false - By default we allow to use storage $opt['useStorage'] = isset($params['useCookie']) && !$params['useCookie'] ? false : true; $options = JHtml::getJSObject($opt); $js = ' window.addEvent(\'domready\', function(){ $$(\'dl#' . $group . '.tabs\').each(function(tabs){ new JTabs(tabs, ' . $options . '); }); });'; $document = JFactory::getDocument(); $document->addScriptDeclaration($js); JHtml::_('script', 'system/tabs.js', false, true); $loaded[(string) $group] = true; } }
/** * 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 * * @since 3.0 */ 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']) ? (bool) $params['parent'] : false; $opt['toggle'] = isset($params['toggle']) ? (bool) $params['toggle'] : true; $opt['active'] = isset($params['active']) ? (string) $params['active'] : ''; $options = JHtml::getJSObject($opt); // Attach accordion to document JFactory::getDocument()->addScriptDeclaration("(function(\$){\n\t\t\t\$('#{$selector}').collapse({$options});\n\t\t})(jQuery);"); // Set static array static::$loaded[__METHOD__][$sig] = true; static::$loaded[__METHOD__]['active'] = $opt['active']; } return '<div id="' . $selector . '" class="accordion">'; }
/** * Internal method to get a JavaScript object notation string from an array * * @param array $array The array to convert to JavaScript object notation * * @return string JavaScript object notation representation of the array * * @since 1.5 * @deprecated 13.3 (Platform) & 4.0 (CMS) - Use JHtml::getJSObject() instead. */ protected static function _getJSObject($array = array()) { JLog::add('JHtmlBehavior::_getJSObject() is deprecated. JHtml::getJSObject() instead..', JLog::WARNING, 'deprecated'); return JHtml::getJSObject($array); }
/** * 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 * * - onShow function This event fires immediately when the show instance method is called. * - onShown function This event is fired when a collapse element has been made visible to the user * (will wait for css transitions to complete). * - onHide function This event is fired immediately when the hide method has been called. * - onHidden function This event is fired when a collapse element has been hidden from the user * (will wait for css transitions to complete). * * @return string HTML for the accordian * * @since 3.0 */ public static function startAccordion($selector = 'myAccordian', $params = array()) { if (!isset(static::$loaded[__METHOD__][$selector])) { // Include Bootstrap framework static::framework(); // Setup options object $opt['parent'] = isset($params['parent']) ? $params['parent'] == true ? '#' . $selector : $params['parent'] : false; $opt['toggle'] = isset($params['toggle']) ? (bool) $params['toggle'] : ($opt['parent'] === false || isset($params['active']) ? false : true); $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); $opt['active'] = isset($params['active']) ? (string) $params['active'] : ''; // Build the script. $script = array(); $script[] = "jQuery(document).ready(function(\$){"; $script[] = "\t\$('#" . $selector . "').collapse(" . $options . ")"; if ($onShow) { $script[] = "\t.on('show', " . $onShow . ")"; } if ($onShown) { $script[] = "\t.on('shown', " . $onShown . ")"; } if ($onHide) { $script[] = "\t.on('hideme', " . $onHide . ")"; } if ($onHidden) { $script[] = "\t.on('hidden', " . $onHidden . ")"; } $script[] = "});"; // Attach accordion to document JFactory::getDocument()->addScriptDeclaration(implode("\n", $script)); // Set static array static::$loaded[__METHOD__][$selector] = $opt; return '<div id="' . $selector . '" class="accordion">'; } }
/** * Creates a tab pane * * @param string $selector The pane identifier. * @param array $params The parameters for the pane * * @return string * * @since 3.0 */ public static function startPane($selector = 'myTab', $params = array()) { $sig = md5(serialize(array($selector, $params))); if (!isset(self::$loaded[__METHOD__][$sig])) { // Include Bootstrap framework self::framework(); // Setup options object $opt['active'] = isset($params['active']) && $params['active'] ? (string) $params['active'] : ''; $options = JHtml::getJSObject($opt); // Attach tooltips to document JFactory::getDocument()->addScriptDeclaration("(function(\$){\n\t\t\t\t\t\$('#{$selector} a').click(function (e) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\$(this).tab('show');\n\t\t\t\t\t});\n\t\t\t\t})(jQuery);"); // Set static array self::$loaded[__METHOD__][$sig] = true; self::$loaded[__METHOD__][$selector]['active'] = $opt['active']; } return '<div class="tab-content" id="' . $selector . 'Content">'; }
/** * 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 = JHtml::getJSObject($opt); // Attach tabs to document JFactory::getDocument()->addScriptDeclaration(JLayoutHelper::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 = JLayoutHelper::render('libraries.cms.html.bootstrap.starttabset', array('selector' => $selector)); return $html; }
/** * Load the JavaScript behavior. * * @param string $group The pane identifier. * @param array $params Array of options. * * @return void * * @since 1.6 * @deprecated __DEPLOY_VERSION__ These helpers are dependent on the deprecated MooTools support */ protected static function loadBehavior($group, $params = array()) { static $loaded = array(); if (!array_key_exists($group, $loaded)) { // Get the JInput object $input = JFactory::getApplication()->input; $loaded[$group] = true; // Include mootools framework. JHtml::_('behavior.framework', true); $document = JFactory::getDocument(); $display = isset($params['startOffset']) && isset($params['startTransition']) && $params['startTransition'] ? (int) $params['startOffset'] : null; $show = isset($params['startOffset']) && !(isset($params['startTransition']) && $params['startTransition']) ? (int) $params['startOffset'] : null; $opt['onActive'] = "\\function(toggler, i) {toggler.addClass('pane-toggler-down');" . "toggler.removeClass('pane-toggler');i.addClass('pane-down');i.removeClass('pane-hide');Cookie.write('jpanesliders_" . $group . "',\$\$('div#" . $group . ".pane-sliders > .panel > h3').indexOf(toggler));}"; $opt['onBackground'] = "\\function(toggler, i) {toggler.addClass('pane-toggler');" . "toggler.removeClass('pane-toggler-down');i.addClass('pane-hide');i.removeClass('pane-down');if(\$\$('div#" . $group . ".pane-sliders > .panel > h3').length==\$\$('div#" . $group . ".pane-sliders > .panel > h3.pane-toggler').length) Cookie.write('jpanesliders_" . $group . "',-1);}"; $opt['duration'] = isset($params['duration']) ? (int) $params['duration'] : 300; $opt['display'] = isset($params['useCookie']) && $params['useCookie'] ? $input->cookie->get('jpanesliders_' . $group, $display, 'integer') : $display; $opt['show'] = isset($params['useCookie']) && $params['useCookie'] ? $input->cookie->get('jpanesliders_' . $group, $show, 'integer') : $show; $opt['opacity'] = isset($params['opacityTransition']) && $params['opacityTransition'] ? 'true' : 'false'; $opt['alwaysHide'] = isset($params['allowAllClose']) && !$params['allowAllClose'] ? 'false' : 'true'; $options = JHtml::getJSObject($opt); $js = "window.addEvent('domready', function(){ new Fx.Accordion(\$\$('div#" . $group . ".pane-sliders > .panel > h3.pane-toggler'), \$\$('div#" . $group . ".pane-sliders > .panel > div.pane-slider'), " . $options . "); });"; $document->addScriptDeclaration($js); } }
/** * Add javascript support for Bootstrap typeahead * * @param string $selector The selector for the typeahead element. * @param array $params An array of options for the typeahead element. * Options for the tooltip can be: * - source array, function The data source to query against. May be an array of strings or a function. * The function is passed two arguments, the query value in the input field and the * process callback. The function may be used synchronously by returning the data * source directly or asynchronously via the process callback's single argument. * - items number The max number of items to display in the dropdown. * - minLength number The minimum character length needed before triggering autocomplete suggestions * - matcher function The method used to determine if a query matches an item. Accepts a single argument, * the item against which to test the query. Access the current query with this.query. * Return a boolean true if query is a match. * - sorter function Method used to sort autocomplete results. Accepts a single argument items and has * the scope of the typeahead instance. Reference the current query with this.query. * - updater function The method used to return selected item. Accepts a single argument, the item and * has the scope of the typeahead instance. * - highlighter function Method used to highlight autocomplete results. Accepts a single argument item and * has the scope of the typeahead instance. Should return html. * * @return void * * @since 3.0 */ public static function typeahead($selector = '.typeahead', $params = array()) { if (!isset(static::$loaded[__METHOD__][$selector])) { // Include Bootstrap framework static::framework(); // Setup options object $opt['source'] = isset($params['source']) ? $params['source'] : '[]'; $opt['items'] = isset($params['items']) ? (int) $params['items'] : 8; $opt['minLength'] = isset($params['minLength']) ? (int) $params['minLength'] : 1; $opt['matcher'] = isset($params['matcher']) ? (string) $params['matcher'] : null; $opt['sorter'] = isset($params['sorter']) ? (string) $params['sorter'] : null; $opt['updater'] = isset($params['updater']) ? (string) $params['updater'] : null; $opt['highlighter'] = isset($params['highlighter']) ? (int) $params['highlighter'] : null; $options = JHtml::getJSObject($opt); // Attach tooltips to document JFactory::getDocument()->addScriptDeclaration("jQuery(document).ready(function()\n\t\t\t\t{\n\t\t\t\t\tjQuery('" . $selector . "').typeahead(" . $options . ");\n\t\t\t\t});"); // Set static array static::$loaded[__METHOD__][$selector] = true; } return; }
$options['selectors'] = $selectors; } // get functions $extensionsParams->set('module.value', $params->get('function_done_filters')); if ($functionDone = trim(FieldsandfiltersExtensionsHelper::getParams('function_done_filters', $extensionsParams))) { $fn['done'] = '\\' . $functionDone; } // hash navigation if ($componentParams->get('hash_navigation_enabled')) { $options['hashNavigation'] = array('enabled' => true, 'prefix' => $componentParams->get('hash_navigation_prefix', '#!')); } if (!empty($fn) && is_array($fn)) { $options['fn'] = $fn; } // Import JS && CSS JHtml::_('FieldsandfiltersHtml.filters.framework'); if (FieldsandfiltersFactory::isVersion()) { $options = JHtml::getJSObject($options); } else { $options = JHtml::_('FieldsandfiltersHtml.joomla.getJSObject', $options); } $script[] = 'jQuery(document).ready(function($) {'; $script[] = ' $( "#faf-form-' . $module->id . '" ).fieldsandfilters(' . $options . ');'; if ($params->get('show_random', 0)) { $script[] = sprintf(' $( "#faf-form-random-' . $module->id . '" ).fieldsandfilters("random:%s");', $componentParams->get('random_type_filters', 'all')); } $script[] = '});'; JFactory::getDocument()->addScriptDeclaration(implode("\n", $script)); require JModuleHelper::getLayoutPath('mod_fieldsandfilters_filters', $params->get('layout', 'default')); } }