Author: jablko
Date: Wed Oct 20 18:12:38 2010
New Revision: 8345

Log:
Cosmetic changes

Modified:
   trunk/js/multiInput.js

Modified: trunk/js/multiInput.js
==============================================================================
--- trunk/js/multiInput.js      Wed Oct 20 18:00:43 2010        (r8344)
+++ trunk/js/multiInput.js      Wed Oct 20 18:12:38 2010        (r8345)
@@ -19,41 +19,45 @@
 
           $('input.multiInput', context).each(function ()
             {
-              var thisName = this.name;
+              var name = this.name;
 
               $(this)
-                // Remove @name to avoid submitting value in the "new" input 
field
+
+                // Remove @name to avoid submitting value in the "new" input
+                // field
                 .removeAttr('name')
 
-                // Catch blur, click or keypress events
+                // Bind blur, click, or keydown events
                 .bind('blur click keydown', function (event)
                   {
-                    if ($(this).data('counter') == undefined)
+                    if (undefined === $(this).data('counter'))
                     {
                       $(this).data('counter', 0);
                     }
                     var counter = $(this).data('counter');
 
-                    // Don't fire on keypress other than Tab (9) or Enter (13) 
key
-                    if ($(this).val() && ('keydown' != event.type || 9 == 
event.keyCode || 13 == event.keyCode))
+                    // Don't fire on keydown other than tab (9) or enter (13)
+                    if ($(this).val()
+                        && ('keydown' !== event.type
+                          || 9 === event.keyCode
+                          || 13 === event.keyCode))
                     {
                       // Cancel default action so as not to loose focus
-                      if ('keydown' == event.type)
+                      if ('keydown' === event.type)
                       {
                         event.preventDefault();
                       }
 
                       // Add input value to multInput
-                      var stem = thisName.replace('[new]', '');
-                      var input = '<input id="' + stem + '_new_' + counter + 
'" name="' + stem + '[new' + counter + ']" value="' + this.value + '">';
-                      var li = $('<li>' + input + '</li>');
+                      var stem = name.replace('[new]', '');
+                      var $li = $('<li><input id="' + stem + '_new_' + counter 
+ '" name="' + stem + '[new' + counter + ']" value="' + this.value + 
'"/></li>');
 
                       // Bind click event to new list item
-                      li.click(function (event)
+                      $li.click(function (event)
                         {
-                          if (event.target == this)
+                          if (event.target === this)
                           {
-                            // On click, remove <li>
+                            // On click, remove <li/>
                             $(this).hide('fast', function ()
                               {
                                 $(this).remove();
@@ -61,18 +65,18 @@
                           }
                         });
 
-                      // Create ul if it doesn't exist
-                      if (0 == $(this).prev('ul.multInput').length)
+                      // Create <ul/> if it doesn't exist
+                      if (!!$(this).prev('ul.multInput').length)
                       {
-                        // Add ul element, if it doesn't exist already (new 
object)
-                        var ul = '<ul class="multInput" name="' + stem + 
'"></ul>';
-                        $(this).before(ul);
+                        // Add <ul/> element, if it doesn't exist already (new
+                        // object)
+                        $('<ul class="multInput" name="' + stem + 
'"/>').insertBefore(this);
                       }
 
-                      // Add li to ul
-                      $(this).prev('ul.multInput').append(li);
+                      // Add <li/> to <ul/>
+                      $(this).prev('ul.multInput').append($li);
 
-                      // Clear <input>
+                      // Clear <input/>
                       this.value = '';
 
                       $(this).data('counter', ++counter);

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to