Mercurial > hg > rr-repo
comparison sites/all/modules/quicktabs/plugins/QuickAccordion.inc @ 2:b74b41bb73f0
-- Google analytics module
author | danieleb <danielebarchiesi@me.com> |
---|---|
date | Thu, 22 Aug 2013 17:22:54 +0100 |
parents | |
children | 134d4b2e75f6 |
comparison
equal
deleted
inserted
replaced
1:67ce89da90df | 2:b74b41bb73f0 |
---|---|
1 <?php | |
2 | |
3 /** | |
4 * Renders the content using the jQuery UI Accordion widget. | |
5 */ | |
6 class QuickAccordion extends QuickRenderer { | |
7 | |
8 public static function optionsForm($qt) { | |
9 $form = array(); | |
10 $form['history'] = array( | |
11 '#type' => 'checkbox', | |
12 '#title' => 'History', | |
13 '#description' => t('Store tab state in the URL allowing for browser back / forward and bookmarks.'), | |
14 '#default_value' => (isset($qt->renderer) && $qt->renderer == 'accordion' && isset($qt->options['history']) && $qt->options['history']), | |
15 ); | |
16 $form['jquery_ui'] = array( | |
17 '#type' => 'fieldset', | |
18 '#title' => t('JQuery UI options'), | |
19 ); | |
20 $form['jquery_ui']['autoHeight'] = array( | |
21 '#type' => 'checkbox', | |
22 '#title' => 'Autoheight', | |
23 '#default_value' => (isset($qt->renderer) && $qt->renderer == 'accordion' && isset($qt->options['jquery_ui']['autoHeight']) && $qt->options['jquery_ui']['autoHeight']), | |
24 ); | |
25 $form['jquery_ui']['collapsible'] = array( | |
26 '#type' => 'checkbox', | |
27 '#title' => t('Collapsible'), | |
28 '#default_value' => (isset($qt->renderer) && $qt->renderer == 'accordion' && isset($qt->options['jquery_ui']['collapsible']) && $qt->options['jquery_ui']['collapsible']), | |
29 ); | |
30 return $form; | |
31 } | |
32 | |
33 public function render() { | |
34 $quickset = $this->quickset; | |
35 $qsid = 'quickset-' . $quickset->getName(); | |
36 // Build our render array... | |
37 $render_array = array(); | |
38 $render_array['#attached'] = $this->add_attached(); | |
39 $render_array['content'] = array( | |
40 '#theme' => 'qt_accordion', | |
41 '#options' => array('attributes' => array( | |
42 'id' => $qsid, | |
43 'class' => array('quick-accordion'), | |
44 )), | |
45 'divs' => array(), | |
46 ); | |
47 | |
48 // Render all tab content. | |
49 foreach ($quickset->getContents() as $key => $item) { | |
50 if (!empty($item)) { | |
51 $render_array['content']['divs'][] = array( | |
52 '#prefix' => '<h3><a href= "#'. $qsid . '_' . $key .'">'. check_plain($quickset->translateString($item->getTitle(), 'tab', $key)) .'</a></h3><div>', | |
53 '#suffix' => '</div>', | |
54 'content' => $item->render(), | |
55 ); | |
56 } | |
57 } | |
58 return $render_array; | |
59 } | |
60 | |
61 /** | |
62 * Add any necessary js, css and libraries for the render array. | |
63 */ | |
64 protected function add_attached() { | |
65 $settings = $this->quickset->getSettings(); | |
66 $options = $settings['options']; | |
67 | |
68 $attached = array( | |
69 'library' => array( | |
70 array('system', 'ui.accordion'), | |
71 ), | |
72 'js' => array( | |
73 array('data' => drupal_get_path('module', 'quicktabs') . '/js/qt_accordion.js'), | |
74 ), | |
75 ); | |
76 | |
77 $javascript = drupal_add_js(); | |
78 foreach ($javascript['settings']['data'] as $key => $settings) { | |
79 if (key($settings) == 'quicktabs') { | |
80 $qtkey = $key; | |
81 break; | |
82 } | |
83 } | |
84 | |
85 if ($options['history']) { | |
86 $attached['library'][] = array('system', 'jquery.bbq'); | |
87 $attached['js'][] = array('data' => drupal_get_path('module', 'quicktabs') . '/js/quicktabs_bbq.js'); | |
88 } | |
89 | |
90 $name = $this->quickset->getName(); | |
91 if (!isset($qtkey) || !array_key_exists('qt_' . $name, $javascript['settings']['data'][$qtkey]['quicktabs'])) { | |
92 $quicktabs_array = array('name' => $name, 'active_tab' => $this->quickset->getActiveTab(), 'options' => $options['jquery_ui'], 'history' => $options['history']); | |
93 $attached['js'][] = array('data' => array('quicktabs' => array('qt_'. $name => $quicktabs_array)), 'type' => 'setting'); | |
94 } | |
95 return $attached; | |
96 } | |
97 | |
98 } |