[Rt-commit] rt branch, 4.0/alert-invalid-file-inputs, updated. rt-4.0.0rc4-65-g2a88425

? sunnavy sunnavy at bestpractical.com
Wed Mar 16 01:24:02 EDT 2011


The branch, 4.0/alert-invalid-file-inputs has been updated
       via  2a8842566c348010768dc490c21f4217d75846ee (commit)
      from  05ff817d118c92f25c33713e60cbd7e27617a809 (commit)

Summary of changes:
 share/html/NoAuth/css/base/forms.css |    6 ++++++
 share/html/NoAuth/js/util.js         |   27 ++++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 3 deletions(-)

- Log -----------------------------------------------------------------
commit 2a8842566c348010768dc490c21f4217d75846ee
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Mar 16 13:19:33 2011 +0800

    alert() is jarring

diff --git a/share/html/NoAuth/css/base/forms.css b/share/html/NoAuth/css/base/forms.css
index 9c6c2a5..854b7e9 100755
--- a/share/html/NoAuth/css/base/forms.css
+++ b/share/html/NoAuth/css/base/forms.css
@@ -263,6 +263,12 @@ form div.submit div.buttons div.next {
     width: 50%;
 }
 
+div.invalid {
+    font-style: italic;
+    color: red;
+    display: inline;
+}
+
 /* query builder */
 
 #formatbuttons {
diff --git a/share/html/NoAuth/js/util.js b/share/html/NoAuth/js/util.js
index 9c3d9bd..da3b251 100644
--- a/share/html/NoAuth/js/util.js
+++ b/share/html/NoAuth/js/util.js
@@ -349,14 +349,35 @@ function escapeCssSelector(str) {
 function checkFileInput ( element ) {
     var val = jQuery(element).val();
     if ( val && val.match( /"/ ) ) {
-        alert("filename contains double quote(\"), which is not supported");
-        jQuery(element).val('');
+        return false;
+    }
+    else {
+        return true;
     }
 }
 
 jQuery( function() {
     jQuery("input[type=file]").change( function() {
-            checkFileInput(this);
+            var invalid_div = jQuery(this).next().hasClass('invalid') ?
+jQuery(this).next() : false;
+
+            if ( checkFileInput(this) ) {
+                if ( invalid_div ) {
+                    invalid_div.hide();
+                }
+            }
+            else {
+                if ( invalid_div  ) {
+                    invalid_div.show();
+                }
+                else {
+                    jQuery(this).after(
+                        '<div class="invalid">filename can not contain double quotes</div>'
+                    );
+                    jQuery(this).val('');
+
+                }
+            }
         } );
     }
 );

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


More information about the Rt-commit mailing list