summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/js/prado.js
diff options
context:
space:
mode:
authorwei <>2006-06-24 05:46:22 +0000
committerwei <>2006-06-24 05:46:22 +0000
commita6be5564823be40670e0cad8dc758557dbd37549 (patch)
tree13083fe7ea207b5426c9ee29afc36654e1ed623d /framework/Web/Javascripts/js/prado.js
parentcb8b23aca4c682c58323f432aa38a88c7a695377 (diff)
Update active controls.
Diffstat (limited to 'framework/Web/Javascripts/js/prado.js')
-rw-r--r--framework/Web/Javascripts/js/prado.js69
1 files changed, 48 insertions, 21 deletions
diff --git a/framework/Web/Javascripts/js/prado.js b/framework/Web/Javascripts/js/prado.js
index c2f2fdfd..0e71f733 100644
--- a/framework/Web/Javascripts/js/prado.js
+++ b/framework/Web/Javascripts/js/prado.js
@@ -251,9 +251,9 @@ lastFocus.value=options['EventTarget'];}}
$('PRADO_POSTBACK_TARGET').value=options['EventTarget'];$('PRADO_POSTBACK_PARAMETER').value=options['EventParameter'];Event.stop(event);Event.fireEvent(form,"submit");}
Prado.Element={setValue:function(element,value)
{var el=$(element);if(el&&typeof(el.value)!="undefined")
-el.value=value;},select:function(element,method,value)
-{var el=$(element);var isList=element.indexOf('[]')>-1;if(!el&&!isList)return;method=isList?'check'+method:el.tagName.toLowerCase()+method;var selection=Prado.Element.Selection;if(typeof(selection[method])=="function")
-selection[method](isList?element:el,value);},click:function(element)
+el.value=value;},select:function(element,method,value,total)
+{var el=$(element);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');},setAttribute:function(element,attribute,value)
{var el=$(element);if(attribute=="disabled"&&value==false)
@@ -278,32 +278,59 @@ else
return result[2];else
return null;},evaluateScript:function(content)
{content.evalScripts();}}
-Prado.Element.Selection={inputValue:function(el,value)
+Prado.Element.Selection={isSelectable:function(el)
+{if(el&&el.type)
{switch(el.type.toLowerCase())
-{case'checkbox':case'radio':return el.checked=value;}},selectValue:function(el,value)
+{case'checkbox':case'radio':case'select':case'select-one':return true;}}
+return false;},inputValue:function(el,value)
+{switch(el.type.toLowerCase())
+{case'checkbox':case'radio':return el.checked=value;}},selectValue:function(elements,value)
+{elements.each(function(el)
{$A(el.options).each(function(option)
-{option.selected=option.value==value;});},selectIndex:function(el,index)
-{if(el.type=='select-one')
+{if(typeof(value)=="boolean")
+options.selected=value;else if(option.value==value)
+option.selected=true;});})},selectValues:function(elements,values)
+{selection=this;values.each(function(value)
+{selection.selectValue(elements,value);})},selectIndex:function(elements,index)
+{elements.each(function(el)
+{if(el.type.toLowerCase()=='select-one')
el.selectedIndex=index;else
{for(var i=0;i<el.length;i++)
{if(i==index)
-el.options[i].selected=true;}}},selectClear:function(el)
-{el.selectedIndex=-1;},selectAll:function(el)
+el.options[i].selected=true;}}})},selectAll:function(elements)
+{elements.each(function(el)
+{if(el.type.toLowerCase()!='select-one')
{$A(el.options).each(function(option)
-{option.selected=true;Logger.warn(option.value);});},selectInvert:function(el)
+{option.selected=true;})}})},selectInvert:function(elements)
+{elements.each(function(el)
+{if(el.type.toLowerCase()!='select-one')
{$A(el.options).each(function(option)
-{option.selected=!option.selected;});},checkValue:function(name,value)
-{$A(document.getElementsByName(name)).each(function(el)
-{el.checked=el.value==value});},checkIndex:function(name,index)
-{var elements=$A(document.getElementsByName(name));for(var i=0;i<elements.length;i++)
+{option.selected=!options.selected;})}})},selectIndices:function(elements,indices)
+{selection=this;indices.each(function(index)
+{selection.selectIndex(elements,index);})},selectClear:function(elements)
+{elements.each(function(el)
+{el.selectedIndex=-1;})},getListElements:function(element,total)
+{elements=new Array();for(i=0;i<total;i++)
+{el=$(element+"_c"+i);if(el)
+elements.push(el);}
+return elements;},checkValue:function(elements,value)
+{elements.each(function(el)
+{if(typeof(value)=="boolean")
+el.checked=value;else if(el.value==value)
+el.checked=true;});},checkValues:function(elements,values)
+{selection=this;values.each(function(value)
+{selection.checkValue(elements,value);})},checkIndex:function(elements,index)
+{for(var i=0;i<elements.length;i++)
{if(i==index)
-elements[i].checked=true;}},checkClear:function(name)
-{$A(document.getElementsByName(name)).each(function(el)
-{el.checked=false;});},checkAll:function(name)
-{$A(document.getElementsByName(name)).each(function(el)
-{el.checked=true;});},checkInvert:function(name)
-{$A(document.getElementsByName(name)).each(function(el)
-{el.checked=!el.checked;});}};Prado.WebUI=Class.create();Prado.WebUI.PostBackControl=Class.create();Prado.WebUI.PostBackControl.prototype={_elementOnClick:null,initialize:function(options)
+elements[i].checked=true;}},checkIndices:function(elements,indices)
+{selection=this;indices.each(function(index)
+{selection.checkIndex(elements,index);})},checkClear:function(elements)
+{elements.each(function(el)
+{el.checked=false;});},checkAll:function(elements)
+{elements.each(function(el)
+{el.checked=true;})},checkInvert:function(elements)
+{elements.each(function(el)
+{el.checked!=el.checked;})}};Prado.WebUI=Class.create();Prado.WebUI.PostBackControl=Class.create();Prado.WebUI.PostBackControl.prototype={_elementOnClick:null,initialize:function(options)
{this.element=$(options.ID);if(this.onInit)
this.onInit(options);},onInit:function(options)
{if(typeof(this.element.onclick)=="function")