' + html.stripScripts() + ' |
* var browser = Prado.Browser();
* alert(browser.ie); //should ouput true if IE, false otherwise
*
* @param ${parameter}
* @return ${return}
*/
Browser : function()
{
var info = { Version : "1.0" };
var is_major = parseInt( navigator.appVersion );
info.nver = is_major;
info.ver = navigator.appVersion;
info.agent = navigator.userAgent;
info.dom = document.getElementById ? 1 : 0;
info.opera = window.opera ? 1 : 0;
info.ie5 = ( info.ver.indexOf( "MSIE 5" ) > -1 && info.dom && !info.opera ) ? 1 : 0;
info.ie6 = ( info.ver.indexOf( "MSIE 6" ) > -1 && info.dom && !info.opera ) ? 1 : 0;
info.ie4 = ( document.all && !info.dom && !info.opera ) ? 1 : 0;
info.ie = info.ie4 || info.ie5 || info.ie6;
info.mac = info.agent.indexOf( "Mac" ) > -1;
info.ns6 = ( info.dom && parseInt( info.ver ) >= 5 ) ? 1 : 0;
info.ie3 = ( info.ver.indexOf( "MSIE" ) && ( is_major < 4 ) );
info.hotjava = ( info.agent.toLowerCase().indexOf( 'hotjava' ) != -1 ) ? 1 : 0;
info.ns4 = ( document.layers && !info.dom && !info.hotjava ) ? 1 : 0;
info.bw = ( info.ie6 || info.ie5 || info.ie4 || info.ns4 || info.ns6 || info.opera );
info.ver3 = ( info.hotjava || info.ie3 );
info.opera7 = ( ( info.agent.toLowerCase().indexOf( 'opera 7' ) > -1 ) || ( info.agent.toLowerCase().indexOf( 'opera/7' ) > -1 ) );
info.operaOld = info.opera && !info.opera7;
return info;
},
ImportCss : function(doc, css_file)
{
if (Prado.Browser().ie)
var styleSheet = doc.createStyleSheet(css_file);
else
{
var elm = doc.createElement("link");
elm.rel = "stylesheet";
elm.href = css_file;
if (headArr = doc.getElementsByTagName("head"))
headArr[0].appendChild(elm);
}
}
};
/**
* Similar to bindAsEventLister, but takes additional arguments.
*/
Function.prototype.bindEvent = function()
{
var __method = this, args = $A(arguments), object = args.shift();
return function(event)
{
return __method.apply(object, [event || window.event].concat(args));
}
};
/**
* Creates a new function by copying function definition from
* the
base
and optional
definition
.
* @param function a base function to copy from.
* @param array additional definition
* @param function return a new function with definition from both
*
base
and
definition
.
*/
Class.extend = function(base, definition)
{
var component = Class.create();
Object.extend(component.prototype, base.prototype);
if(definition)
Object.extend(component.prototype, definition);
return component;
};
/*
Base, version 1.0.2
Copyright 2006, Dean Edwards
License: http://creativecommons.org/licenses/LGPL/2.1/
*/
var Base = function() {
if (arguments.length) {
if (this == window) { // cast an object to this class
Base.prototype.extend.call(arguments[0], arguments.callee.prototype);
} else {
this.extend(arguments[0]);
}
}
};
Base.version = "1.0.2";
Base.prototype = {
extend: function(source, value) {
var extend = Base.prototype.extend;
if (arguments.length == 2) {
var ancestor = this[source];
// overriding?
if ((ancestor instanceof Function) && (value instanceof Function) &&
ancestor.valueOf() != value.valueOf() && /\bbase\b/.test(value)) {
var method = value;
// var _prototype = this.constructor.prototype;
// var fromPrototype = !Base._prototyping && _prototype[source] == ancestor;
value = function() {
var previous = this.base;
// this.base = fromPrototype ? _prototype[source] : ancestor;
this.base = ancestor;
var returnValue = method.apply(this, arguments);
this.base = previous;
return returnValue;
};
// point to the underlying method
value.valueOf = function() {
return method;
};
value.toString = function() {
return String(method);
};
}
return this[source] = value;
} else if (source) {
var _prototype = {toSource: null};
// do the "toString" and other methods manually
var _protected = ["toString", "valueOf"];
// if we are prototyping then include the constructor
if (Base._prototyping) _protected[2] = "constructor";
for (var i = 0; (name = _protected[i]); i++) {
if (source[name] != _prototype[name]) {
extend.call(this, name, source[name]);
}
}
// copy each of the source object's properties to this object
for (var name in source) {
if (!_prototype[name]) {
extend.call(this, name, source[name]);
}
}
}
return this;
},
base: function() {
// call this method from any other method to invoke that method's ancestor
}
};
Base.extend = function(_instance, _static) {
var extend = Base.prototype.extend;
if (!_instance) _instance = {};
// build the prototype
Base._prototyping = true;
var _prototype = new this;
extend.call(_prototype, _instance);
var constructor = _prototype.constructor;
_prototype.constructor = this;
delete Base._prototyping;
// create the wrapper for the constructor function
var klass = function() {
if (!Base._prototyping) constructor.apply(this, arguments);
this.constructor = klass;
};
klass.prototype = _prototype;
// build the class interface
klass.extend = this.extend;
klass.implement = this.implement;
klass.toString = function() {
return String(constructor);
};
extend.call(klass, _static);
// single instance
var object = constructor ? klass : _prototype;
// class initialisation
if (object.init instanceof Function) object.init();
return object;
};
Base.implement = function(_interface) {
if (_interface instanceof Function) _interface = _interface.prototype;
this.prototype.extend(_interface);
};
/**
* Performs a post-back using javascript
*
*/
Prado.PostBack = function(event,options)
{
var form = $(options['FormID']);
var canSubmit = true;
if(options['CausesValidation'] && typeof(Prado.Validation) != "undefined")
{
if(!Prado.Validation.validate(options['FormID'], options['ValidationGroup'], $(options['ID'])))
return Event.stop(event);
}
if(options['PostBackUrl'] && options['PostBackUrl'].length > 0)
form.action = options['PostBackUrl'];
if(options['TrackFocus'])
{
var lastFocus = $('PRADO_LASTFOCUS');
if(lastFocus)
{
var active = document.activeElement; //where did this come from
if(active)
lastFocus.value = active.id;
else
lastFocus.value = options['EventTarget'];
}
}
$('PRADO_POSTBACK_TARGET').value = options['EventTarget'];
$('PRADO_POSTBACK_PARAMETER').value = options['EventParameter'];
/**
* Since google toolbar prevents browser default action,
* we will always disable default client-side browser action
*/
/*if(options['StopEvent']) */
Event.stop(event);
Event.fireEvent(form,"submit");
};
Prado.Element =
{
/**
* Set the value of a particular element.
* @param string element id
* @param string new element value.
*/
setValue : function(element, value)
{
var el = $(element);
if(el && typeof(el.value) != "undefined")
el.value = value;
},
select : function(element, method, value, total)
{
var el = $(element);
if(!el) return;
var selection = Prado.Element.Selection;
if(typeof(selection[method]) == "function")
{
control = selection.isSelectable(el) ? [el] : selection.getListElements(element,total);
selection[method](control, value);
}
},
click : function(element)
{
var el = $(element);
if(el)
Event.fireEvent(el,'click');
},
isDisabled : function(element)
{
if(!element.attributes['disabled']) //FF
return false;
var value = element.attributes['disabled'].nodeValue;
if(typeof(value)=="string")
return value.toLowerCase() == "disabled";
else
return value == true;
},
setAttribute : function(element, attribute, value)
{
var el = $(element);
if(!el) return;
if((attribute == "disabled" || attribute == "multiple") && value==false)
el.removeAttribute(attribute);
else if(attribute.match(/^on/i)) //event methods
{
try
{
eval("(func = function(event){"+value+"})");
el[attribute] = func;
}
catch(e)
{
throw "Error in evaluating '"+value+"' for attribute "+attribute+" for element "+element.id;
}
}
else
el.setAttribute(attribute, value);
},
setOptions : function(element, options)
{
var el = $(element);
if(!el) return;
var previousGroup = null;
var optGroup=null;
if(el && el.tagName.toLowerCase() == "select")
{
while(el.childNodes.length > 0)
el.removeChild(el.lastChild);
var optDom = Prado.Element.createOptions(options);
for(var i = 0; i < optDom.length; i++)
el.appendChild(optDom[i]);
}
},
/**
* Create opt-group options from an array of options[0]=text, options[1]=value, options[2]=group
*/
createOptions : function(options)
{
var previousGroup = null;
var optgroup=null;
var result = [];
for(var i = 0; i
* Event.OnLoad(function(){ alert("Page Loaded!"); });
*
*
* @param {Function} function to execute when page is loaded.
*/
OnLoad : function (fn)
{
// opera onload is in document, not window
var w = document.addEventListener &&
!window.addEventListener ? document : window;
Event.observe(w,'load',fn);
},
/**
* @param {Event} a keyboard event
* @return {Number} the Unicode character code generated by the key
* that was struck.
*/
keyCode : function(e)
{
return e.keyCode != null ? e.keyCode : e.charCode
},
/**
* @param {String} event type or event name.
* @return {Boolean} true if event type is of HTMLEvent, false
* otherwise
*/
isHTMLEvent : function(type)
{
var events = ['abort', 'blur', 'change', 'error', 'focus',
'load', 'reset', 'resize', 'scroll', 'select',
'submit', 'unload'];
return events.include(type);
},
/**
* @param {String} event type or event name
* @return {Boolean} true if event type is of MouseEvent,
* false otherwise
*/
isMouseEvent : function(type)
{
var events = ['click', 'mousedown', 'mousemove', 'mouseout',
'mouseover', 'mouseup'];
return events.include(type);
},
/**
* Dispatch the DOM event of a given
type
on a DOM
*
element
. Only HTMLEvent and MouseEvent can be
* dispatched, keyboard events or UIEvent can not be dispatch
* via javascript consistently.
* For the "submit" event the submit() method is called.
* @param {Object} element id string or a DOM element.
* @param {String} event type to dispatch.
*/
fireEvent : function(element,type)
{
element = $(element);
if(type == "submit")
return element.submit();
if(document.createEvent)
{
if(Event.isHTMLEvent(type))
{
var event = document.createEvent('HTMLEvents');
event.initEvent(type, true, true);
}
else if(Event.isMouseEvent(type))
{
var event = document.createEvent('MouseEvents');
if (event.initMouseEvent)
{
event.initMouseEvent(type,true,true,
document.defaultView, 1, 0, 0, 0, 0, false,
false, false, false, 0, null);
}
else
{
// Safari
// TODO we should be initialising other mouse-event related attributes here
event.initEvent(type, true, true);
}
}
element.dispatchEvent(event);
}
else if(document.createEventObject)
{
var evObj = document.createEventObject();
element.fireEvent('on'+type, evObj);
}
else if(typeof(element['on'+type]) == "function")
element['on'+type]();
}
});
Object.extend(Date.prototype,
{
SimpleFormat: function(format, data)
{
data = data || {};
var bits = new Array();
bits['d'] = this.getDate();
bits['dd'] = String(this.getDate()).zerofill(2);
bits['M'] = this.getMonth()+1;
bits['MM'] = String(this.getMonth()+1).zerofill(2);
if(data.AbbreviatedMonthNames)
bits['MMM'] = data.AbbreviatedMonthNames[this.getMonth()];
if(data.MonthNames)
bits['MMMM'] = data.MonthNames[this.getMonth()];
var yearStr = "" + this.getFullYear();
yearStr = (yearStr.length == 2) ? '19' + yearStr: yearStr;
bits['yyyy'] = yearStr;
bits['yy'] = bits['yyyy'].toString().substr(2,2);
// do some funky regexs to replace the format string
// with the real values
var frm = new String(format);
for (var sect in bits)
{
var reg = new RegExp("\\b"+sect+"\\b" ,"g");
frm = frm.replace(reg, bits[sect]);
}
return frm;
},
toISODate : function()
{
var y = this.getFullYear();
var m = String(this.getMonth() + 1).zerofill(2);
var d = String(this.getDate()).zerofill(2);
return String(y) + String(m) + String(d);
}
});
Object.extend(Date,
{
SimpleParse: function(value, format)
{
val=String(value);
format=String(format);
if(val.length <= 0) return null;
if(format.length <= 0) return new Date(value);
var isInteger = function (val)
{
var digits="1234567890";
for (var i=0; i < val.length; i++)
{
if (digits.indexOf(val.charAt(i))==-1) { return false; }
}
return true;
};
var getInt = function(str,i,minlength,maxlength)
{
for (var x=maxlength; x>=minlength; x--)
{
var token=str.substring(i,i+x);
if (token.length < minlength) { return null; }
if (isInteger(token)) { return token; }
}
return null;
};
var i_val=0;
var i_format=0;
var c="";
var token="";
var token2="";
var x,y;
var now=new Date();
var year=now.getFullYear();
var month=now.getMonth()+1;
var date=1;
while (i_format < format.length)
{
// Get next token from format string
c=format.charAt(i_format);
token="";
while ((format.charAt(i_format)==c) && (i_format < format.length))
{
token += format.charAt(i_format++);
}
// Extract contents of value based on format token
if (token=="yyyy" || token=="yy" || token=="y")
{
if (token=="yyyy") { x=4;y=4; }
if (token=="yy") { x=2;y=2; }
if (token=="y") { x=2;y=4; }
year=getInt(val,i_val,x,y);
if (year==null) { return null; }
i_val += year.length;
if (year.length==2)
{
if (year > 70) { year=1900+(year-0); }
else { year=2000+(year-0); }
}
}
else if (token=="MM"||token=="M")
{
month=getInt(val,i_val,token.length,2);
if(month==null||(month<1)||(month>12)){return null;}
i_val+=month.length;
}
else if (token=="dd"||token=="d")
{
date=getInt(val,i_val,token.length,2);
if(date==null||(date<1)||(date>31)){return null;}
i_val+=date.length;
}
else
{
if (val.substring(i_val,i_val+token.length)!=token) {return null;}
else {i_val+=token.length;}
}
}
// If there are any trailing characters left in the value, it doesn't match
if (i_val != val.length) { return null; }
// Is date valid for month?
if (month==2)
{
// Check for leap year
if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
if (date > 29){ return null; }
}
else { if (date > 28) { return null; } }
}
if ((month==4)||(month==6)||(month==9)||(month==11))
{
if (date > 30) { return null; }
}
var newdate=new Date(year,month-1,date, 0, 0, 0);
return newdate;
}
});
Prado.WebUI = Class.create();
Prado.WebUI.PostBackControl = Class.create();
Prado.WebUI.PostBackControl.prototype =
{
initialize : function(options)
{
this._elementOnClick = null, //capture the element's onclick function
this.element = $(options.ID);
if(this.element)
{
if(this.onInit)
this.onInit(options);
}
},
onInit : function(options)
{
if(typeof(this.element.onclick)=="function")
{
this._elementOnClick = this.element.onclick.bind(this.element);
this.element.onclick = null;
}
Event.observe(this.element, "click", this.elementClicked.bindEvent(this,options));
},
elementClicked : function(event, options)
{
var src = Event.element(event);
var doPostBack = true;
var onclicked = null;
if(this._elementOnClick)
{
var onclicked = this._elementOnClick(event);
if(typeof(onclicked) == "boolean")
doPostBack = onclicked;
}
if(doPostBack && !Prado.Element.isDisabled(src))
this.onPostBack(event,options);
if(typeof(onclicked) == "boolean" && !onclicked)
Event.stop(event);
},
onPostBack : function(event, options)
{
Prado.PostBack(event,options);
}
};
Prado.WebUI.TButton = Class.extend(Prado.WebUI.PostBackControl);
Prado.WebUI.TLinkButton = Class.extend(Prado.WebUI.PostBackControl);
Prado.WebUI.TCheckBox = Class.extend(Prado.WebUI.PostBackControl);
Prado.WebUI.TBulletedList = Class.extend(Prado.WebUI.PostBackControl);
Prado.WebUI.TImageMap = Class.extend(Prado.WebUI.PostBackControl);
/**
* TImageButton client-side behaviour. With validation, Firefox needs
* to capture the x,y point of the clicked image in hidden form fields.
*/
Prado.WebUI.TImageButton = Class.extend(Prado.WebUI.PostBackControl);
Object.extend(Prado.WebUI.TImageButton.prototype,
{
/**
* Override parent onPostBack function, tried to add hidden forms
* inputs to capture x,y clicked point.
*/
onPostBack : function(event, options)
{
if(!this.hasXYInput)
{
this.addXYInput(event,options);
this.hasXYInput = true;
}
Prado.PostBack(event, options);
},
/**
* Add hidden inputs to capture the x,y point clicked on the image.
* @param event DOM click event.
* @param array image button options.
*/
addXYInput : function(event,options)
{
imagePos = Position.cumulativeOffset(this.element);
clickedPos = [event.clientX, event.clientY];
x = clickedPos[0]-imagePos[0]+1;
y = clickedPos[1]-imagePos[1]+1;
x = x < 0 ? 0 : x;
y = y < 0 ? 0 : y;
id = options['EventTarget'];
x_input = $(id+"_x");
y_input = $(id+"_y");
if(x_input)
{
x_input.value = x;
}
else
{
x_input = INPUT({type:'hidden',name:id+'_x','id':id+'_x',value:x});
this.element.parentNode.appendChild(x_input);
}
if(y_input)
{
y_input.value = y;
}
else
{
y_input = INPUT({type:'hidden',name:id+'_y','id':id+'_y',value:y});
this.element.parentNode.appendChild(y_input);
}
}
});
/**
* Radio button, only initialize if not already checked.
*/
Prado.WebUI.TRadioButton = Class.extend(Prado.WebUI.PostBackControl);
Prado.WebUI.TRadioButton.prototype.onRadioButtonInitialize = Prado.WebUI.TRadioButton.prototype.initialize;
Object.extend(Prado.WebUI.TRadioButton.prototype,
{
initialize : function(options)
{
this.element = $(options['ID']);
if(this.element)
{
if(!this.element.checked)
this.onRadioButtonInitialize(options);
}
}
});
Prado.WebUI.TTextBox = Class.extend(Prado.WebUI.PostBackControl,
{
onInit : function(options)
{
this.options=options;
if(options['TextMode'] != 'MultiLine')
Event.observe(this.element, "keydown", this.handleReturnKey.bind(this));
if(this.options['AutoPostBack']==true)
Event.observe(this.element, "change", Prado.PostBack.bindEvent(this,options));
},
handleReturnKey : function(e)
{
if(Event.keyCode(e) == Event.KEY_RETURN)
{
var target = Event.element(e);
if(target)
{
if(this.options['AutoPostBack']==true)
{
Event.fireEvent(target, "change");
Event.stop(e);
}
else
{
if(this.options['CausesValidation'] && typeof(Prado.Validation) != "undefined")
{
if(!Prado.Validation.validate(this.options['FormID'], this.options['ValidationGroup'], $(this.options['ID'])))
return Event.stop(e);
}
}
}
}
}
});
Prado.WebUI.TListControl = Class.extend(Prado.WebUI.PostBackControl,
{
onInit : function(options)
{
Event.observe(this.element, "change", Prado.PostBack.bindEvent(this,options));
}
});
Prado.WebUI.TListBox = Class.extend(Prado.WebUI.TListControl);
Prado.WebUI.TDropDownList = Class.extend(Prado.WebUI.TListControl);
Prado.WebUI.DefaultButton = Class.create();
Prado.WebUI.DefaultButton.prototype =
{
initialize : function(options)
{
this.options = options;
this._event = this.triggerEvent.bindEvent(this);
Event.observe(options['Panel'], 'keydown', this._event);
},
triggerEvent : function(ev, target)
{
var enterPressed = Event.keyCode(ev) == Event.KEY_RETURN;
var isTextArea = Event.element(ev).tagName.toLowerCase() == "textarea";
if(enterPressed && !isTextArea)
{
var defaultButton = $(this.options['Target']);
if(defaultButton)
{
this.triggered = true;
$('PRADO_POSTBACK_TARGET').value = this.options.EventTarget;
Event.fireEvent(defaultButton, this.options['Event']);
Event.stop(ev);
}
}
}
};
Prado.WebUI.TTextHighlighter=Class.create();
Prado.WebUI.TTextHighlighter.prototype=
{
initialize:function(id)
{
if(!window.clipboardData) return;
var options =
{
href : 'javascript:;/'+'/copy code to clipboard',
onclick : 'Prado.WebUI.TTextHighlighter.copy(this)',
onmouseover : 'Prado.WebUI.TTextHighlighter.hover(this)',
onmouseout : 'Prado.WebUI.TTextHighlighter.out(this)'
}
var div = DIV({className:'copycode'}, A(options, 'Copy Code'));
document.write(DIV(null,div).innerHTML);
}
};
Object.extend(Prado.WebUI.TTextHighlighter,
{
copy : function(obj)
{
var parent = obj.parentNode.parentNode.parentNode;
var text = '';
for(var i = 0; i < parent.childNodes.length; i++)
{
var node = parent.childNodes[i];
if(node.innerText)
text += node.innerText == 'Copy Code' ? '' : node.innerText;
else
text += node.nodeValue;
}
if(text.length > 0)
window.clipboardData.setData("Text", text);
},
hover : function(obj)
{
obj.parentNode.className = "copycode copycode_hover";
},
out : function(obj)
{
obj.parentNode.className = "copycode";
}
});
Prado.WebUI.TCheckBoxList = Base.extend(
{
constructor : function(options)
{
for(var i = 0; i
*
*
*
*
*/
Prado.Validation = Class.create();
/**
* A global validation manager.
* To validate the inputs of a particular form, call
*
Prado.Validation.validate(formID, groupID)
* where
formID
is the HTML form ID, and the optional
*
groupID
if present will only validate the validators
* in a particular group.
*/
Object.extend(Prado.Validation,
{
managers : {},
/**
* Validate the validators (those that
DO NOT
* belong to a particular group) the form specified by the
*
formID
parameter. If
groupID
is specified
* then only validators belonging to that group will be validated.
* @param string ID of the form to validate
* @param string ID of the group to validate.
* @param HTMLElement element that calls for validation
*/
validate : function(formID, groupID, invoker)
{
formID = formID || this.getForm();
if(this.managers[formID])
{
return this.managers[formID].validate(groupID, invoker);
}
else
{
throw new Error("Form '"+form+"' is not registered with Prado.Validation");
}
},
/**
* @return string first form ID.
*/
getForm : function()
{
var keys = $H(this.managers).keys();
return keys[0];
},
/**
* Check if the validators are valid for a particular form (and group).
* The validators states will not be changed.
* The
validate
function should be called first.
* @param string ID of the form to validate
* @param string ID of the group to validate.
*/
isValid : function(formID, groupID)
{
formID = formID || this.getForm();
if(this.managers[formID])
return this.managers[formID].isValid(groupID);
return true;
},
/**
* Reset the validators for a given group.
*/
reset : function(groupID)
{
var formID = this.getForm();
if(this.managers[formID])
this.managers[formID].reset(groupID);
},
/**
* Add a new validator to a particular form.
* @param string the form that the validator belongs.
* @param object a validator
* @return object the manager
*/
addValidator : function(formID, validator)
{
if(this.managers[formID])
this.managers[formID].addValidator(validator);
else
throw new Error("A validation manager for form '"+formID+"' needs to be created first.");
return this.managers[formID];
},
/**
* Add a new validation summary.
* @param string the form that the validation summary belongs.
* @param object a validation summary
* @return object manager
*/
addSummary : function(formID, validator)
{
if(this.managers[formID])
this.managers[formID].addSummary(validator);
else
throw new Error("A validation manager for form '"+formID+"' needs to be created first.");
return this.managers[formID];
},
setErrorMessage : function(validatorID, message)
{
$H(Prado.Validation.managers).each(function(manager)
{
manager[1].validators.each(function(validator)
{
if(validator.options.ID == validatorID)
{
validator.options.ErrorMessage = message;
$(validatorID).innerHTML = message;
}
});
});
}
});
Prado.ValidationManager = Class.create();
/**
* Validation manager instances. Manages validators for a particular
* HTML form. The manager contains references to all the validators
* summaries, and their groupings for a particular form.
* Generally,
Prado.Validation
methods should be called rather
* than calling directly the ValidationManager.
*/
Prado.ValidationManager.prototype =
{
/**
*
* options['FormID']* The ID of HTML form to manage.
*
*/
initialize : function(options)
{
this.validators = []; // list of validators
this.summaries = []; // validation summaries
this.groups = []; // validation groups
this.options = {};
this.options = options;
if(!Prado.Validation.managers[options.FormID])
Prado.Validation.managers[options.FormID] = this;
},
/**
* Reset all validators in the given group (if group is null, validators without a group are used).
*/
reset : function(group)
{
this.validatorPartition(group)[0].invoke('reset');
this.updateSummary(group, true);
},
/**
* Validate the validators managed by this validation manager.
* @param string only validate validators belonging to a group (optional)
* @param HTMLElement element that calls for validation
* @return boolean true if all validators are valid, false otherwise.
*/
validate : function(group, source)
{
var partition = this.validatorPartition(group);
var valid = partition[0].invoke('validate', source).all();
this.focusOnError(partition[0]);
partition[1].invoke('hide');
this.updateSummary(group, true);
return valid;
},
/**
* Focus on the first validator that is invalid and options.FocusOnError is true.
*/
focusOnError : function(validators)
{
for(var i = 0; i < validators.length; i++)
{
if(!validators[i].isValid && validators[i].options.FocusOnError)
return Prado.Element.focus(validators[i].options.FocusElementID);
}
},
/**
* @return array[0] validators belong to a group if group is given, otherwise validators
* not belongining to any group. array[1] the opposite of array[0].
*/
validatorPartition : function(group)
{
return group ? this.validatorsInGroup(group) : this.validatorsWithoutGroup();
},
/**
* @return array validatiors in a given group in first array and
* validators not belonging to the group in 2nd array.
*/
validatorsInGroup : function(groupID)
{
if(this.groups.include(groupID))
{
return this.validators.partition(function(val)
{
return val.group == groupID;
});
}
else
return [[],[]];
},
/**
* @return array validators without any group in first array, and those
* with groups in 2nd array.
*/
validatorsWithoutGroup : function()
{
return this.validators.partition(function(val)
{
return !val.group;
});
},
/**
* Gets the state of all the validators, true if they are all valid.
* @return boolean true if the validators are valid.
*/
isValid : function(group)
{
return this.validatorPartition(group)[0].pluck('isValid').all();
},
/**
* Add a validator to this manager.
* @param Prado.WebUI.TBaseValidator a new validator
*/
addValidator : function(validator)
{
this.validators.push(validator);
if(validator.group && !this.groups.include(validator.group))
this.groups.push(validator.group);
},
/**
* Add a validation summary.
* @param Prado.WebUI.TValidationSummary validation summary.
*/
addSummary : function(summary)
{
this.summaries.push(summary);
},
/**
* Gets all validators that belong to a group or that the validator
* group is null and the validator validation was false.
* @return array list of validators with error.
*/
getValidatorsWithError : function(group)
{
return this.validatorPartition(group)[0].findAll(function(validator)
{
return !validator.isValid;
});
},
/**
* Update the summary of a particular group.
* @param string validation group to update.
*/
updateSummary : function(group, refresh)
{
var validators = this.getValidatorsWithError(group);
this.summaries.each(function(summary)
{
var inGroup = group && summary.group == group;
var noGroup = !group && !summary.group;
if(inGroup || noGroup)
summary.updateSummary(validators, refresh);
else
summary.hideSummary(true);
});
}
};
/**
* TValidationSummary displays a summary of validation errors inline on a Web page,
* in a message box, or both. By default, a validation summary will collect
*
ErrorMessage
of all failed validators on the page. If
*
ValidationGroup
is not empty, only those validators who belong
* to the group will show their error messages in the summary.
*
* The summary can be displayed as a list, as a bulleted list, or as a single
* paragraph based on the
DisplayMode
option.
* The messages shown can be prefixed with
HeaderText
.
*
* The summary can be displayed on the Web page and in a message box by setting
* the
ShowSummary
and
ShowMessageBox
* options, respectively.
*/
Prado.WebUI.TValidationSummary = Class.create();
Prado.WebUI.TValidationSummary.prototype =
{
/**
*
* options['ID']* Validation summary ID, i.e., an HTML element ID
* options['FormID']* HTML form that this summary belongs.
* options['ShowMessageBox'] True to show the summary in an alert box.
* options['ShowSummary'] True to show the inline summary.
* options['HeaderText'] Summary header text
* options['DisplayMode'] Summary display style, 'BulletList', 'List', 'SingleParagraph'
* options['Refresh'] True to update the summary upon validator state change.
* options['ValidationGroup'] Validation summary group
* options['Display'] Display mode, 'None', 'Fixed', 'Dynamic'.
* options['ScrollToSummary'] True to scroll to the validation summary upon refresh.
*
*/
initialize : function(options)
{
this.options = options;
this.group = options.ValidationGroup;
this.messages = $(options.ID);
if(this.messages)
{
this.visible = this.messages.style.visibility != "hidden"
this.visible = this.visible && this.messages.style.display != "none";
Prado.Validation.addSummary(options.FormID, this);
}
},
/**
* Update the validation summary to show the error message from
* validators that failed validation.
* @param array list of validators that failed validation.
* @param boolean update the summary;
*/
updateSummary : function(validators, update)
{
if(validators.length <= 0)
{
if(update || this.options.Refresh != false)
{
return this.hideSummary(validators);
}
return;
}
var refresh = update || this.visible == false || this.options.Refresh != false;
if(this.options.ShowSummary != false && refresh)
{
this.updateHTMLMessages(this.getMessages(validators));
this.showSummary(validators);
}
if(this.options.ScrollToSummary != false && refresh)
window.scrollTo(this.messages.offsetLeft-20, this.messages.offsetTop-20);
if(this.options.ShowMessageBox == true && refresh)
{
this.alertMessages(this.getMessages(validators));
this.visible = true;
}
},
/**
* Display the validator error messages as inline HTML.
*/
updateHTMLMessages : function(messages)
{
while(this.messages.childNodes.length > 0)
this.messages.removeChild(this.messages.lastChild);
new Insertion.Bottom(this.messages, this.formatSummary(messages));
},
/**
* Display the validator error messages as an alert box.
*/
alertMessages : function(messages)
{
var text = this.formatMessageBox(messages);
setTimeout(function(){ alert(text); },20);
},
/**
* @return array list of validator error messages.
*/
getMessages : function(validators)
{
var messages = [];
validators.each(function(validator)
{
var message = validator.getErrorMessage();
if(typeof(message) == 'string' && message.length > 0)
messages.push(message);
})
return messages;
},
/**
* Hides the validation summary.
*/
hideSummary : function(validators)
{ if(typeof(this.options.OnHideSummary) == "function")
{
this.messages.style.visibility="visible";
this.options.OnHideSummary(this,validators)
}
else
{
this.messages.style.visibility="hidden";
if(this.options.Display == "None" || this.options.Display == "Dynamic")
this.messages.hide();
}
this.visible = false;
},
/**
* Shows the validation summary.
*/
showSummary : function(validators)
{
this.messages.style.visibility="visible";
if(typeof(this.options.OnShowSummary) == "function")
this.options.OnShowSummary(this,validators);
else
this.messages.show();
this.visible = true;
},
/**
* Return the format parameters for the summary.
* @param string format type, "List", "SingleParagraph" or "BulletList"
* @type array formatting parameters
*/
formats : function(type)
{
switch(type)
{
case "List":
return { header : "
* options['ID']* Validator ID, e.g. span with message
* options['FormID']* HTML form that the validator belongs
* options['ControlToValidate']*HTML form input to validate
* options['Display'] Display mode, 'None', 'Fixed', 'Dynamic'
* options['ErrorMessage'] Validation error message
* options['FocusOnError'] True to focus on validation error
* options['FocusElementID'] Element to focus on error
* options['ValidationGroup'] Validation group
* options['ControlCssClass'] Css class to use on the input upon error
* options['OnValidate'] Function to call immediately after validation
* options['OnValidationSuccess'] Function to call upon after successful validation
* options['OnValidationError'] Function to call upon after error in validation.
* options['ObserveChanges'] True to observe changes in input
*
*/
initialize : function(options)
{
/* options.OnValidate = options.OnValidate || Prototype.emptyFunction;
options.OnSuccess = options.OnSuccess || Prototype.emptyFunction;
options.OnError = options.OnError || Prototype.emptyFunction;
*/
this.enabled = true;
this.visible = false;
this.isValid = true;
this._isObserving = {};
this.group = null;
this.requestDispatched = false;
this.options = options;
this.control = $(options.ControlToValidate);
this.message = $(options.ID);
if(this.control && this.message)
{
this.group = options.ValidationGroup;
this.manager = Prado.Validation.addValidator(options.FormID, this);
}
},
/**
* @return string validation error message.
*/
getErrorMessage : function()
{
return this.options.ErrorMessage;
},
/**
* Update the validator span, input CSS class, and focus particular
* element. Updating the validator control will set the validator
*
visible
property to true.
*/
updateControl: function(focus)
{
this.refreshControlAndMessage();
//if(this.options.FocusOnError && !this.isValid )
// Prado.Element.focus(this.options.FocusElementID);
this.visible = true;
},
refreshControlAndMessage : function()
{
this.visible = true;
if(this.message)
{
if(this.options.Display == "Dynamic")
this.isValid ? this.message.hide() : this.message.show();
this.message.style.visibility = this.isValid ? "hidden" : "visible";
}
if(this.control)
this.updateControlCssClass(this.control, this.isValid);
},
/**
* Add a css class to the input control if validator is invalid,
* removes the css class if valid.
* @param object html control element
* @param boolean true to remove the css class, false to add.
*/
updateControlCssClass : function(control, valid)
{
var CssClass = this.options.ControlCssClass;
if(typeof(CssClass) == "string" && CssClass.length > 0)
{
if(valid)
control.removeClassName(CssClass);
else
control.addClassName(CssClass);
}
},
/**
* Hides the validator messages and remove any validation changes.
*/
hide : function()
{
this.reset();
this.visible = false;
},
/**
* Sets isValid = true and updates the validator display.
*/
reset : function()
{
this.isValid = true;
this.updateControl();
},
/**
* Calls evaluateIsValid() function to set the value of isValid property.
* Triggers onValidate event and onSuccess or onError event.
* @param HTMLElement element that calls for validation
* @return boolean true if valid.
*/
validate : function(invoker)
{
//try to find the control.
if(!this.control)
this.control = $(this.options.ControlToValidate);
if(!this.control)
{
this.isValid = true;
return this.isValid;
}
if(typeof(this.options.OnValidate) == "function")
{
if(this.requestDispatched == false)
this.options.OnValidate(this, invoker);
}
if(this.enabled)
this.isValid = this.evaluateIsValid();
else
this.isValid = true;
this.updateValidationDisplay(invoker);
this.observeChanges(this.control);
return this.isValid;
},
/**
* Updates the validation messages, update the control to be validated.
*/
updateValidationDisplay : function(invoker)
{
if(this.isValid)
{
if(typeof(this.options.OnValidationSuccess) == "function")
{
if(this.requestDispatched == false)
{
this.refreshControlAndMessage();
this.options.OnValidationSuccess(this, invoker);
}
}
else
this.updateControl();
}
else
{
if(typeof(this.options.OnValidationError) == "function")
{
if(this.requestDispatched == false)
{
this.refreshControlAndMessage();
this.options.OnValidationError(this, invoker)
}
}
else
this.updateControl();
}
},
/**
* Observe changes to the control input, re-validate upon change. If
* the validator is not visible, no updates are propagated.
* @param HTMLElement element that calls for validation
*/
observeChanges : function(control)
{
if(!control) return;
var canObserveChanges = this.options.ObserveChanges != false;
var currentlyObserving = this._isObserving[control.id+this.options.ID];
if(canObserveChanges && !currentlyObserving)
{
var validator = this;
Event.observe(control, 'change', function()
{
if(validator.visible)
{
validator.validate();
validator.manager.updateSummary(validator.group);
}
});
this._isObserving[control.id+this.options.ID] = true;
}
},
/**
* @return string trims the string value, empty string if value is not string.
*/
trim : function(value)
{
return typeof(value) == "string" ? value.trim() : "";
},
/**
* Convert the value to a specific data type.
* @param {string} the data type, "Integer", "Double", "Date" or "String"
* @param {string} the value to convert.
* @type {mixed|null} the converted data value.
*/
convert : function(dataType, value)
{
if(typeof(value) == "undefined")
value = this.getValidationValue();
var string = new String(value);
switch(dataType)
{
case "Integer":
return string.toInteger();
case "Double" :
case "Float" :
return string.toDouble(this.options.DecimalChar);
case "Date":
if(typeof(value) != "string")
return value;
else
{
var value = string.toDate(this.options.DateFormat);
if(value && typeof(value.getTime) == "function")
return value.getTime();
else
return null;
}
case "String":
return string.toString();
}
return value;
},
/**
* The ControlType property comes from TBaseValidator::getClientControlClass()
* Be sure to update the TBaseValidator::$_clientClass if new cases are added.
* @return mixed control value to validate
*/
getValidationValue : function(control)
{
if(!control)
control = this.control
switch(this.options.ControlType)
{
case 'TDatePicker':
if(control.type == "text")
{
value = this.trim($F(control));
if(this.options.DateFormat)
{
date = value.toDate(this.options.DateFormat);
return date == null ? value : date;
}
else
return value;
}
else
{
this.observeDatePickerChanges();
return Prado.WebUI.TDatePicker.getDropDownDate(control);//.getTime();
}
case 'THtmlArea':
if(typeof tinyMCE != "undefined")
tinyMCE.triggerSave();
return this.trim($F(control));
case 'TRadioButton':
if(this.options.GroupName)
return this.getRadioButtonGroupValue();
default:
if(this.isListControlType())
return this.getFirstSelectedListValue();
else
return this.trim($F(control));
}
},
getRadioButtonGroupValue : function()
{
name = this.control.name;
value = "";
$A(document.getElementsByName(name)).each(function(el)
{
if(el.checked)
value = el.value;
});
return value;
},
/**
* Observe changes in the drop down list date picker, IE only.
*/
observeDatePickerChanges : function()
{
if(Prado.Browser().ie)
{
var DatePicker = Prado.WebUI.TDatePicker;
this.observeChanges(DatePicker.getDayListControl(this.control));
this.observeChanges(DatePicker.getMonthListControl(this.control));
this.observeChanges(DatePicker.getYearListControl(this.control));
}
},
/**
* Gets numeber selections and their values.
* @return object returns selected values in
values
property
* and number of selections in
checks
property.
*/
getSelectedValuesAndChecks : function(elements, initialValue)
{
var checked = 0;
var values = [];
var isSelected = this.isCheckBoxType(elements[0]) ? 'checked' : 'selected';
elements.each(function(element)
{
if(element[isSelected] && element.value != initialValue)
{
checked++;
values.push(element.value);
}
});
return {'checks' : checked, 'values' : values};
},
/**
* Gets an array of the list control item input elements, for TCheckBoxList
* checkbox inputs are returned, for TListBox HTML option elements are returned.
* @return array list control option elements.
*/
getListElements : function()
{
switch(this.options.ControlType)
{
case 'TCheckBoxList': case 'TRadioButtonList':
var elements = [];
for(var i = 0; i < this.options.TotalItems; i++)
{
var element = $(this.options.ControlToValidate+"_c"+i);
if(this.isCheckBoxType(element))
elements.push(element);
}
return elements;
case 'TListBox':
var elements = [];
var element = $(this.options.ControlToValidate);
if(element && (type = element.type.toLowerCase()))
{
if(type == "select-one" || type == "select-multiple")
elements = $A(element.options);
}
return elements;
default:
return [];
}
},
/**
* @return boolean true if element is of checkbox or radio type.
*/
isCheckBoxType : function(element)
{
if(element && element.type)
{
var type = element.type.toLowerCase();
return type == "checkbox" || type == "radio";
}
return false;
},
/**
* @return boolean true if control to validate is of some of the TListControl type.
*/
isListControlType : function()
{
var list = ['TCheckBoxList', 'TRadioButtonList', 'TListBox'];
return list.include(this.options.ControlType);
},
/**
* @return string gets the first selected list value, initial value if none found.
*/
getFirstSelectedListValue : function()
{
var initial = "";
if(typeof(this.options.InitialValue) != "undefined")
initial = this.options.InitialValue;
var elements = this.getListElements();
var selection = this.getSelectedValuesAndChecks(elements, initial);
return selection.values.length > 0 ? selection.values[0] : initial;
}
}
/**
* TRequiredFieldValidator makes the associated input control a required field.
* The input control fails validation if its value does not change from
* the
InitialValue
option upon losing focus.
*
* options['InitialValue'] Validation fails if control input equals initial value.
*
*/
Prado.WebUI.TRequiredFieldValidator = Class.extend(Prado.WebUI.TBaseValidator,
{
/**
* @return boolean true if the input value is not empty nor equal to the initial value.
*/
evaluateIsValid : function()
{
var inputType = this.control.getAttribute("type");
if(inputType == 'file')
{
return true;
}
else
{
var a = this.getValidationValue();
var b = this.trim(this.options.InitialValue);
return(a != b);
}
}
});
/**
* TCompareValidator compares the value entered by the user into an input
* control with the value entered into another input control or a constant value.
* To compare the associated input control with another input control,
* set the
ControlToCompare
option to the ID path
* of the control to compare with. To compare the associated input control with
* a constant value, specify the constant value to compare with by setting the
*
ValueToCompare
option.
*
* The
DataType
property is used to specify the data type
* of both comparison values. Both values are automatically converted to this data
* type before the comparison operation is performed. The following value types are supported:
* -
Integer
A 32-bit signed integer data type.
* -
Float
A double-precision floating point number data type.
* -
Date
A date data type. The format can be by the
DateFormat
option.
* -
String
A string data type.
*
* Use the
Operator
property to specify the type of comparison
* to perform. Valid operators include Equal, NotEqual, GreaterThan, GreaterThanEqual,
* LessThan and LessThanEqual.
*
* options['ControlToCompare']
* options['ValueToCompare']
* options['Operator']
* options['Type']
* options['DateFormat']
*
*/
Prado.WebUI.TCompareValidator = Class.extend(Prado.WebUI.TBaseValidator,
{
//_observingComparee : false,
/**
* Compares the input to another input or a given value.
*/
evaluateIsValid : function()
{
var value = this.getValidationValue();
if (value.length <= 0)
return true;
var comparee = $(this.options.ControlToCompare);
if(comparee)
var compareTo = this.getValidationValue(comparee);
else
var compareTo = this.options.ValueToCompare || "";
var isValid = this.compare(value, compareTo);
if(comparee)
{
this.updateControlCssClass(comparee, isValid);
this.observeChanges(comparee);
}
return isValid;
},
/**
* Compares two values, their values are casted to type defined
* by
DataType
option. False is returned if the first
* operand converts to null. Returns true if the second operand
* converts to null. The comparision is done based on the
*
Operator
option.
*/
compare : function(operand1, operand2)
{
var op1, op2;
if((op1 = this.convert(this.options.DataType, operand1)) == null)
return false;
if ((op2 = this.convert(this.options.DataType, operand2)) == null)
return true;
switch (this.options.Operator)
{
case "NotEqual":
return (op1 != op2);
case "GreaterThan":
return (op1 > op2);
case "GreaterThanEqual":
return (op1 >= op2);
case "LessThan":
return (op1 < op2);
case "LessThanEqual":
return (op1 <= op2);
default:
return (op1 == op2);
}
}
});
/**
* TCustomValidator performs user-defined client-side validation on an
* input component.
*
* To create a client-side validation function, add the client-side
* validation javascript function to the page template.
* The function should have the following signature:
*
*
*
* Use the
ClientValidationFunction
option
* to specify the name of the client-side validation script function associated
* with the TCustomValidator.
*
* options['ClientValidationFunction'] custom validation function.
*
*/
Prado.WebUI.TCustomValidator = Class.extend(Prado.WebUI.TBaseValidator,
{
/**
* Calls custom validation function.
*/
evaluateIsValid : function()
{
var value = this.getValidationValue();
var clientFunction = this.options.ClientValidationFunction;
if(typeof(clientFunction) == "string" && clientFunction.length > 0)
{
validate = clientFunction.toFunction();
return validate(this, value);
}
return true;
}
});
/**
* Uses callback request to perform validation.
*/
Prado.WebUI.TActiveCustomValidator = Class.extend(Prado.WebUI.TBaseValidator,
{
validatingValue : null,
/**
* Calls custom validation function.
*/
evaluateIsValid : function()
{
value = this.getValidationValue();
if(!this.requestDispatched && (""+value) != (""+this.validatingValue))
//if((""+value) != (""+this.validatingValue))
{
this.validatingValue = value;
request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
if(this.options.DateFormat && value instanceof Date) //change date to string with formatting.
value = value.SimpleFormat(this.options.DateFormat);
request.setCallbackParameter(value);
request.setCausesValidation(false);
request.options.onSuccess = this.callbackOnSuccess.bind(this);
request.options.onFailure = this.callbackOnFailure.bind(this);
request.dispatch();
this.requestDispatched = true;
return false;
}
return this.isValid;
},
callbackOnSuccess : function(request, data)
{
this.isValid = data;
this.requestDispatched = false;
if(typeof(this.options.onSuccess) == "function")
this.options.onSuccess(request,data);
this.updateValidationDisplay();
},
callbackOnFailure : function(request, data)
{
this.requestDispatched = false;
if(typeof(this.options.onFailure) == "function")
this.options.onFailure(request,data);
}
});
/**
* TRangeValidator tests whether an input value is within a specified range.
*
* TRangeValidator uses three key properties to perform its validation.
* The
MinValue
and
MaxValue
options specify the minimum
* and maximum values of the valid range. The
DataType
option is
* used to specify the data type of the value and the minimum and maximum range values.
* These values are converted to this data type before the validation
* operation is performed. The following value types are supported:
* -
Integer
A 32-bit signed integer data type.
* -
Float
A double-precision floating point number data type.
* -
Date
A date data type. The date format can be specified by
* setting
DateFormat
option, which must be recognizable
* by
Date.SimpleParse
javascript function.
* -
String
A string data type.
*
* options['MinValue'] Minimum range value
* options['MaxValue'] Maximum range value
* options['DataType'] Value data type
* options['DateFormat'] Date format for date data type.
*
*/
Prado.WebUI.TRangeValidator = Class.extend(Prado.WebUI.TBaseValidator,
{
/**
* Compares the input value with a minimum and/or maximum value.
* @return boolean true if the value is empty, returns false if conversion fails.
*/
evaluateIsValid : function()
{
var value = this.getValidationValue();
if(value.length <= 0)
return true;
if(typeof(this.options.DataType) == "undefined")
this.options.DataType = "String";
if(this.options.DataType != "StringLength")
{
var min = this.convert(this.options.DataType, this.options.MinValue || null);
var max = this.convert(this.options.DataType, this.options.MaxValue || null);
value = this.convert(this.options.DataType, value);
}
else
{
var min = this.options.MinValue || 0;
var max = this.options.MaxValue || Number.POSITIVE_INFINITY;
value = value.length;
}
if(value == null)
return false;
var valid = true;
if(min != null)
valid = valid && (this.options.StrictComparison ? value > min : value >= min);
if(max != null)
valid = valid && (this.options.StrictComparison ? value < max : value <= max);
return valid;
}
});
/**
* TRegularExpressionValidator validates whether the value of an associated
* input component matches the pattern specified by a regular expression.
*
* options['ValidationExpression'] regular expression to match against.
*
*/
Prado.WebUI.TRegularExpressionValidator = Class.extend(Prado.WebUI.TBaseValidator,
{
/**
* Compare the control input against a regular expression.
*/
evaluateIsValid : function()
{
var value = this.getValidationValue();
if (value.length <= 0)
return true;
var rx = new RegExp(this.options.ValidationExpression);
var matches = rx.exec(value);
return (matches != null && value == matches[0]);
}
});
/**
* TEmailAddressValidator validates whether the value of an associated
* input component is a valid email address.
*/
Prado.WebUI.TEmailAddressValidator = Prado.WebUI.TRegularExpressionValidator;
/**
* TListControlValidator checks the number of selection and their values
* for a TListControl that allows multiple selections.
*/
Prado.WebUI.TListControlValidator = Class.extend(Prado.WebUI.TBaseValidator,
{
/**
* @return true if the number of selections and/or their values
* match the requirements.
*/
evaluateIsValid : function()
{
var elements = this.getListElements();
if(elements && elements.length <= 0)
return true;
this.observeListElements(elements);
var selection = this.getSelectedValuesAndChecks(elements);
return this.isValidList(selection.checks, selection.values);
},
/**
* Observe list elements for IE browsers of changes
*/
observeListElements : function(elements)
{
if(Prado.Browser().ie && this.isCheckBoxType(elements[0]))
{
var validator = this;
elements.each(function(element)
{
validator.observeChanges(element);
});
}
},
/**
* Determine if the number of checked and the checked values
* satisfy the required number of checks and/or the checked values
* equal to the required values.
* @return boolean true if checked values and number of checks are satisfied.
*/
isValidList : function(checked, values)
{
var exists = true;
//check the required values
var required = this.getRequiredValues();
if(required.length > 0)
{
if(values.length < required.length)
return false;
required.each(function(requiredValue)
{
exists = exists && values.include(requiredValue);
});
}
var min = typeof(this.options.Min) == "undefined" ?
Number.NEGATIVE_INFINITY : this.options.Min;
var max = typeof(this.options.Max) == "undefined" ?
Number.POSITIVE_INFINITY : this.options.Max;
return exists && checked >= min && checked <= max;
},
/**
* @return array list of required options that must be selected.
*/
getRequiredValues : function()
{
var required = [];
if(this.options.Required && this.options.Required.length > 0)
required = this.options.Required.split(/,\s*/);
return required;
}
});
/**
* TDataTypeValidator verifies if the input data is of the type specified
* by
DataType
option.
* The following data types are supported:
* -
Integer
A 32-bit signed integer data type.
* -
Float
A double-precision floating point number data type.
* -
Date
A date data type.
* -
String
A string data type.
* For
Date
type, the option
DateFormat
* will be used to determine how to parse the date string.
*/
Prado.WebUI.TDataTypeValidator = Class.extend(Prado.WebUI.TBaseValidator,
{
evaluateIsValid : function()
{
value = this.getValidationValue();
if(value.length <= 0)
return true;
return this.convert(this.options.DataType, value) != null;
}
});