From a6be5564823be40670e0cad8dc758557dbd37549 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sat, 24 Jun 2006 05:46:22 +0000 Subject: Update active controls. --- framework/Web/Javascripts/js/ajax.js | 4 +- framework/Web/Javascripts/js/prado.js | 69 ++++++++++++++++++++++++----------- 2 files changed, 51 insertions(+), 22 deletions(-) (limited to 'framework/Web/Javascripts/js') diff --git a/framework/Web/Javascripts/js/ajax.js b/framework/Web/Javascripts/js/ajax.js index e0e9ae7e..fbbd3ecf 100644 --- a/framework/Web/Javascripts/js/ajax.js +++ b/framework/Web/Javascripts/js/ajax.js @@ -215,4 +215,6 @@ this.timeout=(t+this.options.Interval)*1000;this.count++;return parseInt(this.ti {if(this.timers[id]) this.timers[id].startTimer();},stop:function(id) {if(this.timers[id]) -this.timers[id].stopTimer();}}); \ No newline at end of file +this.timers[id].stopTimer();}});Prado.WebUI.ActiveListControl=Base.extend({constructor:function(options) +{this.element=$(options.ID);this.options=options;Event.observe(this.element,"change",this.doCallback.bind(this));},doCallback:function(event) +{new Prado.CallbackRequest(this.options.EventTarget,this.options);Event.stop(event);}});Prado.WebUI.TActiveDropDownList=Prado.WebUI.ActiveListControl; \ No newline at end of file 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