Index: simplenews.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simplenews/simplenews.js,v
retrieving revision 1.4
diff -u -r1.4 simplenews.js
--- simplenews.js	20 Feb 2010 09:23:04 -0000	1.4
+++ simplenews.js	6 Jan 2011 20:58:23 -0000
@@ -1,30 +1,30 @@
-// $Id: simplenews.js,v 1.4 2010/02/20 09:23:04 sutharsan Exp $
+//$Id: simplenews.js,v 1.4 2010/02/20 09:23:04 sutharsan Exp $
+(function ($) {
 
 /**
  * Set text of Save button dependent on the selected send option.
- * @todo Changed Drupal.behaviors: http://drupal.org/node/224333#drupal_behaviors
- * @todo Wrap jQuery code: http://drupal.org/node/224333#javascript_compatibility
- * @todo behaviors settings passed locally: http://drupal.org/node/224333#local_settings_behaviors
  */
-// TODO This does not work
-Drupal.behaviors.simplenewsCommandSend = function (context) {
-  var simplenewsSendButton = function () {
-    switch ($(".simplenews-command-send :radio:checked").val()) {
+Drupal.behaviors.simplenewsCommandSend = {
+  attach: function (context) {
+    var commandSend = $(".simplenews-command-send", context);
+    var sendButton = function () {
+      switch ($(":radio:checked", commandSend).val()) {
       case '0':
-        $('#edit-submit').attr({value: Drupal.t('Save')});
+        $('#edit-submit', context).attr({value: Drupal.t('Save')});
         break;
       case '1':
-        $('#edit-submit').attr({value: Drupal.t('Save and send')});
+        $('#edit-submit', context).attr({value: Drupal.t('Save and send')});
         break;
       case '2':
-        $('#edit-submit').attr({value: Drupal.t('Save and send test')});
+        $('#edit-submit', context).attr({value: Drupal.t('Save and send test')});
         break;
+      }
     }
+
+    // Update send button at page load and when a send option is selected.
+    sendButton();
+    commandSend.click( function() { sendButton(); });
   }
-  
-  // Update send button at page load and when a send option is selected.
-  $(function() { simplenewsSendButton(); });
-  $(".simplenews-command-send").click( function() { simplenewsSendButton(); });
-  
-  
-}
+};
+
+})(jQuery);
\ No newline at end of file
