Same name and namespace in other branches
- 8.x-1.x src/Plugin/QuickRender/QuickAccordion.php \Drupal\quicktabs\Plugin\QuickRender\QuickAccordion
Renders the content using the jQuery UI Accordion widget.
Hierarchy
- class \QuickRenderer
- class \QuickAccordion extends \QuickRenderer
Expanded class hierarchy of QuickAccordion
1 string reference to 'QuickAccordion'
- quicktabs_quicktabs_renderers dans ./
quicktabs.module - Implements hook_quicktabs_renderers().
Fichier
-
plugins/
QuickAccordion.inc, line 6
View source
class QuickAccordion extends QuickRenderer {
public static function optionsForm($qt) {
$form = array();
$form['history'] = array(
'#type' => 'checkbox',
'#title' => 'History',
'#description' => t('Store tab state in the URL allowing for browser back / forward and bookmarks.'),
'#default_value' => isset($qt->renderer) && $qt->renderer == 'accordion' && isset($qt->options['history']) && $qt->options['history'],
);
$form['jquery_ui'] = array(
'#type' => 'fieldset',
'#title' => t('JQuery UI options'),
);
$form['jquery_ui']['autoHeight'] = array(
'#type' => 'checkbox',
'#title' => 'Autoheight',
'#default_value' => isset($qt->renderer) && $qt->renderer == 'accordion' && isset($qt->options['jquery_ui']['autoHeight']) && $qt->options['jquery_ui']['autoHeight'],
);
$form['jquery_ui']['collapsible'] = array(
'#type' => 'checkbox',
'#title' => t('Collapsible'),
'#default_value' => isset($qt->renderer) && $qt->renderer == 'accordion' && isset($qt->options['jquery_ui']['collapsible']) && $qt->options['jquery_ui']['collapsible'],
);
return $form;
}
public function render() {
$quickset = $this->quickset;
$qsid = 'quickset-' . $quickset->getName();
// Build our render array...
$render_array = array();
$render_array['#attached'] = $this->add_attached();
$render_array['content'] = array(
'#theme' => 'qt_accordion',
'#options' => array(
'attributes' => array(
'id' => $qsid,
'class' => array(
'quick-accordion',
),
),
),
'divs' => array(),
);
// Render all tab content.
foreach ($quickset->getContents() as $key => $item) {
if (!empty($item)) {
$attributes = array();
$attributes['class'][] = drupal_html_class($item->getTitle());
drupal_alter('quicktabs_tablinks_attributes', $attributes, $quickset, $key);
$attributes['href'] = '#' . $qsid . '_' . $key;
$render_array['content']['divs'][] = array(
'#prefix' => '<h3><a ' . drupal_attributes($attributes) . '>' . check_plain($quickset->translateString($item->getTitle(), 'tab', $key)) . '</a></h3><div>',
'#suffix' => '</div>',
'content' => $item->render(),
);
}
}
return $render_array;
}
/**
* Add any necessary js, css and libraries for the render array.
*/
protected function add_attached() {
$settings = $this->quickset
->getSettings();
// Setting heightStyle option so accordions don't auto height with newer versions of jQuery UI
if (!isset($settings['options']['jquery_ui']['autoheight'])) {
$settings['options']['jquery_ui']['heightStyle'] = 'content';
}
$options = $settings['options'];
$attached = array(
'library' => array(
array(
'system',
'ui.accordion',
),
),
'js' => array(
array(
'data' => drupal_get_path('module', 'quicktabs') . '/js/qt_accordion.js',
),
),
);
$javascript = drupal_add_js();
if (isset($javascript['settings']['data'])) {
foreach ($javascript['settings']['data'] as $key => $settings) {
if (key($settings) == 'quicktabs') {
$qtkey = $key;
break;
}
}
}
if ($options['history']) {
$attached['library'][] = array(
'system',
'jquery.bbq',
);
$attached['js'][] = array(
'data' => drupal_get_path('module', 'quicktabs') . '/js/quicktabs_bbq.js',
);
}
$name = $this->quickset
->getName();
if (!isset($qtkey) || !array_key_exists('qt_' . $name, $javascript['settings']['data'][$qtkey]['quicktabs'])) {
$quicktabs_array = array(
'name' => $name,
'active_tab' => $this->quickset
->getActiveTab(),
'options' => $options['jquery_ui'],
'history' => $options['history'],
);
$attached['js'][] = array(
'data' => array(
'quicktabs' => array(
'qt_' . $name => $quicktabs_array,
),
),
'type' => 'setting',
);
}
return $attached;
}
}
Members
Titre Trier par ordre décroissant | Modifiers | Object type | Résumé | Overriden Title |
---|---|---|---|---|
QuickAccordion::add_attached | protected | function | Add any necessary js, css and libraries for the render array. | |
QuickAccordion::optionsForm | public static | function | Method for returning the form elements to display for this renderer type on the admin form. |
Overrides QuickRenderer::optionsForm |
QuickAccordion::render | public | function | The only method that renderer plugins must implement. | Overrides QuickRenderer::render |
QuickRenderer::$quickset | protected | property | ||
QuickRenderer::getTitle | public | function | Accessor method for the title. | |
QuickRenderer::__construct | public | function | Constructor |