mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
mlanthaler: Bugfix: Variable declaration hided parameter.
(merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@42143 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
d768f72b88
commit
576cc94a81
@ -20,13 +20,14 @@ function hasHadFormError() {
|
||||
/**
|
||||
* Returns group with the correct classname
|
||||
*/
|
||||
function findIndexOf(group,index){
|
||||
var i, group;
|
||||
for( i=0 ; i < group.length ; i++ ) {
|
||||
if(group[i].className.indexOf(index) > -1){
|
||||
function findIndexOf(group,index) {
|
||||
var i;
|
||||
for(i = 0; i < group.length; i++) {
|
||||
if(group[i].className.indexOf(index) > -1) {
|
||||
return group[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function clearErrorMessage(holderDiv){
|
||||
@ -43,7 +44,7 @@ function clearErrorMessage(holderDiv){
|
||||
}
|
||||
}
|
||||
|
||||
function clearAllErrorMessages(){
|
||||
function clearAllErrorMessages() {
|
||||
$$('span.message').each(function(el) {
|
||||
Element.hide(el);
|
||||
});
|
||||
@ -53,23 +54,23 @@ function require(fieldName,cachedError) {
|
||||
el = _CURRENT_FORM.elements[fieldName];
|
||||
|
||||
// see if the field is an optionset
|
||||
if( el == null ) {
|
||||
if(el == null) {
|
||||
|
||||
var descendants = _CURRENT_FORM.getElementsByTagName('*');
|
||||
|
||||
el = $(fieldName);
|
||||
|
||||
if( el == null )
|
||||
if(el == null)
|
||||
return true;
|
||||
|
||||
if( Element.hasClassName( el, 'optionset' ) ) {
|
||||
if(Element.hasClassName(el, 'optionset')) {
|
||||
el.type = 'optionset';
|
||||
|
||||
var options = el.getElementsByTagName('input');
|
||||
|
||||
for( var i = 0; i < options.length; i++ ) {
|
||||
if( options[i].checked )
|
||||
if( el.value != null )
|
||||
for(var i = 0; i < options.length; i++) {
|
||||
if(options[i].checked)
|
||||
if(el.value != null)
|
||||
el.value += ',' + options[i].value;
|
||||
else
|
||||
el.value = options[i].value;
|
||||
@ -79,9 +80,9 @@ function require(fieldName,cachedError) {
|
||||
}
|
||||
|
||||
|
||||
if(el != null){
|
||||
if(el != null) {
|
||||
// Sets up radio and checkbox validation
|
||||
if(el.type == 'checkbox' || el.type == 'radio' ){
|
||||
if(el.type == 'checkbox' || el.type == 'radio') {
|
||||
var set = el.checked;
|
||||
}//merged by nlou 23/08/2007, r#40674
|
||||
else if(el.type == 'select-one'){
|
||||
@ -100,16 +101,16 @@ function require(fieldName,cachedError) {
|
||||
|
||||
// Sometimes require events are triggered of
|
||||
// associative elements like labels ;-p
|
||||
if(el.type){
|
||||
if( el.parentNode.className.indexOf('form') != -1) set = true;
|
||||
if(el.type) {
|
||||
if(el.parentNode.className.indexOf('form') != -1) set = true;
|
||||
baseEl = el;
|
||||
|
||||
} else {
|
||||
if(_CURRENT_FORM.elements[fieldName]) {
|
||||
//Some elements are nested and need to be "got"
|
||||
var i, hasValue = false;
|
||||
if(_CURRENT_FORM.elements[fieldName].length > 1){
|
||||
for( i=0 ; i < el.length ; i++ ) {
|
||||
if(_CURRENT_FORM.elements[fieldName].length > 1) {
|
||||
for(i=0; i < el.length; i++) {
|
||||
if(el[i].checked && el[i].value) {
|
||||
hasValue = true;
|
||||
break;
|
||||
@ -131,13 +132,13 @@ function require(fieldName,cachedError) {
|
||||
}
|
||||
|
||||
// This checks to see if the input has a value, and the field is not a readonly.
|
||||
if( ( typeof set == 'undefined' || set == "" ) ) {
|
||||
if((typeof set == 'undefined' || set == "")) {
|
||||
//fieldgroup validation
|
||||
var fieldLabel = findParentLabel(baseEl);
|
||||
|
||||
// Some fields do-not have labels, in
|
||||
// which case we need a blank one
|
||||
if(fieldLabel == null || fieldLabel == ""){
|
||||
if(fieldLabel == null || fieldLabel == "") {
|
||||
fieldlabel = "this field";
|
||||
}
|
||||
|
||||
@ -148,8 +149,8 @@ function require(fieldName,cachedError) {
|
||||
validationError(baseEl, errorMessage.replace('$FieldLabel', fieldLabel),"required",cachedError);
|
||||
return false;
|
||||
|
||||
}else{
|
||||
if(!hasHadFormError()){
|
||||
} else {
|
||||
if(!hasHadFormError()) {
|
||||
clearErrorMessage(baseEl.parentNode);
|
||||
}
|
||||
return true;
|
||||
@ -162,24 +163,24 @@ function require(fieldName,cachedError) {
|
||||
/**
|
||||
* Returns the label of the blockset which contains the classname left
|
||||
*/
|
||||
function findParentLabel(el){
|
||||
function findParentLabel(el) {
|
||||
// If the el's type is HTML then were at the uppermost parent, so return
|
||||
// null. its handled by the validator function anyway :-)
|
||||
if(el){
|
||||
if(el.className == "undefined"){
|
||||
if(el) {
|
||||
if(el.className == "undefined") {
|
||||
return null;
|
||||
}else{
|
||||
if(el.className){
|
||||
if(el.className.indexOf('field') == 0){
|
||||
} else {
|
||||
if(el.className) {
|
||||
if(el.className.indexOf('field') == 0) {
|
||||
labels = el.getElementsByTagName('label');
|
||||
if(labels){
|
||||
var left = findIndexOf(labels,'left');
|
||||
var right = findIndexOf(labels,'right');
|
||||
if(left){
|
||||
if(left) {
|
||||
return strip_tags(left.innerHTML);
|
||||
}else if(right){
|
||||
} else if(right) {
|
||||
return strip_tags(right.innerHTML);
|
||||
}else{
|
||||
} else {
|
||||
return findParentLabel(el.parentNode);
|
||||
}
|
||||
}
|
||||
@ -189,7 +190,7 @@ function findParentLabel(el){
|
||||
}else{
|
||||
return findParentLabel(el.parentNode);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
return findParentLabel(el.parentNode);
|
||||
}
|
||||
}
|
||||
@ -201,7 +202,7 @@ function findParentLabel(el){
|
||||
/**
|
||||
* Adds a validation error to an element
|
||||
*/
|
||||
function validationError(field,message, messageClass, cacheError){
|
||||
function validationError(field,message, messageClass, cacheError) {
|
||||
if(typeof(field) == 'string') {
|
||||
field = $(field);
|
||||
}
|
||||
@ -217,7 +218,7 @@ function validationError(field,message, messageClass, cacheError){
|
||||
|
||||
// The validation function should only be called if you've just left a field,
|
||||
// or the field is being validated on final submission
|
||||
if(_LIMIT_VALIDATION_ERRORS && _LIMIT_VALIDATION_ERRORS != field){
|
||||
if(_LIMIT_VALIDATION_ERRORS && _LIMIT_VALIDATION_ERRORS != field) {
|
||||
// clearErrorMessage(field.parentNode);
|
||||
return;
|
||||
}
|
||||
@ -228,7 +229,7 @@ function validationError(field,message, messageClass, cacheError){
|
||||
var validationMessage = field.validationMessage;
|
||||
|
||||
// Cycle through the elements to see if it has a span
|
||||
// ( for a validation or required messages )
|
||||
// (for a validation or required messages)
|
||||
if(!validationMessage) {
|
||||
|
||||
//Get the parent holder of the element
|
||||
@ -265,12 +266,12 @@ function clearValidationErrorLimit() {
|
||||
_LIMIT_VALIDATION_ERRORS = null;
|
||||
}
|
||||
|
||||
function clearValidationErrorCache(){
|
||||
function clearValidationErrorCache() {
|
||||
_ERROR_CACHE = new Array();
|
||||
}
|
||||
|
||||
function showCachedValidationErrors(){
|
||||
for(i = 0; i < _ERROR_CACHE.length; i++){
|
||||
function showCachedValidationErrors() {
|
||||
for(i = 0; i < _ERROR_CACHE.length; i++) {
|
||||
validationError(_ERROR_CACHE[i]["field"],
|
||||
_ERROR_CACHE[i]["message"],
|
||||
_ERROR_CACHE[i]["messageClass"],
|
||||
|
Loading…
Reference in New Issue
Block a user