Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/jskitcomments/README.txt,v
retrieving revision 1.3
diff -u -r1.3 README.txt
--- README.txt	16 Jul 2009 08:46:58 -0000	1.3
+++ README.txt	16 Jul 2009 16:02:47 -0000
@@ -11,9 +11,11 @@
 can also leave comments using this JS-Kit Comments Widget.
 
 Customization of the JS-Kit Comments widget is captured in the 
-administration page for this module. For more advanced customization 
-like custom JS-Kit Comments widget template or customized styling 
-the module offers theme hooks.
+administration page for this module. For more advanced customization
+like custom JS-Kit Comments widget template the module offers theme
+hooks. To change the CSS style of the comments, create a CSS file
+named "jskitcomments.css" in your theme directory and put the CSS
+styles in there.
 
 Documentation on JS-Kit Comments customizations can be found here:
   http://js-kit.com/comments/custom.html
Index: jskitcomments.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/jskitcomments/jskitcomments.module,v
retrieving revision 1.4
diff -u -r1.4 jskitcomments.module
--- jskitcomments.module	16 Jul 2009 08:47:53 -0000	1.4
+++ jskitcomments.module	16 Jul 2009 16:02:47 -0000
@@ -65,7 +65,43 @@
     break;
   }
 }
-      
+
+/**
+ * Implementation of hook_link.
+ */
+function jskitcomments_link($type, $object, $teaser = FALSE) {
+  $links = array();
+  if ($type == 'node' && $teaser) {
+    // Only display the link for nodes that have comments.
+    if (in_array($object->type, variable_get('jskitcomments_nodetypes', array()), TRUE)) {
+      // Make sure the user has access to view the comments.
+      if (user_access('view jskitcomments')) {
+        // Load the JS-Kit comment count API.
+        jskitcomments_add('comments-count');
+
+        // Create the span tag that will load in the number of comments.
+        $count = '<span'. drupal_attributes(array(
+          'class' => 'js-kit-comments-count',
+          'permalink' => url("node/$object->nid", array('absolute' => TRUE, 'alias' => FALSE)),
+          'path' => "/node/$object->nid",
+          'domain' => variable_get('jskitcomments_domain', ''),
+        )) .'></span>';
+
+        // Create the link itself, featuring the new span tag.
+        $links['jskitcomments_count'] = array(
+          'title' => t('!count Comments', array('!count' => $count)),
+          'href' => 'node/'. $object->nid,
+          'attributes' => array(
+            'title' => t('View comments regarding this topic.'),
+          ),
+          'html' => TRUE,
+        );
+      }
+    }
+  }
+  return $links;
+}
+
 /**
  * Implementation of hook_block().
  */
@@ -88,16 +124,6 @@
 }
 
 /**
- * Implementation of hook_footer().
- */
-function jskitcomments_footer($main = 0) {
-  $node = menu_get_object();
-  if (isset($node) && isset($node->jskitcomments)) {
-    return theme('jskitcomments_footer');
-  }
-}
-
-/**
  * Implementation of hook_theme().
  */
 function jskitcomments_theme() {
@@ -116,9 +142,6 @@
         'attributes' => NULL
       ),
     ),
-    'jskitcomments_footer' => array(
-      'arguments' => array(),
-	 ),
   );
 }
 
@@ -164,15 +187,6 @@
 }
 
 /**
- * Renders the supporting JavaScript for JS-Kit Comments just before the </body> tag.
- * Themes can overide this function to do more complex customizations of JS-Kit Comments
- * Add custom style tags after this script!
- */
-function theme_jskitcomments_footer() {
-  return '<script src="http://js-kit.com/comments.js"></script>';
-}
-
-/**
  * Generate the JS-Kit comments script tag for the node with the specified theme hook.
  * 
  * @param $node
@@ -229,6 +243,40 @@
   if (!empty($flashcolor)) {
     $attributes['flashColor'] = check_plain('#'.$flashcolor);
   }
+
+  // Load the JS-Kit comments API.
+  jskitcomments_add('comments');
+
   return theme($hook, $uniq, $permalink, $attributes);
 }
 
+/**
+ * Adds the required Drupal JavaScript behaviors to the page.
+ *
+ * @param $type
+ *   (optional) If given, will processes the given JS-Kit API to load. Available
+ *   values are "comments" to display the full comments list on the page, or
+ *   "comments-count" to display the number of comments in the links.
+ */
+function jskitcomments_add($type = NULL) {
+  // Make sure to only add JavaScript types once.
+  static $added = NULL;
+  if (!isset($added)) {
+    // Add the Drupal JavaScript behavior.
+    drupal_add_js(drupal_get_path('module', 'jskitcomments') .'/jskitcomments.js');
+    // State that the JavaScript has been added so that it's not added twice.
+    $added = array();
+  }
+  // Process the type of JavaScript from JS-Kit to load.
+  if (isset($type) && !isset($added[$type])) {
+    drupal_add_js(array('jskitcomments' => array($type)), 'setting');
+    // Allow themes to add their own CSS to change the styling of the comments.
+    if ($type == 'comments') {
+      $css = path_to_theme() .'/jskitcomments.css';
+      if (file_exists($css)) {
+        drupal_add_css($css, 'theme');
+      }
+    }
+    $added[$type] = TRUE;
+  }
+}
Index: jskitcomments.js
===================================================================
RCS file: jskitcomments.js
diff -N jskitcomments.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ jskitcomments.js	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,24 @@
+// $Id$
+
+/**
+ * Drupal JS-Kit behaviors.
+ */
+Drupal.behaviors.jskitcomments = function(context) {
+  if (Drupal.settings.jskitcomments) {
+    // This prevents JS-Kit from using document.write().
+    window.$JCCAI = true;
+
+    // Process through all desired JS-Kit APIs.
+    jQuery.each(Drupal.settings.jskitcomments, function(index, value) {
+      // Make the AJAX call for the JS-Kit API using the browser cache.
+      jQuery.ajax({
+        type: 'GET',
+        url: 'http://js-kit.com/' + value + '.js',
+        dataType: 'script',
+        cache: true
+      });
+    });
+    // Make sure it doesn't process the elements twice.
+    Drupal.settings.jskitcomments = false;
+  }
+};
