[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_0BETA2-300-g2817ebe

Marc Delisle lem9 at users.sourceforge.net
Fri Jan 14 15:21:05 CET 2011


The branch, master has been updated
       via  2817ebe8e9b69c3ad7d29cfdb5a7ba8c7a949e13 (commit)
      from  867892816d37dde8e2848c6f659f174837a1e147 (commit)


- Log -----------------------------------------------------------------
commit 2817ebe8e9b69c3ad7d29cfdb5a7ba8c7a949e13
Author: Marc Delisle <marc at infomarc.info>
Date:   Fri Jan 14 09:20:09 2011 -0500

    - Avoid incorrect validation after using datepicker
    - Partly jQueryfy a function
    - After fixing an incorrect value, the field remained red

-----------------------------------------------------------------------

Summary of changes:
 js/tbl_change.js |   69 +++++++++++++++++++++++++-----------------------------
 tbl_change.php   |    4 +++
 2 files changed, 36 insertions(+), 37 deletions(-)

diff --git a/js/tbl_change.js b/js/tbl_change.js
index ebd88ff..69dfdf5 100644
--- a/js/tbl_change.js
+++ b/js/tbl_change.js
@@ -156,8 +156,7 @@ function isTime(val)
         return true;
 }
 
-function verificationsAfterFieldChange(urlField, multi_edit,theType){
-    var rowForm = document.forms['insertForm'];
+function verificationsAfterFieldChange(urlField, multi_edit, theType){
     var evt = window.event || arguments.callee.caller.arguments[0];
     var target = evt.target || evt.srcElement;
 
@@ -166,53 +165,49 @@ function verificationsAfterFieldChange(urlField, multi_edit,theType){
 
     // Unchecks the Ignore checkbox for the current row
     $("input[name='insert_ignore_" + multi_edit + "']").attr({'checked': false});
+    $this_input = $("input[name='fields[multi_edit][" + multi_edit + "][" + urlField + "]']");
 
-    if(target.name.substring(0,6)=="fields")
-    {
-        var dt=rowForm.elements['fields[multi_edit][' + multi_edit + '][' + urlField + ']'];
+    // Does this field come from datepicker?
+    if ($this_input.data('comes_from') == 'datepicker') {
+        // Yes, so do not validate because the final value is not yet in
+        // the field and hopefully the datepicker returns a valid date+time
+        $this_input.data('comes_from', '');
+        return true;
+    }
+
+    if(target.name.substring(0,6)=="fields") {
         // validate for date time
-        if(theType=="datetime"||theType=="time"||theType=="date"||theType=="timestamp")
-        {
+        if(theType=="datetime"||theType=="time"||theType=="date"||theType=="timestamp") {
+            $this_input.removeClass("invalid_value");
+            var dt_value = $this_input.val();
             if(theType=="date"){
-                if(!isDate(dt.value))
-                    {
-                        dt.className="invalid_value";
-                        return false;
-                    }
-            }
-            else if(theType=="time")
-            {
-                if(!isTime(dt.value))
-                {
-                    dt.className="invalid_value";
+                if (! isDate(dt_value)) {
+                    $this_input.addClass("invalid_value");
                     return false;
                 }
-            }
-            else if(theType=="datetime"||theType=="timestamp")
-            {
+            } else if(theType=="time") {
+                if (! isTime(dt_value)) {
+                    $this_input.addClass("invalid_value");
+                    return false;
+                }
+            } else if(theType=="datetime"||theType=="timestamp") {
                 tmstmp=false;
-                if(dt.value=="CURRENT_TIMESTAMP")
-                {
-                    dt.className="";
+                if(dt_value == "CURRENT_TIMESTAMP") {
                     return true;
                 }
-                if(theType=="timestamp")
-                {
+                if(theType=="timestamp") {
                     tmstmp=true;
                 }
-                if(dt.value=="0000-00-00 00:00:00")
+                if(dt_value=="0000-00-00 00:00:00") {
                     return true;
-                var dv=dt.value.indexOf(" ");
-                if(dv==-1)
-                {
-                    dt.className="invalid_value";
-                    return false;
                 }
-                else
-                {
-                    if(!(isDate(dt.value.substring(0,dv),tmstmp)&&isTime(dt.value.substring(dv+1))))
-                    {
-                        dt.className="invalid_value";
+                var dv=dt_value.indexOf(" ");
+                if(dv==-1) {
+                    $this_input.addClass("invalid_value");
+                    return false;
+                } else {
+                    if (! (isDate(dt_value.substring(0,dv),tmstmp) && isTime(dt_value.substring(dv+1)))) {
+                        $this_input.addClass("invalid_value");
                         return false;
                     }
                 }
diff --git a/tbl_change.php b/tbl_change.php
index 3256966..4ba5144 100644
--- a/tbl_change.php
+++ b/tbl_change.php
@@ -988,6 +988,10 @@ $(function() {
         <?php echo ($field['pma_type'] == 'date' ? "showTime: false,":"showTime: true,"); ?>
         dateFormat: 'yy-mm-dd', // yy means year with four digits
         altTimeField: '',
+        beforeShow: function(input, inst) {
+            // Remember that we came from the datepicker
+            $(input).data('comes_from', 'datepicker');
+        },
         constrainInput: false
      });
 });


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list