Same name in other branches
- 7.x-3.x plugins/QuickQuicktabs.inc \QuickQuicktabs::add_attached()
Add any necessary js, css and libraries for the render array.
1 call to QuickQuicktabs::add_attached()
- QuickQuicktabs::render dans src/
Plugin/ QuickRender/ QuickQuicktabs.php
Fichier
-
src/
Plugin/ QuickRender/ QuickQuicktabs.php, line 118
Classe
- QuickQuicktabs
- Renders the content using the original Quicktabs mechanism of previous versions. Includes support for ajax rendered content.
Namespace
Drupal\quicktabs\Plugin\QuickRenderCode
protected function add_attached() {
$attached = array(
'css' => array(
array(
'data' => drupal_get_path('module', 'quicktabs') . '/css/quicktabs.css',
),
),
'js' => array(
array(
'data' => drupal_get_path('module', 'quicktabs') . '/js/quicktabs.js',
),
array(
'data' => 'misc/progress.js',
'weight' => JS_LIBRARY,
),
),
);
$settings = $this->quickset
->getSettings();
// Add the custom style css if a custom style has been set.
// No use of now.
/*$style_css = quicktabs_get_css($settings['style']);
if (!empty($style_css)) {
$attached['css'][] = $style_css;
}*/
// Prepare a tab_settings array for passing the tab info to our JavaScript.
$tab_settings = array();
foreach ($this->quickset
->getContents() as $i => $content) {
if (!empty($content)) {
$tab_settings[$i] = $content->getSettings();
}
}
// Add our JS settings
$javascript = drupal_add_js();
$javascript = array(
'#attached' => array(),
);
if (isset($javascript['settings']['data'])) {
foreach ($javascript['settings']['data'] as $key => $settings) {
if (key($settings) == 'quicktabs') {
$qtkey = $key;
break;
}
}
}
$name = $this->quickset
->getName();
if (!isset($qtkey) || isset($javascript['settings']['data'][$qtkey]['quicktabs']) && !array_key_exists('qt_' . $name, $javascript['settings']['data'][$qtkey]['quicktabs'])) {
$quicktabs_array = array_merge(array(
'name' => $name,
'tabs' => $tab_settings,
), $settings);
$attached['js'][] = array(
'data' => array(
'quicktabs' => array(
'qt_' . $name => $quicktabs_array,
),
),
'type' => 'setting',
);
}
return $attached;
}