Index: panels_views/panels_views.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/panels/panels_views/Attic/panels_views.module,v
retrieving revision 1.1.2.24
diff -u -r1.1.2.24 panels_views.module
--- panels_views/panels_views.module	5 Jun 2008 03:46:21 -0000	1.1.2.24
+++ panels_views/panels_views.module	6 Jun 2008 10:38:29 -0000
@@ -234,8 +234,12 @@
  * Form to add or edit add a view pane.
  */
 function panels_views_edit_view_form($view, $panel_view) {
-  panels_views_pane_arguments($view, $panel_view);
+  // Add Javascript for improved UI.
+  drupal_add_js(panels_get_path('panels_views/panels_views.js'));
 
+  // Update the panel view object to make it map correctly to the view's
+  // arguments.
+  panels_views_pane_arguments($view, $panel_view);
 
   $form['basic'] = array(
     '#type' => 'fieldset',
@@ -355,6 +359,7 @@
       '#description' => t('If "Fixed" is selected, what to use as an argument.'),
       '#default_value' => $panel_view->contexts[$id]['fixed'],
     );
+
     $form['contexts'][$id]['label'] = array(
       '#type' => 'textfield',
       '#title' => t('Label'),
@@ -425,7 +430,6 @@
     '#description' => t('If checked, link the title of the pane to the view.'),
     '#default_value' => $panel_view->link_to_view,
   );
-
   $form['deco']['allow_link_to_view'] = array(
     '#type' => 'checkbox',
     '#title' => t('Allow the pane configuration to modify the link to view setting.'),
@@ -460,20 +464,20 @@
 
   $form['deco']['url_override'] = array(
     '#type' => 'checkbox',
-    '#title' => t('Override the panel URL with a manually set URL.'),
+    '#title' => t('Override the view URL with a manually set URL.'),
     '#default_value' => $panel_view->url_override,
   );
 
   $form['deco']['url'] = array(
     '#type' => 'textfield',
     '#title' => t('Override view URL'),
-    '#description' => t('If override URL is set, the URL the view thinks it is using; all "more", "exposed filters", "summary" and "feed" type links will use this URL.'),
+    '#description' => t('If override view URL is set, the URL the view thinks it is using; all "more", "exposed filters", "summary" and "feed" type links will use this URL.'),
     '#default_value' => $panel_view->url,
   );
 
   $form['deco']['allow_url_override'] = array(
     '#type' => 'checkbox',
-    '#title' => t('Allow the pane configuration to modify the URL override setting.'),
+    '#title' => t('Allow the pane configuration to modify the view URL override setting.'),
     '#default_value' => $panel_view->allow_url_override,
   );
 
@@ -486,7 +490,7 @@
 
   $form['deco']['allow_url_from_panel'] = array(
     '#type' => 'checkbox',
-    '#title' => t('Allow the pane configuration to modify the "set view URL to panel URL" setting.'),
+    '#title' => t('Allow the pane configuration to modify the "Set view URL to panel URL" setting.'),
     '#default_value' => $panel_view->allow_url_from_panel,
   );
 
@@ -912,7 +916,7 @@
       );
     }
   }
-  // Provide form gadgets only on the things that th euser can change.
+  // Provide form gadgets only on the things that the user can change.
   if ($pv->allow_type) {
     $form['view_type'] = array(
       '#type' => 'select',
@@ -1227,6 +1231,16 @@
 /**
  * Adjust a pane for a view's arguments, adding or subtracting as needed to
  * match the current view's argument configuration.
+ * In simpler terms, this means that's we're changing the panel view object so
+ * that it maps to the view's arguments correctly.
+ *
+ * Note: $panel_view->contexts is misnamed, and should actually have been
+ * named $panel_view->arguments or so.
+ *
+ * @param $view
+ *   A view object.
+ * @param &$panel_view
+ *   A panel view object.
  */
 function panels_views_pane_arguments($view, &$panel_view) {
   $contexts = array();
Index: panels_views/panels_views.js
===================================================================
RCS file: panels_views/panels_views.js
diff -N panels_views/panels_views.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ panels_views/panels_views.js	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,113 @@
+// $Id$
+
+
+/**
+ * @file panels_views.js 
+ *
+ * Contains the javascript for editing Views panes.
+ */
+
+var PanelsViews = PanelsViews || {};
+
+//PanelsViews.context = $('form#panels-views-edit-view-form *');
+
+PanelsViews.attachBindings = function() {
+  // Arguments dependent form items.
+  for (var argId = 0; $('select#edit-contexts-'+ argId +'-type').length > 0; argId++) {
+    var $argumentSourceSelect = $('select#edit-contexts-'+ argId +'-type');
+
+    this.argumentSourceDependencies(argId, $argumentSourceSelect.val(), 0);
+
+    $argumentSourceSelect.change(function(_argId) {
+      return function() { PanelsViews.argumentSourceDependencies(_argId, $(this).val(), 'fast'); };
+    }(argId));
+  }
+
+  // The bulk of dependent checkboxes are really simple!
+  var checkboxes = new Array(
+    '#edit-use-pager',
+    '#edit-link-to-view',
+    '#edit-more-link',
+    '#edit-feed-icons',
+    '#edit-url-override'
+  );
+  var deps = new Array(
+    '#edit-pager-id, #edit-allow-use-pager',
+    '#edit-allow-link-to-view',
+    '#edit-allow-more-link',
+    '#edit-allow-feed-icons',
+    '#edit-url, #edit-allow-url-override'
+  );
+  var otherDeps = new Array(
+    false,
+    false,
+    false,
+    false,
+    '#edit-url-from-panel'
+  );
+  for (var i = 0; i < checkboxes.length; i++) {
+    this.simpleDependencies($(checkboxes[i]).attr('checked'), deps[i], false, 0);
+    $(checkboxes[i]).change(function(_i) {
+      return function() { PanelsViews.simpleDependencies($(this).attr('checked'), deps[_i], otherDeps[_i], 'fast'); };
+    }(i));
+  }
+
+  // Pane decorations: 'allow url from panel' must be displayed if
+  // 'url override' is disabled AND 'url from panel' is enabled.
+  this.simpleDependencies(($('#edit-url-override').attr('checked') !== true) && ($('#edit-url-from-panel').attr('checked') === true), '#edit-allow-url-from-panel', false, 0);
+  $('#edit-url-from-panel').change(function() {
+    PanelsViews.simpleDependencies(($('#edit-url-override').attr('checked') !== true) && ($('#edit-url-from-panel').attr('checked') === true), '#edit-allow-url-from-panel', false, 'fast');
+  });
+};
+
+PanelsViews.argumentSourceDependencies = function(argId, argumentSource, speed) {
+    switch (argumentSource) {
+      case 'context':
+        $('#edit-contexts-'+ argId +'-panel, #edit-contexts-'+ argId +'-fixed').parent().hide(speed);
+        $('#edit-contexts-'+ argId +'-context').parent().show(speed);
+        break;
+
+      case 'panel':
+        $('#edit-contexts-'+ argId +'-context, #edit-contexts-'+ argId +'-fixed').parent().hide(speed);
+        $('#edit-contexts-'+ argId +'-panel').parent().show(speed);
+        break;
+
+      case 'fixed':
+        $('#edit-contexts-'+ argId +'-context, #edit-contexts-'+ argId +'-panel').parent().hide(speed);
+        $('#edit-contexts-'+ argId +'-fixed').parent().show(speed);
+        break;
+
+      default:
+        $('#edit-contexts-'+ argId +'-context, #edit-contexts-'+ argId +'-fixed, #edit-contexts-'+ argId +'-panel').parent().hide(speed);
+        break;
+    }
+};
+
+PanelsViews.simpleDependencies = function(checked, dep, otherDep, speed) {
+  if (!otherDep) {
+    if (checked === true) {
+      $('div.form-item['+ dep +']').show(speed);
+    }
+    else {
+      $('div.form-item['+ dep +']').hide(speed);
+    }
+  }
+  else {
+    if (checked === true) {
+      $('div.form-item['+ otherDep +']').hide(speed, function() {
+        $('div.form-item['+ dep +']').show(speed);
+      });
+    }
+    else {
+      $('div.form-item['+ dep +']').hide(speed, function() {
+        $('div.form-item['+ otherDep +']').show(speed);
+      });
+    }    
+  }
+};
+
+if (Drupal.jsEnabled) {
+  $(document).ready(function() {
+    PanelsViews.attachBindings();
+  });
+}
