diff --git a/blockcache_alter.js b/blockcache_alter.js deleted file mode 100644 index 95246d0..0000000 --- a/blockcache_alter.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Check value of cache_block to see if - * we need to hide or show the additional settings. - */ -function BlockCacheAlterCheck() { - var blockcache = jQuery('#edit-cache-block'); - var selected = blockcache[0].options[blockcache[0].selectedIndex].value; - if (selected == '-1') { - toggleBlockCacheAlter('hide'); - } - else { - toggleBlockCacheAlter('show'); - } -} - -/** - * Show or hide additional blockcache settings. - */ -function toggleBlockCacheAlter(type) { - if (type == 'hide') { - jQuery('#blockcache_alter_wrapper').hide('slow'); - } - else { - jQuery('#blockcache_alter_wrapper').show('slow'); - } -} diff --git a/blockcache_alter.module b/blockcache_alter.module index 6097b45..04b53d6 100644 --- a/blockcache_alter.module +++ b/blockcache_alter.module @@ -45,21 +45,22 @@ function blockcache_alter_admin_settings() { '#title' => t('Show debug information ?'), '#description' => t('Debug info: shows helpful debugging whenever blocks are rendered, whether they are pulled form cache or not, and when block caches are refreshed.'), '#default_value' => variable_get('bca_debug', 0), + '#states' => array( + 'visible' => array(':input[name="bca_corepatch"]' => array('checked' => TRUE)), + ), ); $form['bca_user1'] = array( '#type' => 'checkbox', '#title' => t('Cache blocks for user 1 (uid 1) ?'), '#description' => t('This enables block caching for the primary Drupal user (uid 1). Can lead to unexpected results on production websites!'), '#default_value' => variable_get('bca_user1', 0), + '#states' => array( + 'visible' => array(':input[name="bca_corepatch"]' => array('checked' => TRUE)), + ), ); return system_settings_form($form); } -function blockcache_alter_init() { - // Add some funky hide and show javascript. - drupal_add_js(drupal_get_path('module', 'blockcache_alter') . '/blockcache_alter.js'); -} - /** * Implementation of hook_form_alter(). */ @@ -111,22 +112,19 @@ function blockcache_alter_form_alter(&$form, $form_state, $form_id) { '#description' => t('Select the appropriate cache setting for this block.'), '#options' => $block_cache_options, '#default_value' => $default_value, - '#attributes' => array('onChange' => 'javascript:BlockCacheAlterCheck(); return false;'), ); // Cache clearing option after saving this block. - $display = ($default_value == DRUPAL_NO_CACHE) ? 'none' : 'block'; $form['cache']['cache_block_clear'] = array( '#type' => 'radios', '#title' => t('Clear cache'), - '#prefix' => '
', '#description' => t('Select the appropriate cache clearing action after saving this block.'), '#options' => $cache_clear_actions, '#default_value' => 1, + '#states' => array( + 'invisible' => array(':input[name="cache_block"]' => array('value' => DRUPAL_NO_CACHE)), + ), ); - if ($core_patch != TRUE) { - $form['cache']['cache_block_clear']['#suffix'] = '
'; - } // Show options underneath onl if core patch is applied. if ($core_patch == TRUE) { @@ -135,7 +133,10 @@ function blockcache_alter_form_alter(&$form, $form_state, $form_id) { $form['cache']['option_1'] = array( '#type' => 'fieldset', '#title' => t('Cache refresh option 1: Cache lifetime'), - '#description' => t('Set a minimum cache lifetime (in seconds). Leave 0 or empty to use the second option.') + '#description' => t('Set a minimum cache lifetime (in seconds). Leave 0 or empty to use the second option.'), + '#states' => array( + 'invisible' => array(':input[name="cache_block"]' => array('value' => DRUPAL_NO_CACHE)), + ), ); // Blockcache lifetime. @@ -151,6 +152,9 @@ function blockcache_alter_form_alter(&$form, $form_state, $form_id) { '#type' => 'fieldset', '#title' => t('Cache refresh option 2: Drupal actions'), '#description' => t('Refresh on certain actions in the Drupal system. When choosing node or comment action, you also need to specify on which node types it should refresh. Note that clicking any of these checkboxes will not have any effect if a minimum lifetime is set in option 1.'), + '#states' => array( + 'invisible' => array(':input[name="cache_block"]' => array('value' => DRUPAL_NO_CACHE)), + ), ); // Blockcache refresh. @@ -165,8 +169,6 @@ function blockcache_alter_form_alter(&$form, $form_state, $form_id) { $options['nodequeue'] = t('A node is added or removed from a nodequeue'); } $form['cache']['option_2']['bc_refresh'] = array( - '#prefix' => '
', - '#suffix' => '
', '#type' => 'checkboxes', '#title' => t('Refresh when'), '#options' => $options, @@ -181,20 +183,11 @@ function blockcache_alter_form_alter(&$form, $form_state, $form_id) { } $form['cache']['option_2']['bc_relate'] = array( - '#prefix' => '
', - '#suffix' => '
', '#type' => 'checkboxes', '#title' => t('Relation'), '#options' => $node_types, '#default_value' => variable_get('bc_relate_'. $form['module']['#value'] .'_'. $form['delta']['#value'], array()), ); - - // End div. - $form['cache']['enddiv'] = array( - '#type' => 'hidden', - '#suffix' => '', - ); - } // Add own submit handler.