Author: jablko
Date: Sun Oct 24 18:28:40 2010
New Revision: 8449

Log:
Initialize min and max

Modified:
   trunk/js/date.js

Modified: trunk/js/date.js
==============================================================================
--- trunk/js/date.js    Sun Oct 24 18:17:47 2010        (r8448)
+++ trunk/js/date.js    Sun Oct 24 18:28:40 2010        (r8449)
@@ -10,60 +10,104 @@
               var $start = $('[id$=startDate]', this);
               var $end = $('[id$=endDate]', this);
 
-              var min = '';
-              var max = '';
+              var min = [];
+              var max = [];
 
-              $('[id$=dateDisplay]', this).change(function ()
-                {
-                  if (min === $start.val() && max === $end.val())
+              var matches = $('[id$=dateDisplay]', this)
+                .change(function ()
                   {
-                    min = max = [];
-
-                    var matches = 
$(this).val().match(/\d+(?:[-/]0*(?:1[0-2]|\d)(?:[-/]0*(?:3[01]|[12]?\d))?(?!\d))?/g);
-                    if (matches)
+                    if (min === $start.val() && max === $end.val())
                     {
-                      jQuery.each(matches, function (index)
-                        {
-                          var matches = this.match(/\d+/g);
-                          if (0 === index)
+                      min = max = [];
+
+                      var matches = 
$(this).val().match(/\d+(?:[-/]0*(?:1[0-2]|\d)(?:[-/]0*(?:3[01]|[12]?\d))?(?!\d))?/g);
+                      if (matches)
+                      {
+                        jQuery.each(matches, function (index)
                           {
-                            min = max = matches;
+                            var matches = this.match(/\d+/g);
+                            if (0 === index)
+                            {
+                              min = max = matches;
 
-                            return;
-                          }
+                              return;
+                            }
 
-                          jQuery.each(min, function (index)
-                            {
-                              if (this - 0 < matches[index] - 0)
+                            jQuery.each(min, function (index)
                               {
-                                return false;
-                              }
+                                if (this - 0 < matches[index] - 0)
+                                {
+                                  return false;
+                                }
+
+                                if (this - 0 != matches[index] - 0)
+                                {
+                                  min = matches;
+                                }
+                              });
 
-                              if (this - 0 != matches[index] - 0)
+                            jQuery.each(max, function (index)
                               {
-                                min = matches;
-                              }
-                            });
+                                if (this - 0 > matches[index] - 0)
+                                {
+                                  return false;
+                                }
+
+                                if (this - 0 != matches[index] - 0)
+                                {
+                                  max = matches;
+                                }
+                              });
+                          });
+                      }
 
-                          jQuery.each(max, function (index)
-                            {
-                              if (this - 0 > matches[index] - 0)
-                              {
-                                return false;
-                              }
+                      $start.val(min = min.join('-'));
+                      $end.val(max = max.join('-'));
+                    }
+                  })
+                
.val().match(/\d+(?:[-/]0*(?:1[0-2]|\d)(?:[-/]0*(?:3[01]|[12]?\d))?(?!\d))?/g);
+              if (matches)
+              {
+                jQuery.each(matches, function (index)
+                  {
+                    var matches = this.match(/\d+/g);
+                    if (0 === index)
+                    {
+                      min = max = matches;
 
-                              if (this - 0 != matches[index] - 0)
-                              {
-                                max = matches;
-                              }
-                            });
-                        });
+                      return;
                     }
 
-                    $start.val(min = min.join('-'));
-                    $end.val(max = max.join('-'));
-                  }
-                });
+                    jQuery.each(min, function (index)
+                      {
+                        if (this - 0 < matches[index] - 0)
+                        {
+                          return false;
+                        }
+
+                        if (this - 0 != matches[index] - 0)
+                        {
+                          min = matches;
+                        }
+                      });
+
+                    jQuery.each(max, function (index)
+                      {
+                        if (this - 0 > matches[index] - 0)
+                        {
+                          return false;
+                        }
+
+                        if (this - 0 != matches[index] - 0)
+                        {
+                          max = matches;
+                        }
+                      });
+                  });
+              }
+
+              min = min.join('-');
+              max = max.join('-');
             });
         } };
   })(jQuery);

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