You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by jk...@apache.org on 2006/10/26 16:31:44 UTC
svn commit: r468017 - in /tapestry/tapestry4/trunk: ./
tapestry-framework/src/js/dojo/src/validate/check.js
tapestry-framework/src/js/tapestry/form/validation.js
tapestry-framework/src/js/tapestry/widget/AlertDialog.js
Author: jkuhnert
Date: Thu Oct 26 07:31:43 2006
New Revision: 468017
URL: http://svn.apache.org/viewvc?view=rev&rev=468017
Log:
Fixed alertdialog bad reference to focus function.
Temporarily fixed dojo.validate.check() function to work correctly in IE7.
Modified:
tapestry/tapestry4/trunk/ (props changed)
tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/validate/check.js
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form/validation.js
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/AlertDialog.js
Propchange: tapestry/tapestry4/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Oct 26 07:31:43 2006
@@ -1,17 +1,17 @@
-
-bin
-private
-dist
-.temp
-target
-maven.log
-velocity.log
-*.out
-build
-${destdir}
-ext-package
-cachedir
-.clover
-TestNG context suite.launch
-tapestry_org.apache.tapestry.*.xml
-temp-testng-customsuite.xml
+bin
+private
+dist
+.temp
+target
+maven.log
+velocity.log
+*.out
+build
+${destdir}
+ext-package
+cachedir
+.clover
+TestNG context suite.launch
+tapestry_org.apache.tapestry.*.xml
+temp-testng-customsuite.xml
+tmp
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/validate/check.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/validate/check.js?view=diff&rev=468017&r1=468016&r2=468017
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/validate/check.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/validate/check.js Thu Oct 26 07:31:43 2006
@@ -45,7 +45,7 @@
if(profile.trim instanceof Array){
for(var i = 0; i < profile.trim.length; i++){
var elem = form[profile.trim[i]];
-if(elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; }
+if(!dj_undef("type", elem) && elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; }
elem.value = elem.value.replace(/(^\s*|\s*$)/g, "");
}
}
@@ -53,7 +53,7 @@
if(profile.uppercase instanceof Array){
for(var i = 0; i < profile.uppercase.length; i++){
var elem = form[profile.uppercase[i]];
-if(elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; }
+if(!dj_undef("type", elem) && elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; }
elem.value = elem.value.toUpperCase();
}
}
@@ -61,7 +61,7 @@
if(profile.lowercase instanceof Array){
for (var i = 0; i < profile.lowercase.length; i++){
var elem = form[profile.lowercase[i]];
-if(elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; }
+if(!dj_undef("type", elem) && elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; }
elem.value = elem.value.toLowerCase();
}
}
@@ -69,7 +69,7 @@
if(profile.ucfirst instanceof Array){
for(var i = 0; i < profile.ucfirst.length; i++){
var elem = form[profile.ucfirst[i]];
-if(elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; }
+if(!dj_undef("type", elem) && elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; }
elem.value = elem.value.replace(/\b\w+\b/g, function(word) { return word.substring(0,1).toUpperCase() + word.substring(1).toLowerCase(); });
}
}
@@ -77,7 +77,7 @@
if(profile.digit instanceof Array){
for(var i = 0; i < profile.digit.length; i++){
var elem = form[profile.digit[i]];
-if(elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; }
+if(!dj_undef("type", elem) && elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; }
elem.value = elem.value.replace(/\D/g, "");
}
}
@@ -88,11 +88,11 @@
if(!dojo.lang.isString(profile.required[i])){ continue; }
var elem = form[profile.required[i]];
// Are textbox, textarea, or password fields blank.
-if((elem.type == "text" || elem.type == "textarea" || elem.type == "password") && /^\s*$/.test(elem.value)){
+if(!dj_undef("type", elem) && (elem.type == "text" || elem.type == "textarea" || elem.type == "password") && /^\s*$/.test(elem.value)){
missing[missing.length] = elem.name;
}
// Does drop-down box have option selected.
-else if((elem.type == "select-one" || elem.type == "select-multiple")
+else if(!dj_undef("type", elem) && (elem.type == "select-one" || elem.type == "select-multiple")
&& (elem.selectedIndex == -1
|| /^\s*$/.test(elem.options[elem.selectedIndex].value))){
missing[missing.length] = elem.name;
@@ -130,7 +130,7 @@
}
}
// case 2: elem is a select box
-else if(elem.type == "select-multiple" ){
+else if(!dj_undef("type", elem) && elem.type == "select-multiple" ){
var selected = 0;
for(var j = 0; j < elem.options.length; j++){
if (elem.options[j].selected && !/^\s*$/.test(elem.options[j].value)) { selected++; }
@@ -155,11 +155,11 @@
// properties of dependencies object are the names of dependent fields to be checked
for(name in profile.dependencies){
var elem = form[name]; // the dependent element
-if(elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; } // limited support
+if(!dj_undef("type", elem) && elem.type != "text" && elem.type != "textarea" && elem.type != "password"){ continue; } // limited support
if(/\S+/.test(elem.value)){ continue; } // has a value already
if(results.isMissing(elem.name)){ continue; } // already listed as missing
var target = form[profile.dependencies[name]];
-if(target.type != "text" && target.type != "textarea" && target.type != "password"){ continue; } // limited support
+if(!dj_undef("type", target) && target.type != "text" && target.type != "textarea" && target.type != "password"){ continue; } // limited support
if(/^\s*$/.test(target.value)){ continue; } // skip if blank
missing[missing.length] = elem.name; // ok the dependent field is missing
}
@@ -170,7 +170,8 @@
// constraint properties are the names of fields to bevalidated
for(name in profile.constraints){
var elem = form[name];
-if( (elem.type != "text")&&
+if(dj_undef("type", elem)){continue;}
+if((elem.type != "text")&&
(elem.type != "textarea")&&
(elem.type != "password")){
continue;
@@ -208,7 +209,8 @@
for(name in profile.confirm){
var elem = form[name]; // the confirm element
var target = form[profile.confirm[name]];
-if ( (elem.type != "text" && elem.type != "textarea" && elem.type != "password")
+if(dj_undef("type",elem || dj_undef("type", target))){continue;}
+if ((elem.type != "text" && elem.type != "textarea" && elem.type != "password")
||(target.type != elem.type)
||(target.value == elem.value) // it's valid
||(results.isInvalid(elem.name))// already listed as invalid
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form/validation.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form/validation.js?view=diff&rev=468017&r1=468016&r2=468017
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form/validation.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form/validation.js Thu Oct 26 07:31:43 2006
@@ -43,9 +43,9 @@
* will ~not~ be submitted.
*/
validateForm:function(form, props){
- if (typeof form == "undefined") return false;
- if (typeof props == "undefined") return true; // form exists but no profile? just submit I guess..
- if (!props.validateForm) return true;
+ if (typeof form == "undefined") {return false;}
+ if (typeof props == "undefined") {return true;} // form exists but no profile? just submit I guess..
+ if (!props.validateForm) {return true;}
try {
this.clearValidationDecorations(form, props);
@@ -84,7 +84,7 @@
* form will be submitted.
*/
processResults:function(form, results, profile){
- if (results.isSuccessful()) return true;
+ if (results.isSuccessful()) { return true; }
var formValid=true;
if (results.hasMissing()) {
@@ -115,6 +115,7 @@
* @param profile The form validation profile.
*/
handleMissingField:function(field, profile){
+ field=dojo.byId(field);
if (dj_undef("type", field)) {return;}
dojo.html.removeClass(field, this.invalidClass);
@@ -130,6 +131,7 @@
* @param profile The form validation profile.
*/
handleInvalidField:function(field, profile){
+ field=dojo.byId(field);
if (dj_undef("type", field)) {return;}
dojo.html.removeClass(field, this.missingClass);
@@ -144,7 +146,7 @@
*/
clearValidationDecorations:function(form, props){
for (var i=0; i< form.elements.length; i++) {
- if (typeof form.elements[i].type == "undefined"
+ if (dj_undef("type", form.elements[i]) || typeof form.elements[i].type == "undefined"
|| form.elements[i].type == "submit"
|| form.elements[i].type == "hidden") { continue; }
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/AlertDialog.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/AlertDialog.js?view=diff&rev=468017&r1=468016&r2=468017
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/AlertDialog.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/AlertDialog.js Thu Oct 26 07:31:43 2006
@@ -94,7 +94,7 @@
dojo.dom.removeNode(this.okButton);
tapestry.widget.AlertDialog.prototype.destroy.call(this);
dojo.dom.removeNode(this.bg);
- tapestry.form.focusCurrentField();
+ tapestry.form._focusCurrentField();
}
},
"html"