diff --git a/js/quicktabs.js b/js/quicktabs.js index ec99c65..c634d8a 100644 --- a/js/quicktabs.js +++ b/js/quicktabs.js @@ -20,6 +20,7 @@ Drupal.behaviors.quicktabs = { Drupal.quicktabs.prepare = function(el) { // el.id format: "quicktabs-$name" var qt_name = Drupal.quicktabs.getQTName(el); + var qtKey = 'qt_' + qt_name; var $ul = $(el).find('ul.quicktabs-tabs:first'); $ul.find('li a').each(function(i, element){ element.myTabIndex = i; @@ -27,7 +28,9 @@ Drupal.quicktabs.prepare = function(el) { var tab = new Drupal.quicktabs.tab(element); var parent_li = $(element).parents('li').get(0); if ($(parent_li).hasClass('active')) { - $(element).addClass('quicktabs-loaded'); + if (!Drupal.settings.quicktabs[qtKey].qt.ajax_always) { + $(element).addClass('quicktabs-loaded'); + } } $(element).once(function() {$(this).bind('click', {tab: tab}, Drupal.quicktabs.clickHandler);}); }); @@ -101,8 +104,11 @@ if (Drupal.ajax) { if (!$(element).hasClass('quicktabs-loaded')) { ajax.beforeSerialize(ajax.element, ajax.options); $.ajax(ajax.options); - if ($(element).parents('ul').hasClass('quicktabs-tabs')) { - $(element).addClass('quicktabs-loaded'); + var qtKey = 'qt_' + element.qt_name; + if (!Drupal.settings.quicktabs[qtKey].qt.ajax_always) { + if ($(element).parents('ul').hasClass('quicktabs-tabs')) { + $(element).addClass('quicktabs-loaded'); + } } } } diff --git a/plugins/QuickQuicktabs.inc b/plugins/QuickQuicktabs.inc index 9dcb7de..6650168 100644 --- a/plugins/QuickQuicktabs.inc +++ b/plugins/QuickQuicktabs.inc @@ -128,6 +128,11 @@ class QuickQuicktabs extends QuickRenderer { 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); + // Load the qt + if ($qt = quicktabs_load($name)) { + // Add the qt settings as well + $quicktabs_array['qt'] = (array) $qt; + } $attached['js'][] = array('data' => array('quicktabs' => array('qt_' . $name => $quicktabs_array)), 'type' => 'setting'); } return $attached; diff --git a/quicktabs.admin.inc b/quicktabs.admin.inc index ea320a5..482cd9a 100644 --- a/quicktabs.admin.inc +++ b/quicktabs.admin.inc @@ -225,7 +225,20 @@ function _quicktabs_admin_main_form($form_state, &$qt) { '#default_value' => isset($qt->ajax) ? $qt->ajax : 0, '#description' => t('Choose how the content of tabs should be loaded.
By choosing "Yes", only the first tab will be loaded when the page first viewed. Content for other tabs will be loaded only when the user clicks the other tab. This will provide faster initial page loading, but subsequent tab clicks will be slower. This can place less load on a server.
By choosing "No", all tabs will be loaded when the page is first viewed. This will provide slower initial page loading, and more server load, but subsequent tab clicks will be faster for the user. Use with care if you have heavy views.
Warning: if you enable Ajax, any block you add to this quicktabs block will be accessible to anonymous users, even if you place role restrictions on the quicktabs block. Do not enable Ajax if the quicktabs block includes any blocks with potentially sensitive information.
'), '#states' => array('visible' => array(':input[name="renderer"]' => array('value' => 'quicktabs'))), - '#weight' => -5, + '#weight' => -4, + ); + + $form['ajax_always'] = array( + '#type' => 'radios', + '#title' => t('Use Ajax every time a tab is toggled'), + '#options' => array( + TRUE => t('Yes'), + FALSE => t('No'), + ), + '#default_value' => isset($qt->ajax_always) ? $qt->ajax_always : 0, + '#description' => t('Choose whether or not the tab content should be refetched via Ajax every single time a tab is toggled.'), + '#states' => array('visible' => array(':input[name="ajax"]' => array('value' => '1'))), + '#weight' => -3, ); $form['hide_empty_tabs'] = array( @@ -233,13 +246,13 @@ function _quicktabs_admin_main_form($form_state, &$qt) { '#title' => t('Hide empty tabs'), '#default_value' => isset($qt->hide_empty_tabs) ? $qt->hide_empty_tabs : 0, '#description' => t('Empty and restricted tabs will not be displayed. Could be useful when the tab content is not accessible.