1 <?php
2 /**
3 * @package Joomla.Libraries
4 * @subpackage HTML
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('JPATH_PLATFORM') or die;
11
12 /**
13 * Utility class for Tabs elements.
14 *
15 * @since 1.6
16 * @deprecated 3.7.0 These helpers are dependent on the deprecated MooTools support
17 */
18 abstract class JHtmlTabs
19 {
20 /**
21 * Creates a panes and creates the JavaScript object for it.
22 *
23 * @param string $group The pane identifier.
24 * @param array $params An array of option.
25 *
26 * @return string
27 *
28 * @since 1.6
29 * @deprecated 3.7.0 These helpers are dependent on the deprecated MooTools support
30 */
31 public static function start($group = 'tabs', $params = array())
32 {
33 static::loadBehavior($group, $params);
34
35 return '<dl class="tabs" id="' . $group . '"><dt style="display:none;"></dt><dd style="display:none;">';
36 }
37
38 /**
39 * Close the current pane
40 *
41 * @return string HTML to close the pane
42 *
43 * @since 1.6
44 * @deprecated 3.7.0 These helpers are dependent on the deprecated MooTools support
45 */
46 public static function end()
47 {
48 return '</dd></dl>';
49 }
50
51 /**
52 * Begins the display of a new panel.
53 *
54 * @param string $text Text to display.
55 * @param string $id Identifier of the panel.
56 *
57 * @return string HTML to start a new panel
58 *
59 * @since 1.6
60 * @deprecated 3.7.0 These helpers are dependent on the deprecated MooTools support
61 */
62 public static function panel($text, $id)
63 {
64 return '</dd><dt class="tabs ' . $id . '"><span><h3><a href="javascript:void(0);">' . $text . '</a></h3></span></dt><dd class="tabs">';
65 }
66
67 /**
68 * Load the JavaScript behavior.
69 *
70 * @param string $group The pane identifier.
71 * @param array $params Array of options.
72 *
73 * @return void
74 *
75 * @since 1.6
76 * @deprecated 3.7.0 These helpers are dependent on the deprecated MooTools support
77 */
78 protected static function loadBehavior($group, $params = array())
79 {
80 static $loaded = array();
81
82 if (!array_key_exists((string) $group, $loaded))
83 {
84 // Include MooTools framework
85 JHtml::_('behavior.framework', true);
86
87 $opt['onActive'] = isset($params['onActive']) ? '\\' . $params['onActive'] : null;
88 $opt['onBackground'] = isset($params['onBackground']) ? '\\' . $params['onBackground'] : null;
89 $opt['display'] = isset($params['startOffset']) ? (int) $params['startOffset'] : null;
90 $opt['titleSelector'] = 'dt.tabs';
91 $opt['descriptionSelector'] = 'dd.tabs';
92
93 // When use storage is set and value is false - By default we allow to use storage
94 $opt['useStorage'] = !(isset($params['useCookie']) && !$params['useCookie']);
95
96 $options = JHtml::getJSObject($opt);
97
98 $js = ' window.addEvent(\'domready\', function(){
99 $$(\'dl#' . $group . '.tabs\').each(function(tabs){
100 new JTabs(tabs, ' . $options . ');
101 });
102 });';
103
104 $document = JFactory::getDocument();
105 $document->addScriptDeclaration($js);
106 JHtml::_('script', 'system/tabs.js', array('version' => 'auto', 'relative' => true));
107
108 $loaded[(string) $group] = true;
109 }
110 }
111 }
112