Index: dashboard.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/dashboard/dashboard.info,v
retrieving revision 1.1
diff -u -p -r1.1 dashboard.info
--- dashboard.info	10 Apr 2009 17:09:12 -0000	1.1
+++ dashboard.info	12 Apr 2009 01:27:44 -0000
@@ -4,4 +4,5 @@ core = 6.x
 package = Drupal.org
 dependencies[] = jquery_ui
 dependencies[] = drupalorg_crosssite
+dependencies[] = drupalorg_news
 dependencies[] = profile
Index: dashboard.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/dashboard/dashboard.js,v
retrieving revision 1.3
diff -u -p -r1.3 dashboard.js
--- dashboard.js	11 Apr 2009 21:14:04 -0000	1.3
+++ dashboard.js	12 Apr 2009 01:27:44 -0000
@@ -12,10 +12,12 @@ Drupal.behaviors.dashboard = function(co
       containment: $dashboard,
       distance: 5,
       opacity: 0.8,
+      tolerance: 'pointer',
       start: function(event, ui) {
         dashboardSetColumnHeight(ui.item.height());
       },
       stop: function(event, ui) {
+        // we can probably extract this and reuse most of it in .droppable:drop
         gadgets = [];
         $columns.each(function() {
           gadgets.push($(this).sortable('toArray').join(',').replace(/gadget-/g, ''));
@@ -29,6 +31,65 @@ Drupal.behaviors.dashboard = function(co
         dashboardSetColumnHeight(0);
       }
     });
+    
+    $gadgets = $columns.find('>div.gadget').draggable({
+      handle: $(this).find('h2>a'),
+      opacity: .45,
+      tolerance: 'pointer',
+      helper: 'clone', // have to use clone in order for connectToSortable to work without error
+      connectToSortable: $columns,
+      stop: function(event, ui) {
+        console.log(ui);
+        $(ui.helper[0]).removeClass('ui-draggable');
+      }
+    });
+    
+    // we want to be able to drop on any tab that is not the add tab
+    $("#nav-content li:not('.dashboard-link-add')>a").droppable({
+      accept: "div.gadget>h2>a",
+      tolerance: 'pointer',
+      containment: $gadgets,
+      greedy: true,
+      over: function() {
+        $(this).css({'border': '1px solid red'}); // probably use a class here instead
+      },
+      out: function() {
+        $(this).css({'border': '0px'}); // remove class instead
+      },
+      drop: function(event, ui) {
+        $(this).css({'border': '0px'}); // remove class instead
+        
+        // remove the current gadget
+        console.log(event);
+        $currentGadget = $(event.originalTarget).parent().parent();
+        $currentGadget.remove();
+        
+        // make sure our tab is compatible - might want something more complex; url?
+        tab = this.text.replace(' ', '-');
+        gid = $currentGadget.attr('id').replace(/gadget-/g, '');
+        
+        // get the current gadget so we can save them
+        gadgets = [];
+        $columns.each(function() {
+          gadgets.push($(this).sortable('toArray').join(',').replace(/gadget-/g, ''));
+        });
+        
+        // move the gadget to the specified page
+        jQuery.post(
+          Drupal.settings.basePath + 'dashboard/' + Drupal.settings.dashboardPage + '/move-gadget',
+          {
+            token: Drupal.settings.dashboardToken,
+            gadget_id: gid,
+            page_id: tab,
+            column_0: gadgets[0],
+            column_1: gadgets[1],
+            column_2: gadgets[2]
+          }
+        );
+        dashboardSetColumnHeight(0);
+        return false;
+      }
+    });
   }
 }
 
Index: dashboard.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/dashboard/dashboard.module,v
retrieving revision 1.18
diff -u -p -r1.18 dashboard.module
--- dashboard.module	11 Apr 2009 21:14:04 -0000	1.18
+++ dashboard.module	12 Apr 2009 01:27:44 -0000
@@ -41,6 +41,14 @@ function dashboard_menu() {
       'type' => MENU_CALLBACK,
       'file' => 'dashboard.page.inc',
     ),
+    'dashboard/%dashboard_user_page/move-gadget' => array(
+      'page callback' => 'dashboard_gadget_move',
+      'page arguments' => array(1),
+      'access callback' => 'dashboard_valid_token',
+      'access arguments' => array(1),
+      'type' => MENU_CALLBACK,
+      'file' => 'dashboard.page.inc',
+    ),
     'dashboard/%dashboard_user_page/remove-gadget' => array(
       'page callback' => 'dashboard_gadget_remove',
       'access callback' => 'dashboard_valid_token',
@@ -130,7 +138,6 @@ function dashboard_user_page_load($path 
       return dashboard_user_page_load($path);
     }
   }
-
   if (is_null($path)) {
     return $pages;
   }
Index: dashboard.page.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/dashboard/dashboard.page.inc,v
retrieving revision 1.2
diff -u -p -r1.2 dashboard.page.inc
--- dashboard.page.inc	10 Apr 2009 23:29:13 -0000	1.2
+++ dashboard.page.inc	12 Apr 2009 01:27:44 -0000
@@ -4,7 +4,7 @@
  * Add the CSS and JS requirements for the page.
  */
 function dashboard_add_ui($page = NULL) {
-  jquery_ui_add(array('ui.sortable'));
+  jquery_ui_add(array('ui.sortable', 'ui.draggable', 'ui.droppable'));
   drupal_add_js(array(
     'dashboardPage' => $page->path,
     'dashboardToken' => drupal_get_token('dashboard ' . $page->page_id),
@@ -170,3 +170,10 @@ function dashboard_gadget_reorder($page)
 function dashboard_gadget_remove() {
   db_query("DELETE FROM {dashboard_gadget} WHERE gadget_id = %d", $_POST['gadget_id']);
 }
+
+function dashboard_gadget_move($page) {
+  $gadget_id = $_POST['gadget_id'];
+  $dest_page = dashboard_user_page_load($_POST['page_id']);
+  db_query("UPDATE dashboard_gadget SET page_id = %d, weight = 0, col = 0 WHERE gadget_id = %d", $dest_page->page_id, $gadget_id);
+  dashboard_gadget_redorder($page);
+}
\ No newline at end of file
