Author: jablko
Date: Mon Oct 18 16:19:11 2010
New Revision: 8246

Log:
Cosmetic changes

Modified:
   trunk/js/autocomplete.js
   trunk/js/dialog.js

Modified: trunk/js/autocomplete.js
==============================================================================
--- trunk/js/autocomplete.js    Mon Oct 18 15:43:09 2010        (r8245)
+++ trunk/js/autocomplete.js    Mon Oct 18 16:19:11 2010        (r8246)
@@ -53,8 +53,8 @@
                                 {
                                   $(this).remove();
 
-                                  // Toggle <ul> based on children length
-                                  $ul.toggle(0 < $ul.children().length);
+                                  // Toggle <ul/> based on children length
+                                  $ul.toggle($ul.children().length);
                                 });
                             })
                           .appendTo($ul.show());
@@ -77,7 +77,7 @@
                       // field is completely removed, hidden value is cleared.
                       .change(function ()
                       {
-                        if (0 == $input.val().length)
+                        if (!$input.val().length)
                         {
                           $hidden.val('');
                         }
@@ -217,19 +217,19 @@
                         // If this item is already selected, highlight it,
                         // otherwise add it to list of selected items
                         if (!$('li:has(input[value=' + args[2][1] + '])', $ul)
-                          .each(function ()
-                            {
-                              // Make background yellow for one second
-                              //
-                              // TODO Use CSS class
-                              var $span = $('span', this).css('background', 
'yellow');
+                            .each(function ()
+                              {
+                                // Make background yellow for one second
+                                //
+                                // TODO Use CSS class
+                                var $span = $('span', this).css('background', 
'yellow');
 
-                              setTimeout(function ()
-                                {
-                                  $span.css('background', 'none');
-                                }, 1000);
-                            })
-                          .length)
+                                setTimeout(function ()
+                                  {
+                                    $span.css('background', 'none');
+                                  }, 1000);
+                              })
+                            .length)
                         {
                           // Make <li/> of hidden <input/> with item value, and
                           // <span/> with item HTML
@@ -247,8 +247,8 @@
                                   {
                                     $(this).remove();
 
-                                    // Toggle <ul> based on children length
-                                    $ul.toggle(0 < $ul.children().length);
+                                    // Toggle <ul/> based on children length
+                                    $ul.toggle($ul.children().length);
                                   });
                               })
                             .appendTo($ul.show());
@@ -447,8 +447,9 @@
                                       {
                                         $(this).remove();
                                         
-                                        // Toggle <ul> based on children length
-                                        $ul.toggle(0 < $ul.children().length);
+                                        // Toggle <ul/> based on children
+                                        // length
+                                        $ul.toggle($ul.children().length);
                                       });
 
                                     // Cancel addition of new choice
@@ -498,7 +499,7 @@
                           // This is because listeners have the same name in
                           // each scope, and it will get overridden if the if
                           // statement evaluates
-                          if (0 == $input.parents('div.yui-dialog').length)
+                          if (!$input.parents('div.yui-dialog').length)
                           {
                             $(form).submit(submit);
                           }

Modified: trunk/js/dialog.js
==============================================================================
--- trunk/js/dialog.js  Mon Oct 18 15:43:09 2010        (r8245)
+++ trunk/js/dialog.js  Mon Oct 18 16:19:11 2010        (r8246)
@@ -257,8 +257,8 @@
     {
       if (undefined == arguments[0])
       {
-        // If no "id" passed as argument then create unique id and skip the 
data
-        // load
+        // If no "id" passed as argument then create unique id and skip the
+        // data load
         this.id = 'new' + this.instances++;
       }
       else
@@ -266,7 +266,7 @@
         this.id = arguments[0];
       }
 
-      if (0 == arguments.length)
+      if (!arguments.length)
       {
         this.yuiDialog.show();
         this.yuiDialog.focusFirst();
@@ -280,20 +280,8 @@
       }
     }
 
-  this.loadData = function ()
+  this.loadData = function (id, callback)
     {
-      if (undefined == arguments[0])
-      {
-        return this;
-      }
-
-      var id = arguments[0];
-
-      if (1 < arguments.length)
-      {
-        var callback = arguments[1];
-      }
-
       if (undefined != this.data[id])
       {
         this.updateDialog(id, this.data[id], callback)
@@ -304,39 +292,35 @@
         var dataSource = new YAHOO.util.XHRDataSource(id);
         dataSource.responseType = YAHOO.util.DataSourceBase.TYPE_JSON;
         dataSource.parseJSONData = function (request, response)
-        {
-          if (undefined != thisDialog.options.relationTableMap)
-          {
-            return { results: [thisDialog.options.relationTableMap(response)] 
};
-          }
-          else
           {
-            var dataMap = function (response)
-              {
-                for (name in response)
+            if (undefined != thisDialog.options.relationTableMap)
+            {
+              return { results: 
[thisDialog.options.relationTableMap(response)] };
+            }
+            else
+            {
+              var dataMap = function (response)
                 {
-                  this[thisDialog.fieldPrefix + '[' + name + ']'] = 
response[name];
+                  for (name in response)
+                  {
+                    this[thisDialog.fieldPrefix + '[' + name + ']'] = 
response[name];
+                  }
                 }
-              }
 
-            return { results: [new dataMap(response)] };
+              return { results: [new dataMap(response)] };
+            }
           }
-        }
 
-        dataSource.sendRequest(null, function (req, res)
+        dataSource.sendRequest(null, function (request, response)
           {
-            success: thisDialog.updateDialog(id, res.results[0], callback);
+            success: thisDialog.updateDialog(id, response.results[0], 
callback);
             failure: null;
           });
       }
     }
 
-  this.updateDialog = function ()
+  this.updateDialog = function (thisId, thisData, callback)
     {
-      var thisId = arguments[0];
-      var thisData = arguments[1];
-      var callback = arguments[2];
-
       if (undefined == this.data[thisId])
       {
         this.data[thisId] = thisData;
@@ -355,7 +339,9 @@
         this.fields[fieldname].value = thisData[fieldname];
 
         // Get display value for autocompletes
-        if 
($(this.fields[fieldname]).next('input').hasClass('form-autocomplete'))
+        if ($(this.fields[fieldname])
+            .next('input')
+            .hasClass('form-autocomplete'))
         {
           var hiddenInput = this.fields[fieldname];
 
@@ -371,15 +357,16 @@
             var dataSource = new YAHOO.util.XHRDataSource(hiddenInput.value);
             dataSource.responseType = YAHOO.util.DataSourceBase.TYPE_TEXT;
             dataSource.parseTextData = function (request, response)
-            {
-              var text = $('h1.label', response.toString()).text();
-              return { 'results': [ text ]};
-            };
+              {
+                var text = $('h1.label', response).text();
+
+                return { 'results': [ text ]};
+              };
 
             var myCallback = {
-              success: function (req, res, payload)
+              success: function (request, response, payload)
                 {
-                  
$(payload.hiddenInput).next('input.form-autocomplete').val(res.results[0]);
+                  
$(payload.hiddenInput).next('input.form-autocomplete').val(response.results[0]);
                 },
               argument: { 'hiddenInput': hiddenInput }
             }
@@ -514,7 +501,7 @@
           });
 
       // If this is an existing relationship, then store id for deletion
-      if ('new' != thisId.substr(0,3))
+      if ('new' != thisId.substr(0, 3))
       {
         this.deletes.push(thisId.match(/\d+$/));
       }
@@ -558,14 +545,12 @@
         }
       }
 
-      if (0 == $('tr[id=' + this.id + ']', displayTable).length)
+      if (!$('tr[id=' + this.id + ']', displayTable)
+          .replaceWith(tr)
+          .length)
       {
         $(displayTable).append(tr);
       }
-      else
-      {
-        $('tr[id=' + this.id + ']', displayTable).replaceWith(tr);
-      }
 
       // Bind events
       $('img[alt=edit]', tr).click(function ()

-- 
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