1 <?php
2 3 4 5 6 7 8
9
10 defined('JPATH_PLATFORM') or die;
11
12 13 14 15 16 17
18 abstract class JHtmlSliders
19 {
20 21 22 23 24 25 26 27 28 29 30
31 public static function start($group = 'sliders', $params = array())
32 {
33 static::loadBehavior($group, $params);
34
35 return '<div id="' . $group . '" class="pane-sliders"><div style="display:none;"><div>';
36 }
37
38 39 40 41 42 43 44 45
46 public static function end()
47 {
48 return '</div></div></div>';
49 }
50
51 52 53 54 55 56 57 58 59 60 61
62 public static function panel($text, $id)
63 {
64 return '</div></div><div class="panel"><h3 class="pane-toggler title" id="' . $id . '"><a href="javascript:void(0);"><span>' . $text
65 . '</span></a></h3><div class="pane-slider content">';
66 }
67
68 69 70 71 72 73 74 75 76 77 78
79 protected static function loadBehavior($group, $params = array())
80 {
81 static $loaded = array();
82
83 if (!array_key_exists($group, $loaded))
84 {
85
86 $input = JFactory::getApplication()->input;
87
88 $loaded[$group] = true;
89
90
91 JHtml::_('behavior.framework', true);
92
93 $document = JFactory::getDocument();
94
95 $display = (isset($params['startOffset']) && isset($params['startTransition']) && $params['startTransition'])
96 ? (int) $params['startOffset'] : null;
97 $show = (isset($params['startOffset']) && !(isset($params['startTransition']) && $params['startTransition']))
98 ? (int) $params['startOffset'] : null;
99
100 $opt['onActive'] = "\\function(toggler, i) {toggler.addClass('pane-toggler-down');" .
101 "toggler.removeClass('pane-toggler');i.addClass('pane-down');i.removeClass('pane-hide');Cookie.write('jpanesliders_"
102 . $group . "',$$('div#" . $group . ".pane-sliders > .panel > h3').indexOf(toggler));}";
103 $opt['onBackground'] = "\\function(toggler, i) {toggler.addClass('pane-toggler');" .
104 "toggler.removeClass('pane-toggler-down');i.addClass('pane-hide');i.removeClass('pane-down');if($$('div#"
105 . $group . ".pane-sliders > .panel > h3').length==$$('div#" . $group
106 . ".pane-sliders > .panel > h3.pane-toggler').length) Cookie.write('jpanesliders_" . $group . "',-1);}";
107 $opt['duration'] = isset($params['duration']) ? (int) $params['duration'] : 300;
108 $opt['display'] = (isset($params['useCookie']) && $params['useCookie']) ? $input->cookie->get('jpanesliders_' . $group, $display, 'integer')
109 : $display;
110 $opt['show'] = (isset($params['useCookie']) && $params['useCookie']) ? $input->cookie->get('jpanesliders_' . $group, $show, 'integer') : $show;
111 $opt['opacity'] = (isset($params['opacityTransition']) && $params['opacityTransition']) ? 'true' : 'false';
112 $opt['alwaysHide'] = (isset($params['allowAllClose']) && (!$params['allowAllClose'])) ? 'false' : 'true';
113
114 $options = JHtml::getJSObject($opt);
115
116 $js = "window.addEvent('domready', function(){ new Fx.Accordion($$('div#" . $group
117 . ".pane-sliders > .panel > h3.pane-toggler'), $$('div#" . $group . ".pane-sliders > .panel > div.pane-slider'), " . $options
118 . "); });";
119
120 $document->addScriptDeclaration($js);
121 }
122 }
123 }
124