? ctools-plugin.patch
Index: WIDGETAPI.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/Attic/WIDGETAPI.txt,v
retrieving revision 1.1.2.3
diff -u -p -r1.1.2.3 WIDGETAPI.txt
--- WIDGETAPI.txt	19 Aug 2009 05:38:45 -0000	1.1.2.3
+++ WIDGETAPI.txt	3 Nov 2009 15:28:57 -0000
@@ -3,40 +3,137 @@ Widget API - Vote Up/Down
 -=-=-=-=-=-=-=-=-=-=-=-=-=-
 
 Vote Up/Down has its own widget API that allows site implementors and designers
-to easily use their own widget themes. Its easy as 1-2-3! Following are some
-rules you must follow:
+to easily use their own widget themes. Its easy as 1-2-3! Your widgets can be
+in a module or even in your theme.
 
-- All widgets are put in their respective sub-folders inside the widgets/
-  subdirectory. So your widget theme is called "awesome", make a folder by the
-  name of "awesome" such that its path is ./widgets/awesome
-
-- The widget itself is themed by the API using the "widget.tpl.php" file. As
-  soon as this file is created in your widget folder, it will displayed in the
-  list of available widget themes. The theme system of Vote Up/Down outputs
-  variables that you can freely use to display all sorts of widgets. The list of
-  variables is given later.
-
-- Apart from displaying the number of votes in the widget itself, you can also
-  display the widgets in the "links" part of the node, comment etc. This is
-  implemented in the theme using a separate theme file called "votes.tpl.php"
-
-
--=-=-=-=-=-
-Variables
--=-=-=-=-=-
-$cid          : Unique content ID
-$type         : Type of element being voted on
-$widget_theme : The name of the widget theme being rendered
-$tag          : The unique tag associated with each vote
-$class_up     : Either 'up-active', or 'up-inactive'
-$class_down   : Either 'down-active' or 'down-inactive'
-$link_up      : URL used for 'up' voting when JS is disabled
-$link_down    : URL used for 'down' voting when JS is disabled
-$class	      : 'negative', 'positive' or 'neutral' depending on number of votes
-$vote_label   : The pluralized vote label
-$points	      : Number of total vote points for the vote object (signed)
-$unsigned_points : Number of total vote points for the object (unsigned)
+Putting widgets in a module or theme
+====================================
+
+If you are putting widgets in a module, your module needs to include the
+following hook implementation:
+
+/**
+ * Implementation of hook_ctools_plugin_dierctory() to let the system know
+ * we implement widget plugins.
+ */
+function MODULENAME_ctools_plugin_directory($module, $plugin) {
+  if ($module == 'vud') {
+    return $plugin;
+  }
+}
+
+If your module includes other CTools plugin types, you will need to modify
+your already existing hook_ctools_plugin_directory() function accordingly.
+
+If you want to put widgets in your theme, add the following line to your
+info file:
+
+plugins[vud][widgets] = widgets
+
+In either case, then create the 'widgets' directory in your module or your
+theme.
+
+Quick and dirty widget creation
+===============================
+
+Let's set up a theme for widgets:
+After you have set up your module or theme for widgets, copy the 'updown'
+widget and all its files into your widget directory. You'll need to rename
+the widget, so for this example, we're going to call the widget example:
+
+edit your .info file and add the following line:
+  plugins[vud][widgets'] = widgets
+mkdir a 'widgets' directory in your theme.
+copy the 'updown' directory and its files to your widgets directory.
+Rename the updown directory in your theme/wdigets directory to 'example'.
+Rename 'updown.inc' to 'example.inc'.
+Rename 'updown.css' to 'example.css'
+Edit example.inc:
+  Change vud_updown_vud_widgets to MODULEORTHEMENAME_example_vud_widgets
+  Change the title from t('Default') to t('My example widget')
+Edit example.css and search-and-replace 'updown' to 'example'.
+Edit widget.tpl.php and search-and-replace 'updown' to 'example'.
+Visit your themes or modules configuration page and submit it, to ensure
+that the caches are cleared so that your new plugin can be recognized.
+
+You should now have a widget that you can assign. Modify it to your heart's
+content!
+
+Creating widgets
+================
+
+In the widgets directory, create a directory with the name of your widget.
+
+Then, create a directory with the name of your widget. For safety, you should 
+'namespace' your widgets which means to include the module name or something 
+unique so you don't clash with future widgets that may be included with vote 
+up down. 
+
+In your new widget directory, create a .inc file with the name of your
+widget. You should then end up with widgets/my_widget/my_widget.inc if,
+for example, your widget is named 'my_widget'.
+
+This .inc file needs to include one function:
+
+/**
+ * Specialized implementation of hook_vud_widgets().
+ */
+function MODULEORTHEMENAME_WIDGETNAME_vud_widgets() {
+  return array(
+    'title' => t('Default'),
+    'widget template' => 'widget',
+    'votes template' => 'votes',
+  );
+}
+
+You should include the 'widget template' line if you are including a
+widget.tpl.php and the 'votes template' line if you are including a
+votes.tpl.php. If you want the template named differently, the value of
+this line will set that.
+
+If you create a WIDGETNAME.css file this will automatically be included.
+If you want this file to be different, add
+
+  'css' => 'mycssfile.css',
+
+If you want multiple CSS files, add
+
+  'css' => array('myfile1.css', 'myfile2.css'),
+
+You can do similarly with javascript, though unlike .css files, javascript
+files will NOT be automatically included, you MUST specify them.
+
+Variables in the template files
+===============================
+
+$id                 : Unique CSS ID that should be used for this itme.
+$cid                : Unique content ID
+$type               : Type of element being voted on
+$widget_theme       : The name of the widget theme being rendered
+$tag                : The unique tag associated with each vote
+$class_up           : Either 'up-active', or 'up-inactive'
+$class_down         : Either 'down-active' or 'down-inactive'
+$link_up            : URL used for 'up' voting when JS is disabled
+$link_down          : URL used for 'down' voting when JS is disabled
+$link_class_up      : A class that should be put onto the "up" link. Needed for javascript.
+$link_class_down    : A class that should be put onto the "down" link. Needed for javascript.
+$class	            : 'negative', 'positive' or 'neutral' depending on number of votes
+$vote_label         : The pluralized vote label
+$points	            : Number of total vote points for the vote object (signed)
+$unsigned_points    : Number of total vote points for the object (unsigned)
+
+Advanced features
+=================
+
+Your widget can specify an 'ajax render' callback. This callback will be used
+to specify a CTools AJAX command packet if you want to do fancy rendering. This
+is not too likely to be needed, and should only be used if you've looked at the
+AJAX rendering code and understand it.
+
+If you want to use a different templating system than PHPtemplate, you can! Set
+'render function' to the name of a function that will be called in place of
+drupal_render_template() and set 'extension' to something other than .tpl.php if
+you so desire.
 
--=-=-=-=-=-
 Last updated:
 ; $Id: WIDGETAPI.txt,v 1.1.2.3 2009/08/19 05:38:45 lut4rp Exp $
Index: vud.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/Attic/vud.info,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 vud.info
--- vud.info	26 May 2009 11:36:55 -0000	1.1.2.1
+++ vud.info	3 Nov 2009 15:28:57 -0000
@@ -2,5 +2,6 @@
 name = Vote Up/Down
 description = "Provides a configurable up/down voting widget for other modules to use."
 dependencies[] = votingapi
+dependencies[] = ctools
 package = Voting
 core = 6.x
Index: vud.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/Attic/vud.module,v
retrieving revision 1.1.2.21
diff -u -p -r1.1.2.21 vud.module
--- vud.module	15 Aug 2009 21:15:45 -0000	1.1.2.21
+++ vud.module	3 Nov 2009 15:28:58 -0000
@@ -54,12 +54,13 @@ function vud_menu() {
     'weight' => -10,
   );
 
-  $items['vote/%/%/%/%/%'] = array(
+  $items['vote/%/%/%/%/%/%'] = array(
     'title'            => 'Vote',
     'page callback'    => 'vud_vote',
-    'page arguments'   => array(1, 2, 3, 4, 5),
+    'page arguments'   => array(1, 2, 3, 4, 5, 6),
     'access arguments' => array('use vote up/down'),
     'type'             => MENU_CALLBACK,
+    'file'             => 'vud.theme.inc',
   );
 
   $items['votereset/%/%/%/%'] = array(
@@ -127,64 +128,6 @@ function vud_user_votes() {
 }
 
 /**
- * Function for the main voting handler with Ajax support.
- */
-function vud_vote($type, $cid, $value, $tag, $token) {
-  if (is_numeric($value) && drupal_valid_token($token, "vote/$type/$cid/$value/$tag")) {
-    $vote = array();
-    // Sanity-check the incoming values.
-    if ($value > 0) {
-      $vote['value'] = 1;
-    }
-    else if ($value < 0) {
-      $vote['value'] = -1;
-    }
-    else {
-      $vote['value'] = 0;
-    }
-
-    $vote['value_type'] = 'points';
-    $tag = $tag ? $tag : variable_get('vud_tag', 'vote');
-    $vote['tag'] = $tag;
-
-    $vote['content_id'] = $cid;
-    $vote['content_type'] = $type;
-    $vote['tag'] = $tag;
-    $votes = array(0 => $vote);
-    votingapi_set_votes($votes);
-  }
-  else {
-    watchdog("vud", "Could not vote on $type $cid, with value $value, tag $tag and token $token");
-    drupal_set_message("Oops! There was an error in submitting your vote!", 'warning');
-  }
-
-  if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
-    $result_criteria = array(
-      'content_type' => $type,
-      'content_id' => $cid,
-      'value_type' => 'points',
-      'tag' => $tag,
-      'function' => 'sum'
-    );
-    $vote_result = (int) votingapi_select_single_result_value($result_criteria);
-    $f_vote_result = format_plural($vote_result, '1 vote', '@count votes');
-    $js = array(
-      'fullvotes' => $f_vote_result,
-      'votes'     => $vote_result,
-      'type'      => $type,
-      'id'        => $cid,
-      'value'     => $value,
-      'tag'       => $tag,
-    );
-    drupal_json($js);
-    exit;
-  }
-  else {
-    drupal_goto($_SERVER['HTTP_REFERER']);
-  }
-}
-
-/**
  * Callback to reset votes on an object.
  */
 function vud_reset($type, $cid, $tag, $token) {
@@ -206,3 +149,13 @@ function vud_reset($type, $cid, $tag, $t
     drupal_set_message("Oops! There was an error in resetting your vote!", 'warning');
   }
 }
+
+/**
+ * Implementation of hook_ctools_plugin_dierctory() to let the system know
+ * we implement widget plugins.
+ */
+function vud_ctools_plugin_directory($module, $plugin) {
+  if ($module == 'vud') {
+    return $plugin;
+  }
+}
Index: vud.theme.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/Attic/vud.theme.inc,v
retrieving revision 1.1.2.22
diff -u -p -r1.1.2.22 vud.theme.inc
--- vud.theme.inc	19 Aug 2009 05:38:45 -0000	1.1.2.22
+++ vud.theme.inc	3 Nov 2009 15:28:58 -0000
@@ -7,24 +7,90 @@
  */
 
 /**
+ * Implementation of hook_ctools_plugin_*.
+ *
+ * Give information to CTools about the widgets plugin.
+ */
+function vud_ctools_plugin_widgets() {
+  return array(
+    'cache' => FALSE,
+    'defaults' => 'vud_width_plugin_defaults',
+    // Themes can offer this plugin.
+    'load themes' => TRUE,
+  );
+}
+
+/**
+ * Provide defaults for widgets.
+ */
+function vud_width_plugin_defaults($info, &$plugin) {
+  $defaults = array(
+    'render function' => 'theme_render_template',
+    'extension' => '.tpl.php',
+    'css' => $plugin['name'] . '.css',
+  );
+
+  $plugin += $defaults;
+}
+
+/**
+ * Load metadata for a single widget without loading all widgets.
+ */
+function vud_widget_get($name) {
+  ctools_include('plugins');
+  return ctools_get_plugins('vud', 'widgets', $name);
+}
+
+/**
+ * Load metadata for all widgets
+ */
+function vud_widget_get_all() {
+  ctools_include('plugins');
+  return ctools_get_plugins('vud', 'widgets');
+}
+
+/**
+ * Load the names of all widgets for use in a select.
+ *
+ * This can be given directly to #options when choosing a widget.
+ */
+function vud_widget_get_names() {
+  $names = array();
+  foreach (vud_widget_get_all() as $name => $plugin) {
+    $names[$name] = $plugin['title'];
+  }
+
+  asort($names);
+  return $names;
+}
+
+/**
  * Proxy widget function that hook_theme() calls.
  */
 function vud_widget_proxy($cid, $type, $tag, $widget_theme) {
-  $render_function = 'theme_render_template';
-  $extension = '.tpl.php';
+  $plugin = vud_widget_get($widget_theme);
+  if (empty($plugin) || empty($plugin['widget template'])) {
+    return;
+  }
 
-  $template_file = drupal_get_path('module', 'vud') ."/widgets/$widget_theme/widget". $extension;
-  $variables = array('cid' => $cid, 'type' => $type, 'widget_theme' => $widget_theme);
+  $template_file = $plugin['path'] . '/' . $plugin['widget template'] . $plugin['extension'];
+  $variables = array(
+    'cid' => $cid,
+    'type' => $type,
+    'widget_theme' => $widget_theme,
+    'plugin' => $plugin,
+    'tag' => $tag ? $tag : variable_get('vud_tag', 'vote'),
+    'id' => 'widget-' . $type . '-' . $cid,
+    'link_class_up' => 'ctools-use-ajax vud-link-up',
+    'link_class_down' => 'ctools-use-ajax vud-link-down',
+  );
 
   global $user;
-  $variables['cid'] = $cid;
-  $variables['type'] = $type;
-  $variables['widget_theme'] = $widget_theme;
-  $variables['tag'] = $tag ? $tag : variable_get('vud_tag', 'vote');
   $uid = votingapi_current_user_identifier();
 
-  vud_add_css($widget_theme);  // Search and add the CSS files.
-  vud_add_js($widget_theme);   // Search and add the JS files.
+  ctools_add_js('ajax-responder');
+  vud_add_files('css', $plugin);  // Search and add the CSS files.
+  vud_add_files('js', $plugin);   // Search and add the JS files.
 
   $base_criteria = array(
     'content_type' => $type,
@@ -47,11 +113,11 @@ function vud_widget_proxy($cid, $type, $
     $variables['class_down'] = 'down-inactive';
   }
 
-  $token_up = drupal_get_token("vote/$type/$cid/1/$tag");
-  $variables['link_up'] = url("vote/$type/$cid/1/$tag/$token_up");
+  $token_up = drupal_get_token("vote/$type/$cid/1/$tag/$widget_theme");
+  $variables['link_up'] = url("vote/$type/$cid/1/$tag/$widget_theme/$token_up");
 
-  $token_down = drupal_get_token("vote/$type/$cid/-1/$tag");
-  $variables['link_down'] = url("vote/$type/$cid/-1/$tag/$token_down");
+  $token_down = drupal_get_token("vote/$type/$cid/-1/$tag/$widget_theme");
+  $variables['link_down'] = url("vote/$type/$cid/-1/$tag/$widget_theme/$token_down");
 
   $result_criteria = array(
     'content_type' => $type,
@@ -78,7 +144,7 @@ function vud_widget_proxy($cid, $type, $
   }
   $variables['vote_label'] = format_plural($vote_result, 'vote', 'votes');
 
-  $output = $render_function($template_file, $variables);
+  $output = $plugin['render function']($template_file, $variables);
   return $output;
 }
 
@@ -86,11 +152,19 @@ function vud_widget_proxy($cid, $type, $
  * Proxy votes display function, that hook_theme() calls.
  */
 function vud_votes_proxy($cid, $type, $tag, $widget_theme) {
-  $render_function = 'theme_render_template';
-  $extension = '.tpl.php';
+  $plugin = vud_widget_get($widget_theme);
+  if (empty($plugin) || empty($plugin['votes template'])) {
+    return;
+  }
 
-  $template_file = drupal_get_path('module', 'vud') ."/widgets/$widget_theme/votes". $extension;
-  $variables = array('cid' => $cid, 'type' => $type, 'widget_theme' => $widget_theme);
+  $template_file = $plugin['path'] . '/' . $plugin['votes template'] . $plugin['extension'];
+  $variables = array(
+    'cid' => $cid,
+    'type' => $type,
+    'widget_theme' => $widget_theme,
+    'plugin' => $plugin,
+    'id' => 'votes-' . $type . '-' . $cid,
+  );
 
   $variables['tag'] = $tag;
 
@@ -119,55 +193,94 @@ function vud_votes_proxy($cid, $type, $t
   }
   $variables['vote_label'] = format_plural($vote_result, 'vote', 'votes');
 
-  vud_add_css($widget_theme);  // Search and add the CSS files.
-  vud_add_js($widget_theme);   // Search and add the JS files.
+  vud_add_files('css', $plugin);  // Search and add the CSS files.
+  vud_add_files('js', $plugin);   // Search and add the JS files.
 
   if (file_exists($template_file)) {
-      $output = $render_function($template_file, $variables);
-  }
-  else {
-      drupal_set_message("The $template_file file is missing. Please create the file, or set vote points to \"Don't display\".", 'error');
+    return $plugin['render function']($template_file, $variables);
   }
-  return $output;
 }
 
 /**
- * Read and parse the widgets/ directory recursively.
+ * Read and load all CSS or JS files in the selected widget directory.
  */
-function vud_read_widgets() {
-  $vud_path = drupal_get_path('module', 'vud');
-  $widgets_dir = $vud_path .'/widgets';
-  $files = file_scan_directory($widgets_dir, 'widget\.tpl\.php$');
-  $themes = array();
-  foreach ($files as $file) {
-    $widgetword = strlen($file->filename) - strlen($widgets_dir) - strlen($file->basename);
-    $themename = substr($file->filename, strlen($widgets_dir) + 1, $widgetword - 2);
-    $themes["$themename"] = $themename;
+function vud_add_files($type, $plugin) {
+  $function = 'drupal_add_' . $type;
+  if (empty($plugin[$type])) {
+    return;
   }
-  asort($themes);
-  return $themes;
-}
 
-/**
- * Read and load all CSS files in the selected widget directory.
- */
-function vud_add_css($widget) {
-  $vud_path = drupal_get_path('module', 'vud');
-  $widget_dir = $vud_path .'/widgets/'. $widget;
-  $files = file_scan_directory($widget_dir, '\.css$');
-  foreach ($files as $file) {
-    drupal_add_css($file->filename);
+  if (is_string($plugin[$type])) {
+    $css = array($plugin[$type]);
+  }
+
+  if (is_array($plugin[$type])) {
+    $css = $plugin[$type];
+  }
+
+  if (!empty($css)) {
+    foreach ($css as $file) {
+      $function($plugin['path'] . '/' . $file);
+    }
   }
 }
 
 /**
- * Read and load all JavaScript files in the selected widget directory.
+ * Function for the main voting handler with Ajax support.
  */
-function vud_add_js($widget) {
-  $vud_path = drupal_get_path('module', 'vud');
-  $widget_dir = $vud_path .'/widgets/'. $widget;
-  $files = file_scan_directory($widget_dir, '\.js$');
-  foreach ($files as $file) {
-    drupal_add_js($file->filename);
+function vud_vote($type, $cid, $value, $tag, $widget, $token) {
+  if (is_numeric($value) && drupal_valid_token($token, "vote/$type/$cid/$value/$tag/$widget")) {
+    $vote = array();
+    // Sanity-check the incoming values.
+    if ($value > 0) {
+      $vote['value'] = 1;
+    }
+    else if ($value < 0) {
+      $vote['value'] = -1;
+    }
+    else {
+      $vote['value'] = 0;
+    }
+
+    $vote['value_type'] = 'points';
+    $tag = $tag ? $tag : variable_get('vud_tag', 'vote');
+    $vote['tag'] = $tag;
+
+    $vote['content_id'] = $cid;
+    $vote['content_type'] = $type;
+    $vote['tag'] = $tag;
+    $votes = array(0 => $vote);
+    drupal_alter('vud_votes', $votes);
+    votingapi_set_votes($votes);
+  }
+  else {
+    watchdog("vud", "Could not vote on $type $cid, with value $value, tag $tag and token $token");
+    drupal_set_message("Oops! There was an error in submitting your vote!", 'warning');
+  }
+
+  if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
+    ctools_include('ajax');
+    $plugin = vud_widget_get($widget);
+
+    if ($function = ctools_plugin_get_function($plugin, 'ajax render')) {
+      $commands = $function($type, $cid, $value, $tag, $token, $widget);
+    }
+    else {
+      $commands = array();
+      if (!empty($plugin['widget template'])) {
+        $commands[] = ctools_ajax_command_replace("#widget-$type-$cid", theme('vud_widget', $cid, $type, $tag, $widget));
+      }
+
+      if (!empty($plugin['votes template'])) {
+        $commands[] = ctools_ajax_command_replace("#votes-$type-$cid", theme('vud_votes', $cid, $type, $tag, $widget));
+      }
+    }
+
+    // This is the default set of commands. It can be overridden by an individual
+    // widget if it wants to.
+    ctools_ajax_render($commands);
+  }
+  else {
+    drupal_goto($_SERVER['HTTP_REFERER']);
   }
 }
Index: vud_comment/vud_comment.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/vud_comment/Attic/vud_comment.module,v
retrieving revision 1.1.2.17
diff -u -p -r1.1.2.17 vud_comment.module
--- vud_comment/vud_comment.module	22 Aug 2009 04:42:49 -0000	1.1.2.17
+++ vud_comment/vud_comment.module	3 Nov 2009 15:28:58 -0000
@@ -46,7 +46,7 @@ function vud_comment_admin_settings() {
     '#title'       => t('Widget selection'),
     '#description' => t('Select the voting widget theme that will be displayed.'),
     '#default_value' => variable_get('vud_comment_widget', 'plain'),
-    '#options'       => vud_read_widgets(),
+    '#options'       => vud_widget_get_names(),
   );
   $form['vud_comment_votes'] = array(
     '#type'          => 'radios',
Index: vud_node/vud_node.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/vud_node/Attic/vud_node.module,v
retrieving revision 1.1.2.20
diff -u -p -r1.1.2.20 vud_node.module
--- vud_node/vud_node.module	15 Aug 2009 21:15:46 -0000	1.1.2.20
+++ vud_node/vud_node.module	3 Nov 2009 15:28:58 -0000
@@ -55,7 +55,7 @@ function vud_node_admin_settings() {
     '#description'   => t('Select the voting widget theme that will be displayed.'),
     '#type'          => 'radios',
     '#default_value' => variable_get('vud_node_widget', 'plain'),
-    '#options'       => vud_read_widgets(),
+    '#options'       => vud_widget_get_names(),
   );
   $form['vud_node_widget_show'] = array(
     '#type'          => 'select',
Index: vud_term/vud_term.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/vud_term/Attic/vud_term.module,v
retrieving revision 1.1.2.8
diff -u -p -r1.1.2.8 vud_term.module
--- vud_term/vud_term.module	15 Aug 2009 21:15:46 -0000	1.1.2.8
+++ vud_term/vud_term.module	3 Nov 2009 15:28:58 -0000
@@ -46,7 +46,7 @@ function vud_term_admin_settings() {
     '#title'         => t('Widget selection'),
     '#description'   => t('Select the voting widget theme that will be displayed.'),
     '#default_value' => variable_get('vud_term_widget', 'plain'),
-    '#options'       => vud_read_widgets(),
+    '#options'       => vud_widget_get_names(),
   );
   $form['vud_term_votetable_show'] = array(
     '#type'          => 'select',
Index: widgets/alternate/alternate.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/widgets/alternate/Attic/alternate.css,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 alternate.css
--- widgets/alternate/alternate.css	12 Aug 2009 14:23:02 -0000	1.1.2.4
+++ widgets/alternate/alternate.css	3 Nov 2009 15:28:58 -0000
@@ -41,3 +41,16 @@
     font-size: 18px;
     padding: 2px;
 }
+
+.vud-widget-alternate .ctools-ajaxing {
+  padding-right: 0 !important;
+  display: block;
+  width: 50px;
+  height: 22px;
+  background-position: center;
+  float: left;
+}
+
+.vud-widget-alternate .ctools-ajaxing div {
+  display: none;
+}
Index: widgets/alternate/alternate.inc
===================================================================
RCS file: widgets/alternate/alternate.inc
diff -N widgets/alternate/alternate.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ widgets/alternate/alternate.inc	3 Nov 2009 15:28:58 -0000
@@ -0,0 +1,11 @@
+<?php
+
+/**
+ * Specialized implementation of hook_vud_widgets().
+ */
+function vud_alternate_vud_widgets() {
+  return array(
+    'title' => t('Alternate'),
+    'widget template' => 'widget',
+  );
+}
Index: widgets/alternate/alternate.js
===================================================================
RCS file: widgets/alternate/alternate.js
diff -N widgets/alternate/alternate.js
--- widgets/alternate/alternate.js	10 Aug 2009 08:44:34 -0000	1.1.2.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,27 +0,0 @@
-// $Id: alternate.js,v 1.1.2.2 2009/08/10 08:44:34 lut4rp Exp $
-
-Drupal.behaviors.vudAlternateWidget = function () {
-    $('.vud-widget-alternate .up-inactive, .up-active').click(function () {
-	voteurl = $(this).parent().attr('href');
-	$.ajax({
-	    type: 'GET',
-	    url: voteurl,
-	    success: function (data) {
-		data = Drupal.parseJson(data);
-		var longvotes = data.fullvotes;
-		var shrtvotes = data.votes;
-		var type = data.type;
-		var id = data.id;
-		var value = data.value;
-		if (value == 1) {
-		    $('#vote-up-' + type + '-' + id).removeClass('up-inactive').addClass('up-active');
-		}
-		$("#total-votes-" + type + "-" + id).html(shrtvotes);
-	    },
-	    error: function (xmlhttp) {
-		alert('An HTTP '+ xmlhttp.status +' error occured. Your vote was not submitted!');
-	    }
-	});
-	return false;
-    });
-};
\ No newline at end of file
Index: widgets/alternate/widget.tpl.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/widgets/alternate/Attic/widget.tpl.php,v
retrieving revision 1.1.2.10
diff -u -p -r1.1.2.10 widget.tpl.php
--- widgets/alternate/widget.tpl.php	19 Aug 2009 05:38:46 -0000	1.1.2.10
+++ widgets/alternate/widget.tpl.php	3 Nov 2009 15:28:58 -0000
@@ -7,9 +7,11 @@
  * Alternate widget theme for Vote Up/Down
  */
 ?>
-<div class="vud-widget-alternate">
+<div class="vud-widget-alternate" id="<?php print $id; ?>">
 <?php if ($class_up) : ?>
-  <div id="total-votes-<?php print $type; ?>-<?php print $cid; ?>" class="<?php print $widget_theme; ?>-votes-display"><?php print $unsigned_points; ?></div>
-  <a href="<?php print $link_up; ?>"><div id="vote-up-<?php print $type; ?>-<?php print $cid; ?>" class="<?php print $class_up; ?>" title="Vote up!"></div></a>
+  <div class="alternate-votes-display"><?php print $unsigned_points; ?></div>
+  <a href="<?php print $link_up; ?>" class="<?php print $link_class_up; ?>">
+  <div class="<?php print $class_up; ?>" title="<?php print t('Vote up!'); ?>">  </div>
+  </a>
 <?php endif; ?>
 </div>
Index: widgets/plain/ajax.js
===================================================================
RCS file: widgets/plain/ajax.js
diff -N widgets/plain/ajax.js
--- widgets/plain/ajax.js	10 Aug 2009 08:36:13 -0000	1.1.2.8
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,36 +0,0 @@
-// $Id: ajax.js,v 1.1.2.8 2009/08/10 08:36:13 lut4rp Exp $
-
-Drupal.behaviors.vudPlainWidget = function () {
-    $('.vud-widget-plain span.up-inactive, span.down-inactive, span.up-active, span.down-active').click(function () {
-	voteurl = $(this).parent().attr('href');
-	$.ajax({
-	    type: 'GET',
-	    url: voteurl,
-	    success: function (data) {
-		data = Drupal.parseJson(data);
-		var longvotes = data.fullvotes;
-		var shrtvotes = data.votes;
-		var type = data.type;
-		var id = data.id;
-		var value = data.value;
-		if (value == 1) {
-		    $('#vote-up-' + type + '-' + id).removeClass('up-inactive').addClass('up-active');
-		    $('#vote-down-' + type + '-' + id).removeClass('down-active').addClass('down-inactive');
-		}
-		if (value == -1) {
-		    $('#vote-down-' + type + '-' + id).removeClass('down-inactive').addClass('down-active');
-		    $('#vote-up-' + type + '-' + id).removeClass('up-active').addClass('up-inactive');
-		}
-		if (type == 'term') {
-		    $("#total-votes-" + type + "-" + id).html(shrtvotes);
-		} else {
-		    $("#total-votes-" + type + "-" + id + " .total").html(longvotes);
-		}
-	    },
-	    error: function (xmlhttp) {
-		alert('An HTTP '+ xmlhttp.status +' error occured. Your vote was not submitted!');
-	    }
-	});
-	return false;
-    });
-};
Index: widgets/plain/plain.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/widgets/plain/Attic/plain.css,v
retrieving revision 1.1.2.5
diff -u -p -r1.1.2.5 plain.css
--- widgets/plain/plain.css	15 Aug 2009 21:15:46 -0000	1.1.2.5
+++ widgets/plain/plain.css	3 Nov 2009 15:28:58 -0000
@@ -67,3 +67,24 @@
   width: 40em;
   margin: 0.5em 0 0.5em 1em;
 }
+
+.vud-widget-plain .ctools-ajaxing {
+  padding-right: 0 !important;
+  display: block;
+  width: 15px;
+  height: 16px;
+  background-position: center;
+  float: left;
+}
+
+.vud-widget-plain .ctools-ajaxing.plain-click-up {
+  margin-right: 3px;
+}
+
+.vud-widget-plain .ctools-ajaxing.plain-click-down {
+  margin-left: 3px;
+}
+
+.vud-widget-plain .ctools-ajaxing span {
+  display: none;
+}
Index: widgets/plain/plain.inc
===================================================================
RCS file: widgets/plain/plain.inc
diff -N widgets/plain/plain.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ widgets/plain/plain.inc	3 Nov 2009 15:28:58 -0000
@@ -0,0 +1,12 @@
+<?php
+
+/**
+ * Specialized implementation of hook_vud_widgets().
+ */
+function vud_plain_vud_widgets() {
+  return array(
+    'title' => t('Plain'),
+    'widget template' => 'widget',
+    'votes template' => 'votes',
+  );
+}
Index: widgets/plain/votes.tpl.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/widgets/plain/Attic/votes.tpl.php,v
retrieving revision 1.1.2.7
diff -u -p -r1.1.2.7 votes.tpl.php
--- widgets/plain/votes.tpl.php	19 Aug 2009 05:38:46 -0000	1.1.2.7
+++ widgets/plain/votes.tpl.php	3 Nov 2009 15:28:58 -0000
@@ -7,4 +7,4 @@
  * Plain widget votes display for Vote Up/Down
  */
 ?>
-<span id="total-votes-<?php print $type; ?>-<?php print $cid; ?>" class="total-votes-plain"><span class="<?php print $class; ?> total"><?php print $unsigned_points; ?> <?php print $vote_label; ?></span></span>
+<span id="<?php print $id; ?>" class="total-votes-plain"><span class="<?php print $class; ?> total"><?php print $unsigned_points; ?> <?php print $vote_label; ?></span></span>
Index: widgets/plain/widget.tpl.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/widgets/plain/Attic/widget.tpl.php,v
retrieving revision 1.1.2.9
diff -u -p -r1.1.2.9 widget.tpl.php
--- widgets/plain/widget.tpl.php	16 Aug 2009 19:30:02 -0000	1.1.2.9
+++ widgets/plain/widget.tpl.php	3 Nov 2009 15:28:58 -0000
@@ -7,9 +7,13 @@
  * Plain widget theme for Vote Up/Down
  */
 ?>
-<div class="vud-widget-plain">
-<?php if ($class_up) { ?>
-  <a href="<?php print $link_up; ?>"><span id="vote-up-<?php print $type; ?>-<?php print $cid; ?>" class="<?php print $class_up; ?>" title="Vote up!"></span></a>
-  <a href="<?php print $link_down; ?>"><span id="vote-down-<?php print $type; ?>-<?php print $cid; ?>" class="<?php print $class_down; ?>" title="Vote down!"></span></a>
-<?php } ?>
+<div class="vud-widget-plain" id="<?php print $id; ?>">
+<?php if ($class_up): ?>
+  <a href="<?php print $link_up; ?>" class="<?php print $link_class_up; ?>">
+    <span class="<?php print $class_up; ?>" title="<?php print t('Vote up!'); ?>"></span>
+  </a>
+  <a href="<?php print $link_down; ?>" class="<?php print $link_class_down; ?>">
+    <span class="<?php print $class_down; ?>" title="<?php print t('Vote down!'); ?>"></span>
+  </a>
+<?php endif; ?>
 </div>
Index: widgets/updown/updown.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/widgets/updown/Attic/updown.css,v
retrieving revision 1.1.2.6
diff -u -p -r1.1.2.6 updown.css
--- widgets/updown/updown.css	16 Aug 2009 19:22:05 -0000	1.1.2.6
+++ widgets/updown/updown.css	3 Nov 2009 15:28:58 -0000
@@ -43,14 +43,14 @@
   font-size: 20px;
 }
 
-.vud-widget-updown .up-inactive,
-.vud-widget-updown .up-active {
+.vud-widget-updown .vud-link-up div {
   float: left;
+  margin-right: 3px;
 }
 
-.vud-widget-updown .down-inactive,
-.vud-widget-updown .down-active {
-  float: right;
+.vud-widget-updown .vud-link-down div {
+  float: left;
+  margin-left: 3px;
 }
 
 .vud-widget-updown .up-active,
@@ -66,3 +66,24 @@
   cursor: default;
 }
 
+.vud-widget-updown .ctools-ajaxing {
+  border: 1px solid #ccc;
+  padding-right: 0 !important;
+  display: block;
+  width: 20px;
+  height: 22px;
+  background-position: center;
+  float: left;
+}
+
+.vud-widget-updown .ctools-ajaxing.updown-click-up {
+  margin-right: 3px;
+}
+
+.vud-widget-updown .ctools-ajaxing.updown-click-down {
+  margin-left: 3px;
+}
+
+.vud-widget-updown .ctools-ajaxing div {
+  display: none;
+}
Index: widgets/updown/updown.inc
===================================================================
RCS file: widgets/updown/updown.inc
diff -N widgets/updown/updown.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ widgets/updown/updown.inc	3 Nov 2009 15:28:58 -0000
@@ -0,0 +1,11 @@
+<?php
+
+/**
+ * Specialized implementation of hook_vud_widgets().
+ */
+function vud_updown_vud_widgets() {
+  return array(
+    'title' => t('Default'),
+    'widget template' => 'widget',
+  );
+}
Index: widgets/updown/updown.js
===================================================================
RCS file: widgets/updown/updown.js
diff -N widgets/updown/updown.js
--- widgets/updown/updown.js	10 Aug 2009 13:26:46 -0000	1.1.2.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,31 +0,0 @@
-// $Id: updown.js,v 1.1.2.1 2009/08/10 13:26:46 lut4rp Exp $
-
-Drupal.behaviors.vudUpdownWidget = function () {
-    $('.vud-widget-updown .up-active, .up-inactive, .down-active, .down-inactive').click(function () {
-	voteurl = $(this).parent().attr('href');
-	$.ajax({
-	    type: 'GET',
-	    url: voteurl,
-	    success: function (data) {
-		data = Drupal.parseJson(data);
-		var shrtvotes = data.votes;
-		var type = data.type;
-		var id = data.id;
-		var value = data.value;
-		if (value == 1) {
-		    $('#updown-up-' + type + '-' + id).removeClass('up-inactive').addClass('up-active');
-		    $('#updown-down-' + type + '-' + id).removeClass('down-active').addClass('down-inactive');
-		}
-		if (value == -1) {
-		    $('#updown-down-' + type + '-' + id).removeClass('down-inactive').addClass('down-active');
-		    $('#updown-up-' + type + '-' + id).removeClass('up-active').addClass('up-inactive');
-		}
-		$("span#total-votes-" + type + "-" + id).html(shrtvotes);
-	    },
-	    error: function (xmlhttp) {
-		alert('An HTTP '+ xmlhttp.status +' error occured. Your vote was not submitted!');
-	    }
-	});
-	return false;
-    });
-};
\ No newline at end of file
Index: widgets/updown/widget.tpl.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/widgets/updown/Attic/widget.tpl.php,v
retrieving revision 1.1.2.7
diff -u -p -r1.1.2.7 widget.tpl.php
--- widgets/updown/widget.tpl.php	19 Aug 2009 05:38:46 -0000	1.1.2.7
+++ widgets/updown/widget.tpl.php	3 Nov 2009 15:28:58 -0000
@@ -8,8 +8,15 @@
  * UpDown widget theme for Vote Up/Down
  */
 ?>
-<div class="vud-widget-updown">
-  <div class="updown-score"><span class="updown-current-score" id="total-votes-<?php print $type; ?>-<?php print $cid; ?>"><?php print $unsigned_points; ?></span><?php print $vote_label; ?></div>
-  <a href="<?php print $link_up; ?>"><div class="<?php print $class_up; ?>" id="updown-up-<?php print $type; ?>-<?php print $cid; ?>" title="Vote up!">+</div></a>
-  <a href="<?php print $link_down; ?>"><div class="<?php print $class_down; ?>" id="updown-down-<?php print $type; ?>-<?php print $cid; ?>" title="Vote down!">-</div></a>
+<div class="vud-widget-updown" id="<?php print $id; ?>">
+  <div class="updown-score">
+    <span class="updown-current-score"><?php print $unsigned_points; ?></span>
+    <?php print $vote_label; ?>
+  </div>
+  <a href="<?php print $link_up; ?>" class="<?php print $link_class_up; ?>">
+    <div class="<?php print $class_up; ?>" title="<?php print t('Vote up!'); ?>">+</div>
+  </a>
+  <a href="<?php print $link_down; ?>" class="<?php print $link_class_down; ?>">
+    <div class="<?php print $class_down; ?>" title="<?php print t('Vote down!'); ?>">-</div>
+  </a>
 </div>
