Use CTools/dependent.js instead of homebrew.
authorAlex Barth
Wed, 5 May 2010 23:52:48 +0000 (23:52 +0000)
committerAlex Barth
Wed, 5 May 2010 23:52:48 +0000 (23:52 +0000)
feeds_ui/feeds_ui.admin.inc
feeds_ui/feeds_ui.js
plugins/FeedsHTTPFetcher.inc

index c9c5f2d..93ea385 100644 (file)
@@ -296,7 +296,8 @@ function feeds_ui_edit_page($importer, $active = 'help', $plugin_key = '') {
       $active_container['body'] = drupal_get_form('feeds_ui_plugin_form', $importer, $active);
       break;
     case 'settings':
-      drupal_add_js(drupal_get_path('module', 'feeds_ui') .'/feeds_ui.js');
+      drupal_add_js(drupal_get_path('module', 'ctools') .'/js/dependent.js');
+      ctools_include('dependent');
       if (empty($plugin_key)) {
         $active_container['title'] = t('Basic settings');
         $active_container['body'] = feeds_get_config_form($importer);
index 650b650..9908320 100644 (file)
@@ -87,21 +87,4 @@ Drupal.behaviors.feeds = function() {
     $('#' + $(this).attr('id')).attr('checked', 1);
     $('input.form-submit.feeds-ui-hidden-submit').click();
   });
-
-  // Show pubsub settings conditionally.
-  // @todo Generalize dependencies between form elements.
-  if ($('#edit-use-pubsubhubbub').attr('checked')) {
-    $('#edit-designated-hub-wrapper').show();
-  }
-  else {
-    $('#edit-designated-hub-wrapper').hide();
-  }
-  $('#edit-use-pubsubhubbub').click(function() {
-    if ($(this).attr('checked')) {
-      $('#edit-designated-hub-wrapper').show(100);
-    }
-    else {
-      $('#edit-designated-hub-wrapper').hide(100);
-    }
-  });
 };
index d55d2b8..2cccc9b 100644 (file)
@@ -122,6 +122,10 @@ class FeedsHTTPFetcher extends FeedsFetcher {
       '#title' => t('Designated hub'),
       '#description' => t('Enter the URL of a designated PubSubHubbub hub (e. g. superfeedr.com). If given, this hub will be used instead of the hub specified in the actual feed.'),
       '#default_value' => $this->config['designated_hub'],
+      '#process' => array('ctools_dependent_process'),
+      '#dependency' => array(
+        'edit-use-pubsubhubbub' => array(1),
+      ),
     );
     return $form;
   }