summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwei <>2006-08-12 05:34:54 +0000
committerwei <>2006-08-12 05:34:54 +0000
commit54d4919e3f1b00b644fa3c107acdf20159a1b154 (patch)
tree1c3e9cc679d4e08cc4beb06eee6f79838a34cb31
parent6dd529fdc25404da07cf9256d92f2a94985c65fc (diff)
Update active controls.
-rw-r--r--.gitattributes12
-rw-r--r--framework/Web/Javascripts/js/ajax.js15
-rw-r--r--framework/Web/Javascripts/js/prado.js20
-rw-r--r--framework/Web/Javascripts/prado/activecontrols3.js11
-rw-r--r--framework/Web/Javascripts/prado/ajax3.js17
-rw-r--r--framework/Web/Javascripts/prado/element.js15
-rw-r--r--framework/Web/Javascripts/prototype/form.js60
-rw-r--r--framework/Web/Javascripts/prototype/hash.js26
-rw-r--r--framework/Web/UI/ActiveControls/TActiveLinkButton.php98
-rw-r--r--framework/Web/UI/ActiveControls/TActiveListBox.php92
-rw-r--r--framework/Web/UI/ActiveControls/TActiveRadioButton.php143
-rw-r--r--framework/Web/UI/ActiveControls/TActiveRadioButtonList.php70
-rw-r--r--framework/Web/UI/ActiveControls/TCallbackClientScript.php5
-rwxr-xr-xframework/Web/UI/ActiveControls/TCallbackResponseAdapter.php6
-rw-r--r--framework/Web/UI/WebControls/TLinkButton.php16
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/ActiveLinkButtonTest.page11
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/ActiveLinkButtonTest.php16
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxTest.page27
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxTest.php47
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonListTest.page22
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonListTest.php27
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonTest.page38
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonTest.php34
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.page9
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.php21
-rw-r--r--tests/FunctionalTests/active-controls/tests/ActiveButtonTestCase.php2
-rw-r--r--tests/FunctionalTests/active-controls/tests/ActiveCheckBoxListTestCase.php40
-rw-r--r--tests/FunctionalTests/active-controls/tests/ActiveCheckBoxTestCase.php42
-rw-r--r--tests/FunctionalTests/active-controls/tests/ActiveDropDownListTestCase.php28
-rw-r--r--tests/FunctionalTests/active-controls/tests/ActiveHyperLinkTestCase.php6
-rw-r--r--tests/FunctionalTests/active-controls/tests/ActiveLinkButtonTestCase.php16
-rw-r--r--tests/FunctionalTests/active-controls/tests/ActiveListBoxTestCase.php53
-rw-r--r--tests/FunctionalTests/active-controls/tests/ActivePanelTestCase.php2
-rw-r--r--tests/FunctionalTests/active-controls/tests/ActiveRadioButtonListTestCase.php47
-rw-r--r--tests/FunctionalTests/active-controls/tests/ActiveRadioButtonTestCase.php54
-rw-r--r--tests/FunctionalTests/active-controls/tests/AutoCompleteTestCase.php8
-rw-r--r--tests/FunctionalTests/active-controls/tests/CallbackAdapterTestCase.php18
-rw-r--r--tests/FunctionalTests/active-controls/tests/CallbackOptionsTestCase.php10
-rw-r--r--tests/FunctionalTests/active-controls/tests/CustomTemplateTestCase.php2
-rw-r--r--tests/FunctionalTests/active-controls/tests/NestedActiveControlsTestCase.php10
-rw-r--r--tests/FunctionalTests/active-controls/tests/ReplaceContentTestCase.php8
-rw-r--r--tests/FunctionalTests/active-controls/tests/TextBoxCallbackTestCase.php4
-rw-r--r--tests/FunctionalTests/active-controls/tests/TextBoxGroupValidationTestCase.php2
43 files changed, 1053 insertions, 157 deletions
diff --git a/.gitattributes b/.gitattributes
index 517f327a..e7683983 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1855,6 +1855,14 @@ requirements/messages.txt -text
requirements/template-bg.html -text
requirements/template-zh.html -text
requirements/template.html -text
+tests/FunctionalTests/active-controls/protected/pages/ActiveLinkButtonTest.page -text
+tests/FunctionalTests/active-controls/protected/pages/ActiveLinkButtonTest.php -text
+tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxTest.page -text
+tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxTest.php -text
+tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonListTest.page -text
+tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonListTest.php -text
+tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonTest.page -text
+tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonTest.php -text
tests/FunctionalTests/active-controls/protected/pages/CustomTemplateComponent.php -text
tests/FunctionalTests/active-controls/protected/pages/CustomTemplateComponent.tpl -text
tests/FunctionalTests/active-controls/protected/pages/CustomTemplateControlTest.page -text
@@ -1863,6 +1871,10 @@ tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.page -t
tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.php -text
tests/FunctionalTests/active-controls/protected/pages/TextBoxValidationCallback.page -text
tests/FunctionalTests/active-controls/protected/pages/TextBoxValidationCallback.php -text
+tests/FunctionalTests/active-controls/tests/ActiveLinkButtonTestCase.php -text
+tests/FunctionalTests/active-controls/tests/ActiveListBoxTestCase.php -text
+tests/FunctionalTests/active-controls/tests/ActiveRadioButtonListTestCase.php -text
+tests/FunctionalTests/active-controls/tests/ActiveRadioButtonTestCase.php -text
tests/FunctionalTests/active-controls/tests/CustomTemplateTestCase.php -text
tests/FunctionalTests/active-controls/tests/ReplaceContentTestCase.php -text
tests/FunctionalTests/active-controls/tests/TextBoxGroupValidationTestCase.php -text
diff --git a/framework/Web/Javascripts/js/ajax.js b/framework/Web/Javascripts/js/ajax.js
index fd1b7a76..0836f094 100644
--- a/framework/Web/Javascripts/js/ajax.js
+++ b/framework/Web/Javascripts/js/ajax.js
@@ -34,7 +34,9 @@ this.transport.onreadystatechange=Prototype.emptyFunction;},getHeaderData:functi
catch(e)
{if(typeof(json)=="string")
return Prado.CallbackRequest.decode(json);}}});Prado.CallbackRequest=Class.create();Object.extend(Prado.CallbackRequest,{FIELD_CALLBACK_TARGET:'PRADO_CALLBACK_TARGET',FIELD_CALLBACK_PARAMETER:'PRADO_CALLBACK_PARAMETER',FIELD_CALLBACK_PAGESTATE:'PRADO_PAGESTATE',FIELD_POSTBACK_TARGET:'PRADO_POSTBACK_TARGET',FIELD_POSTBACK_PARAMETER:'PRADO_POSTBACK_PARAMETER',PostDataLoaders:[],DATA_HEADER:'X-PRADO-DATA',ACTION_HEADER:'X-PRADO-ACTIONS',ERROR_HEADER:'X-PRADO-ERROR',PAGESTATE_HEADER:'X-PRADO-PAGESTATE',requestInProgress:null,addPostLoaders:function(ids)
-{this.PostDataLoaders=this.PostDataLoaders.concat(ids);},dispatchActions:function(transport,actions)
+{this.PostDataLoaders=this.PostDataLoaders.concat(ids);list=[];this.PostDataLoaders.each(function(id)
+{if(list.indexOf(id)<0)
+list.push(id);});this.PostDataLoaders=list;},dispatchActions:function(transport,actions)
{if(actions&&actions.length>0)
actions.each(this.__run.bind(this,transport));},__run:function(transport,command)
{for(var method in command)
@@ -93,8 +95,9 @@ Prado.CallbackRequest.dispatchNormalRequest(this);},_getPostData:function()
{var data={};var callback=Prado.CallbackRequest;if(this.options.PostInputs!=false)
{callback.PostDataLoaders.each(function(name)
{$A(document.getElementsByName(name)).each(function(element)
-{var value=$F(element);if(typeof(value)!="undefined")
-data[name]=value;})})}
+{if(element.type&&element.name==name)
+{value=$F(element);if(typeof(value)!="undefined")
+data[name]=value;}})})}
if(typeof(this.options.params)!="undefined")
data[callback.FIELD_CALLBACK_PARAMETER]=callback.encode(this.options.params);var pageState=$F(callback.FIELD_CALLBACK_PAGESTATE);if(typeof(pageState)!="undefined")
data[callback.FIELD_CALLBACK_PAGESTATE]=pageState;data[callback.FIELD_CALLBACK_TARGET]=this.id;if(this.options.EventTarget)
@@ -197,8 +200,8 @@ if(this.saving)return;this.effect=new Effect.Highlight(this.element,{startcolor:
this.editing=false;this.saving=false;this.oldInnerHTML=null;this.onLeaveEditMode();},onComplete:function(transport){this.leaveEditMode();this.options.onComplete.bind(this)(transport,this.element);},onEnterEditMode:function(){},onLeaveEditMode:function(){},dispose:function(){if(this.oldInnerHTML){this.element.innerHTML=this.oldInnerHTML;}
this.leaveEditMode();Event.stopObserving(this.element,'click',this.onclickListener);Event.stopObserving(this.element,'mouseover',this.mouseoverListener);Event.stopObserving(this.element,'mouseout',this.mouseoutListener);if(this.options.externalControl){Event.stopObserving(this.options.externalControl,'click',this.onclickListener);Event.stopObserving(this.options.externalControl,'mouseover',this.mouseoverListener);Event.stopObserving(this.options.externalControl,'mouseout',this.mouseoutListener);}}};Ajax.InPlaceCollectionEditor=Class.create();Object.extend(Ajax.InPlaceCollectionEditor.prototype,Ajax.InPlaceEditor.prototype);Object.extend(Ajax.InPlaceCollectionEditor.prototype,{createEditField:function(){if(!this.cached_selectTag){var selectTag=document.createElement("select");var collection=this.options.collection||[];var optionTag;collection.each(function(e,i){optionTag=document.createElement("option");optionTag.value=(e instanceof Array)?e[0]:e;if(this.options.value==optionTag.value)optionTag.selected=true;optionTag.appendChild(document.createTextNode((e instanceof Array)?e[1]:e));selectTag.appendChild(optionTag);}.bind(this));this.cached_selectTag=selectTag;}
this.editField=this.cached_selectTag;if(this.options.loadTextURL)this.loadExternalText();this.form.appendChild(this.editField);this.options.callback=function(form,value){return"value="+encodeURIComponent(value);}}});Form.Element.DelayedObserver=Class.create();Form.Element.DelayedObserver.prototype={initialize:function(element,delay,callback){this.delay=delay||0.5;this.element=$(element);this.callback=callback;this.timer=null;this.lastValue=$F(this.element);Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));},delayedListener:function(event){if(this.lastValue==$F(this.element))return;if(this.timer)clearTimeout(this.timer);this.timer=setTimeout(this.onTimerEvent.bind(this),this.delay*1000);this.lastValue=$F(this.element);},onTimerEvent:function(){this.timer=null;this.callback(this.element,$F(this.element));}};Prado.WebUI.CallbackControl=Class.extend(Prado.WebUI.PostBackControl,{onPostBack:function(event,options)
-{request=new Prado.CallbackRequest(options.EventTarget,options);request.dispatch();Event.stop(event);}});Prado.WebUI.TActiveButton=Class.extend(Prado.WebUI.CallbackControl);Prado.WebUI.TActiveCheckBox=Class.extend(Prado.WebUI.CallbackControl,{onPostBack:function(event,options)
-{request=new Prado.CallbackRequest(options.EventTarget,options);request.dispatch();}});Prado.WebUI.TActiveTextBox=Class.extend(Prado.WebUI.TTextBox,{onInit:function(options)
+{request=new Prado.CallbackRequest(options.EventTarget,options);request.dispatch();Event.stop(event);}});Prado.WebUI.TActiveButton=Class.extend(Prado.WebUI.CallbackControl);Prado.WebUI.TActiveLinkButton=Class.extend(Prado.WebUI.CallbackControl);Prado.WebUI.TActiveCheckBox=Class.extend(Prado.WebUI.CallbackControl,{onPostBack:function(event,options)
+{request=new Prado.CallbackRequest(options.EventTarget,options);request.dispatch();}});Prado.WebUI.TActiveRadioButton=Class.extend(Prado.WebUI.TActiveCheckBox);Prado.WebUI.TActiveTextBox=Class.extend(Prado.WebUI.TTextBox,{onInit:function(options)
{if(options['TextMode']!='MultiLine')
Event.observe(this.element,"keydown",this.handleReturnKey.bind(this));Event.observe(this.element,"change",this.doCallback.bindEvent(this,options));},doCallback:function(event,options)
{request=new Prado.CallbackRequest(options.EventTarget,options);request.dispatch();Event.stop(event);}});Prado.WebUI.TAutoComplete=Class.extend(Autocompleter.Base,Prado.WebUI.TActiveTextBox.prototype);Prado.WebUI.TAutoComplete=Class.extend(Prado.WebUI.TAutoComplete,{initialize:function(options)
@@ -225,4 +228,4 @@ this.timers[id].startTimer();},stop:function(id)
{if(this.timers[id])
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)
-{request=new Prado.CallbackRequest(this.options.EventTarget,this.options);request.dispatch();Event.stop(event);}});Prado.WebUI.TActiveDropDownList=Prado.WebUI.ActiveListControl; \ No newline at end of file
+{request=new Prado.CallbackRequest(this.options.EventTarget,this.options);request.dispatch();Event.stop(event);}});Prado.WebUI.TActiveDropDownList=Prado.WebUI.ActiveListControl;Prado.WebUI.TActiveListBox=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 25a26d70..e3930cfd 100644
--- a/framework/Web/Javascripts/js/prado.js
+++ b/framework/Web/Javascripts/js/prado.js
@@ -54,7 +54,12 @@ results.push(iterable[i]);return results;}}
Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse)
Array.prototype._reverse=Array.prototype.reverse;Object.extend(Array.prototype,{_each:function(iterator){for(var i=0;i<this.length;i++)
iterator(this[i]);},clear:function(){this.length=0;return this;},first:function(){return this[0];},last:function(){return this[this.length-1];},compact:function(){return this.select(function(value){return value!=undefined||value!=null;});},flatten:function(){return this.inject([],function(array,value){return array.concat(value&&value.constructor==Array?value.flatten():[value]);});},without:function(){var values=$A(arguments);return this.select(function(value){return!values.include(value);});},indexOf:function(object){for(var i=0;i<this.length;i++)
-if(this[i]==object)return i;return-1;},reverse:function(inline){return(inline!==false?this:this.toArray())._reverse();},inspect:function(){return'['+this.map(Object.inspect).join(', ')+']';}});var Hash={_each:function(iterator){for(var key in this){var value=this[key];if(typeof value=='function')continue;var pair=[key,value];pair.key=key;pair.value=value;iterator(pair);}},keys:function(){return this.pluck('key');},values:function(){return this.pluck('value');},merge:function(hash){return $H(hash).inject($H(this),function(mergedHash,pair){mergedHash[pair.key]=pair.value;return mergedHash;});},toQueryString:function(){return this.map(function(pair){return pair.map(encodeURIComponent).join('=');}).join('&');},inspect:function(){return'#<Hash:{'+this.map(function(pair){return pair.map(Object.inspect).join(': ');}).join(', ')+'}>';}}
+if(this[i]==object)return i;return-1;},reverse:function(inline){return(inline!==false?this:this.toArray())._reverse();},inspect:function(){return'['+this.map(Object.inspect).join(', ')+']';}});var Hash={_each:function(iterator){for(var key in this){var value=this[key];if(typeof value=='function')continue;var pair=[key,value];pair.key=key;pair.value=value;iterator(pair);}},keys:function(){return this.pluck('key');},values:function(){return this.pluck('value');},merge:function(hash){return $H(hash).inject($H(this),function(mergedHash,pair){mergedHash[pair.key]=pair.value;return mergedHash;});},toQueryString:function(){return this.map(function(pair)
+{if(typeof(pair[1])=='object'||typeof(pair[1])=='array')
+{return $A(pair[1]).collect(function(value)
+{return encodeURIComponent(pair[0])+'='+encodeURIComponent(value);}).join('&');}
+else
+return pair.map(encodeURIComponent).join('=');}).join('&');},inspect:function(){return'#<Hash:{'+this.map(function(pair){return pair.map(Object.inspect).join(': ');}).join(', ')+'}>';}}
function $H(object){var hash=Object.extend({},object||{});Object.extend(hash,Enumerable);Object.extend(hash,Hash);return hash;}
ObjectRange=Class.create();Object.extend(ObjectRange.prototype,Enumerable);Object.extend(ObjectRange.prototype,{initialize:function(start,end,exclusive){this.start=start;this.end=end;this.exclusive=exclusive;},_each:function(iterator){var value=this.start;do{iterator(value);value=value.succ();}while(this.include(value));},include:function(value){if(value<this.start)
return false;if(this.exclusive)
@@ -102,7 +107,8 @@ return matchingInputs;},disable:function(form){var elements=Form.getElements(for
Form.Element={serialize:function(element){element=$(element);var method=element.tagName.toLowerCase();var parameter=Form.Element.Serializers[method](element);if(parameter){var key=encodeURIComponent(parameter[0]);if(key.length==0)return;if(parameter[1].constructor!=Array)
parameter[1]=[parameter[1]];return parameter[1].map(function(value){return key+'='+encodeURIComponent(value);}).join('&');}},getValue:function(element){element=$(element);var method=element.tagName.toLowerCase();var parameter=Form.Element.Serializers[method](element);if(parameter)
return parameter[1];}}
-Form.Element.Serializers={input:function(element){switch(element.type.toLowerCase()){case'submit':case'hidden':case'password':case'text':return Form.Element.Serializers.textarea(element);case'checkbox':case'radio':return Form.Element.Serializers.inputSelector(element);}
+Form.Element.Serializers={input:function(element){if(typeof(element.type)=="undefined")
+return false;switch(element.type.toLowerCase()){case'submit':case'hidden':case'password':case'text':return Form.Element.Serializers.textarea(element);case'checkbox':case'radio':return Form.Element.Serializers.inputSelector(element);}
return false;},inputSelector:function(element){if(element.checked)
return[element.name,element.value];},textarea:function(element){return[element.name,element.value];},select:function(element){return Form.Element.Serializers[element.type=='select-one'?'selectOne':'selectMany'](element);},selectOne:function(element){var value='',opt,index=element.selectedIndex;if(index>=0){opt=element.options[index];value=opt.value||opt.text;}
return[element.name,value];},selectMany:function(element){var value=[];for(var i=0;i<element.length;i++){var opt=element.options[i];if(opt.selected)
@@ -256,9 +262,13 @@ el.value=value;},select:function(element,method,value,total)
{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)
+{var el=$(element);if((attribute=="disabled"||attribute=="multiple")&&value==false)
el.removeAttribute(attribute);else if(attribute.match(/^on/i))
-el[attribute]=eval("(function(event){"+value+"})");else
+{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&&el.tagName.toLowerCase()=="select")
{el.options.length=options.length;for(var i=0;i<options.length;i++)
@@ -280,7 +290,7 @@ return null;},evaluateScript:function(content)
Prado.Element.Selection={isSelectable:function(el)
{if(el&&el.type)
{switch(el.type.toLowerCase())
-{case'checkbox':case'radio':case'select':case'select-one':return true;}}
+{case'checkbox':case'radio':case'select':case'select-multiple':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)
diff --git a/framework/Web/Javascripts/prado/activecontrols3.js b/framework/Web/Javascripts/prado/activecontrols3.js
index 71719f35..f75d3684 100644
--- a/framework/Web/Javascripts/prado/activecontrols3.js
+++ b/framework/Web/Javascripts/prado/activecontrols3.js
@@ -15,6 +15,10 @@ Prado.WebUI.CallbackControl = Class.extend(Prado.WebUI.PostBackControl,
* TActiveButton control.
*/
Prado.WebUI.TActiveButton = Class.extend(Prado.WebUI.CallbackControl);
+/**
+ * TActiveLinkButton control.
+ */
+Prado.WebUI.TActiveLinkButton = Class.extend(Prado.WebUI.CallbackControl);
/**
* Active check box.
@@ -29,6 +33,12 @@ Prado.WebUI.TActiveCheckBox = Class.extend(Prado.WebUI.CallbackControl,
});
/**
+ * TActiveRadioButton control.
+ */
+Prado.WebUI.TActiveRadioButton = Class.extend(Prado.WebUI.TActiveCheckBox);
+
+
+/**
* TActiveTextBox control, handles onchange event.
*/
Prado.WebUI.TActiveTextBox = Class.extend(Prado.WebUI.TTextBox,
@@ -212,3 +222,4 @@ Prado.WebUI.ActiveListControl = Base.extend(
});
Prado.WebUI.TActiveDropDownList = Prado.WebUI.ActiveListControl;
+Prado.WebUI.TActiveListBox = Prado.WebUI.ActiveListControl;
diff --git a/framework/Web/Javascripts/prado/ajax3.js b/framework/Web/Javascripts/prado/ajax3.js
index 8de0b0fe..de5af4ca 100644
--- a/framework/Web/Javascripts/prado/ajax3.js
+++ b/framework/Web/Javascripts/prado/ajax3.js
@@ -120,6 +120,13 @@ Object.extend(Prado.CallbackRequest,
addPostLoaders : function(ids)
{
this.PostDataLoaders = this.PostDataLoaders.concat(ids);
+ list = [];
+ this.PostDataLoaders.each(function(id)
+ {
+ if(list.indexOf(id) < 0)
+ list.push(id);
+ });
+ this.PostDataLoaders = list;
},
/**
@@ -477,9 +484,13 @@ Prado.CallbackRequest.prototype =
{
$A(document.getElementsByName(name)).each(function(element)
{
- var value = $F(element);
- if(typeof(value) != "undefined")
- data[name] = value;
+ //IE will try to get elements with ID == name as well.
+ if(element.type && element.name == name)
+ {
+ value = $F(element);
+ if(typeof(value) != "undefined")
+ data[name] = value;
+ }
})
})
}
diff --git a/framework/Web/Javascripts/prado/element.js b/framework/Web/Javascripts/prado/element.js
index 9b7bd120..d234e71b 100644
--- a/framework/Web/Javascripts/prado/element.js
+++ b/framework/Web/Javascripts/prado/element.js
@@ -33,10 +33,20 @@ Prado.Element =
setAttribute : function(element, attribute, value)
{
var el = $(element);
- if(attribute == "disabled" && value==false)
+ if((attribute == "disabled" || attribute == "multiple") && value==false)
el.removeAttribute(attribute);
else if(attribute.match(/^on/i)) //event methods
- el[attribute] = eval("(function(event){"+value+"})");
+ {
+ 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);
},
@@ -110,6 +120,7 @@ Prado.Element.Selection =
case 'checkbox':
case 'radio':
case 'select':
+ case 'select-multiple':
case 'select-one':
return true;
}
diff --git a/framework/Web/Javascripts/prototype/form.js b/framework/Web/Javascripts/prototype/form.js
index 590f7f9f..41745353 100644
--- a/framework/Web/Javascripts/prototype/form.js
+++ b/framework/Web/Javascripts/prototype/form.js
@@ -7,17 +7,17 @@ var Field = {
focus: function(element) {
$(element).focus();
},
-
+
present: function() {
for (var i = 0; i < arguments.length; i++)
if ($(arguments[i]).value == '') return false;
return true;
},
-
+
select: function(element) {
$(element).select();
},
-
+
activate: function(element) {
element = $(element);
element.focus();
@@ -32,16 +32,16 @@ var Form = {
serialize: function(form) {
var elements = Form.getElements($(form));
var queryComponents = new Array();
-
+
for (var i = 0; i < elements.length; i++) {
var queryComponent = Form.Element.serialize(elements[i]);
if (queryComponent)
queryComponents.push(queryComponent);
}
-
+
return queryComponents.join('&');
},
-
+
getElements: function(form) {
form = $(form);
var elements = new Array();
@@ -53,19 +53,19 @@ var Form = {
}
return elements;
},
-
+
getInputs: function(form, typeName, name) {
form = $(form);
var inputs = form.getElementsByTagName('input');
-
+
if (!typeName && !name)
return inputs;
-
+
var matchingInputs = new Array();
for (var i = 0; i < inputs.length; i++) {
var input = inputs[i];
if ((typeName && input.type != typeName) ||
- (name && input.name != name))
+ (name && input.name != name))
continue;
matchingInputs.push(input);
}
@@ -111,25 +111,25 @@ Form.Element = {
element = $(element);
var method = element.tagName.toLowerCase();
var parameter = Form.Element.Serializers[method](element);
-
+
if (parameter) {
var key = encodeURIComponent(parameter[0]);
if (key.length == 0) return;
-
+
if (parameter[1].constructor != Array)
parameter[1] = [parameter[1]];
-
+
return parameter[1].map(function(value) {
return key + '=' + encodeURIComponent(value);
}).join('&');
}
},
-
+
getValue: function(element) {
element = $(element);
var method = element.tagName.toLowerCase();
var parameter = Form.Element.Serializers[method](element);
-
+
if (parameter)
return parameter[1];
}
@@ -137,13 +137,15 @@ Form.Element = {
Form.Element.Serializers = {
input: function(element) {
+ if(typeof(element.type) == "undefined")
+ return false;
switch (element.type.toLowerCase()) {
case 'submit':
case 'hidden':
case 'password':
case 'text':
return Form.Element.Serializers.textarea(element);
- case 'checkbox':
+ case 'checkbox':
case 'radio':
return Form.Element.Serializers.inputSelector(element);
}
@@ -158,12 +160,12 @@ Form.Element.Serializers = {
textarea: function(element) {
return [element.name, element.value];
},
-
+
select: function(element) {
- return Form.Element.Serializers[element.type == 'select-one' ?
+ return Form.Element.Serializers[element.type == 'select-one' ?
'selectOne' : 'selectMany'](element);
},
-
+
selectOne: function(element) {
var value = '', opt, index = element.selectedIndex;
if (index >= 0) {
@@ -172,7 +174,7 @@ Form.Element.Serializers = {
}
return [element.name, value];
},
-
+
selectMany: function(element) {
var value = [];
for (var i = 0; i < element.length; i++) {
@@ -196,15 +198,15 @@ Abstract.TimedObserver.prototype = {
this.frequency = frequency;
this.element = $(element);
this.callback = callback;
-
+
this.lastValue = this.getValue();
this.registerCallback();
},
-
+
registerCallback: function() {
setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
},
-
+
onTimerEvent: function() {
var value = this.getValue();
if (this.lastValue != value) {
@@ -235,14 +237,14 @@ Abstract.EventObserver.prototype = {
initialize: function(element, callback) {
this.element = $(element);
this.callback = callback;
-
+
this.lastValue = this.getValue();
if (this.element.tagName.toLowerCase() == 'form')
this.registerFormCallbacks();
else
this.registerCallback(this.element);
},
-
+
onElementEvent: function() {
var value = this.getValue();
if (this.lastValue != value) {
@@ -250,17 +252,17 @@ Abstract.EventObserver.prototype = {
this.lastValue = value;
}
},
-
+
registerFormCallbacks: function() {
var elements = Form.getElements(this.element);
for (var i = 0; i < elements.length; i++)
this.registerCallback(elements[i]);
},
-
+
registerCallback: function(element) {
if (element.type) {
switch (element.type.toLowerCase()) {
- case 'checkbox':
+ case 'checkbox':
case 'radio':
Event.observe(element, 'click', this.onElementEvent.bind(this));
break;
@@ -272,7 +274,7 @@ Abstract.EventObserver.prototype = {
Event.observe(element, 'change', this.onElementEvent.bind(this));
break;
}
- }
+ }
}
}
diff --git a/framework/Web/Javascripts/prototype/hash.js b/framework/Web/Javascripts/prototype/hash.js
index 7e8c6f5d..1589189c 100644
--- a/framework/Web/Javascripts/prototype/hash.js
+++ b/framework/Web/Javascripts/prototype/hash.js
@@ -3,35 +3,45 @@ var Hash = {
for (var key in this) {
var value = this[key];
if (typeof value == 'function') continue;
-
+
var pair = [key, value];
pair.key = key;
pair.value = value;
iterator(pair);
}
},
-
+
keys: function() {
return this.pluck('key');
},
-
+
values: function() {
return this.pluck('value');
},
-
+
merge: function(hash) {
return $H(hash).inject($H(this), function(mergedHash, pair) {
mergedHash[pair.key] = pair.value;
return mergedHash;
});
},
-
+
toQueryString: function() {
- return this.map(function(pair) {
- return pair.map(encodeURIComponent).join('=');
+ return this.map(function(pair)
+ {
+ //special case for PHP, array post data.
+ if(typeof(pair[1]) == 'object' || typeof(pair[1]) == 'array')
+ {
+ return $A(pair[1]).collect(function(value)
+ {
+ return encodeURIComponent(pair[0])+'='+encodeURIComponent(value);
+ }).join('&');
+ }
+ else
+ return pair.map(encodeURIComponent).join('=');
}).join('&');
},
-
+
inspect: function() {
return '#<Hash:{' + this.map(function(pair) {
return pair.map(Object.inspect).join(': ');
diff --git a/framework/Web/UI/ActiveControls/TActiveLinkButton.php b/framework/Web/UI/ActiveControls/TActiveLinkButton.php
index 40b69391..16c02519 100644
--- a/framework/Web/UI/ActiveControls/TActiveLinkButton.php
+++ b/framework/Web/UI/ActiveControls/TActiveLinkButton.php
@@ -11,7 +11,17 @@
*/
/**
- * TActiveLinkButton class.
+ * TActiveLinkButton is the active control counter part to TLinkButton.
+ *
+ * When a TActiveLinkButton is clicked, rather than a normal post back request a
+ * callback request is initiated.
+ *
+ * The {@link onCallback OnCallback} event is raised during a callback request
+ * and it is raise <b>after</b> the {@link onClick OnClick} event.
+ *
+ * When the {@link TBaseActiveCallbackControl::setEnableUpdate ActiveControl.EnableUpdate}
+ * property is true, changing the {@link setText Text} property during callback request
+ * will update the link text upon callback response completion.
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version : $ Mon Jun 26 00:49:25 EST 2006 $
@@ -20,6 +30,92 @@
*/
class TActiveLinkButton extends TLinkButton implements IActiveControl, ICallbackEventHandler
{
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TActiveControlAdapter($this));
+ }
+
+ /**
+ * @return TBaseActiveCallbackControl standard callback control options.
+ */
+ public function getActiveControl()
+ {
+ return $this->getAdapter()->getBaseActiveControl();
+ }
+
+ /**
+ * Raises the callback event. This method is required by {@link
+ * ICallbackEventHandler} interface. If {@link getCausesValidation
+ * CausesValidation} is true, it will invoke the page's {@link TPage::
+ * validate validate} method first. It will raise {@link onClick
+ * OnClick} event first and then the {@link onCallback OnCallback} event.
+ * This method is mainly used by framework and control developers.
+ * @param TCallbackEventParameter the event parameter
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->raisePostBackEvent($param);
+ $this->onCallback($param);
+ }
+
+ /**
+ * This method is invoked when a callback is requested. The method raises
+ * 'OnCallback' event to fire up the event handlers. If you override this
+ * method, be sure to call the parent implementation so that the event
+ * handler can be invoked.
+ * @param TCallbackEventParameter event parameter to be passed to the event handlers
+ */
+ public function onCallback($param)
+ {
+ $this->raiseEvent('OnCallback', $this, $param);
+ }
+
+ /**
+ * Updates the link text on the client-side if the
+ * {@link setEnableUpdate EnableUpdate} property is set to true.
+ * @param string caption of the button
+ */
+ public function setText($value)
+ {
+ parent::setText($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->setAttribute($this, 'value', $value);
+ }
+
+ /**
+ * Override parent implementation, no javascript is rendered here instead
+ * the javascript required for active control is registered in {@link addAttributesToRender}.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ }
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
+ */
+ protected function addAttributesToRender($writer)
+ {
+ parent::addAttributesToRender($writer);
+ $writer->addAttribute('id',$this->getClientID());
+ $this->renderLinkButtonHref($writer);
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getPostBackOptions());
+ }
+
+ /**
+ * @return string corresponding javascript class name for this TActiveLinkButton.
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TActiveLinkButton';
+ }
}
?> \ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActiveListBox.php b/framework/Web/UI/ActiveControls/TActiveListBox.php
index 37db5e27..77ca615a 100644
--- a/framework/Web/UI/ActiveControls/TActiveListBox.php
+++ b/framework/Web/UI/ActiveControls/TActiveListBox.php
@@ -20,7 +20,97 @@
*/
class TActiveListBox extends TListBox implements IActiveControl, ICallbackEventHandler
{
-
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveListControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TActiveListControlAdapter($this));
+ $this->setAutoPostBack(true);
+ }
+
+ /**
+ * @return TBaseActiveCallbackControl standard callback control options.
+ */
+ public function getActiveControl()
+ {
+ return $this->getAdapter()->getBaseActiveControl();
+ }
+
+ /**
+ * Javascript client class for this control.
+ * This method overrides the parent implementation.
+ * @return null no javascript class name.
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TActiveListBox';
+ }
+
+ /**
+ * Loads user input data. Disables the client-side update during loading
+ * and restore the EnableUpdate of ActiveControl after loading.
+ * @param string the key that can be used to retrieve data from the input data collection
+ * @param array the input data collection
+ * @return boolean whether the data of the component has been changed
+ */
+ public function loadPostData($key,$values)
+ {
+ $enabled = $this->getActiveControl()->getEnableUpdate();
+ $this->getActiveControl()->setEnableUpdate(false);
+ $result = parent::loadPostData($key, $values);
+ $this->getActiveControl()->setEnableUpdate($enabled);
+ return $result;
+ }
+
+ /**
+ * Sets the selection mode of the list control (Single, Multiple)
+ * on the client-side if the {@link setEnableUpdate EnableUpdate}
+ * property is set to true.
+ * @param string the selection mode
+ */
+ public function setSelectionMode($value)
+ {
+ parent::setSelectionMode($value);
+ $multiple = $this->getIsMultiSelect();
+ $id = $this->getUniqueID(); $multi_id = $id.'[]';
+ if($multiple)
+ $this->getPage()->registerPostDataLoader($multi_id);
+ if($this->getActiveControl()->canUpdateClientSide())
+ {
+ $client = $this->getPage()->getCallbackClient();
+ $client->setAttribute($this, 'multiple', $multiple ? 'multiple' : false);
+ $client->setAttribute($this, 'name', $multiple ? $multi_id : $id);
+ if($multiple)
+ $client->addPostDataLoader($multi_id);
+ }
+ }
+
+ /**
+ * Raises the callback event. This method is required by {@link
+ * ICallbackEventHandler} interface.
+ * This method is mainly used by framework and control developers.
+ * @param TCallbackEventParameter the event parameter
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->onCallback($param);
+ }
+
+ /**
+ * This method is invoked when a callback is requested. The method raises
+ * 'OnCallback' event to fire up the event handlers. If you override this
+ * method, be sure to call the parent implementation so that the event
+ * handler can be invoked.
+ * @param TCallbackEventParameter event parameter to be passed to the event handlers
+ */
+ public function onCallback($param)
+ {
+ $this->raiseEvent('OnCallback', $this, $param);
+ }
}
?> \ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButton.php b/framework/Web/UI/ActiveControls/TActiveRadioButton.php
index b9497051..334de3a1 100644
--- a/framework/Web/UI/ActiveControls/TActiveRadioButton.php
+++ b/framework/Web/UI/ActiveControls/TActiveRadioButton.php
@@ -14,6 +14,17 @@
/**
* TActiveRadioButton class.
*
+ * The active control counter part to radio button. The {@link setAutoPostBack AutoPostBack}
+ * property is set to true by default. Thus, when the radio button is clicked a
+ * {@link onCallback OnCallback} event is raise after {@link OnCheckedChanged} event.
+ *
+ * The {@link setText Text} and {@link setChecked Checked} properties can be
+ * changed during a callback.
+ *
+ * The {@link setGroupName GroupName} property may <b>NOT</b> be changed
+ * during callback because the client-side <tt>name</tt> attribute is read-only
+ * and can not be changed using javascript.
+ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version $Revision: $ Mon Jun 26 00:47:14 EST 2006 $
* @package System.Web.UI.ActiveControls
@@ -21,7 +32,137 @@
*/
class TActiveRadioButton extends TRadioButton implements IActiveControl, ICallbackEventHandler
{
-
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TActiveControlAdapter($this));
+ $this->setAutoPostBack(true);
+ }
+
+ /**
+ * @return TBaseActiveCallbackControl standard callback control options.
+ */
+ public function getActiveControl()
+ {
+ return $this->getAdapter()->getBaseActiveControl();
+ }
+
+ /**
+ * Raises the callback event. This method is required by {@link
+ * ICallbackEventHandler} interface.
+ * This method is mainly used by framework and control developers.
+ * @param TCallbackEventParameter the event parameter
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->onCallback($param);
+ }
+
+ /**
+ * This method is invoked when a callback is requested. The method raises
+ * 'OnCallback' event to fire up the event handlers. If you override this
+ * method, be sure to call the parent implementation so that the event
+ * handler can be invoked.
+ * @param TCallbackEventParameter event parameter to be passed to the event handlers
+ */
+ public function onCallback($param)
+ {
+ $this->raiseEvent('OnCallback', $this, $param);
+ }
+
+ /**
+ * Updates the button text on the client-side if the
+ * {@link setEnableUpdate EnableUpdate} property is set to true.
+ * @param string caption of the button
+ */
+ public function setText($value)
+ {
+ parent::setText($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->update(
+ $this->getDefaultLabelID(), $value);
+ }
+
+ /**
+ * Checks the radio button.
+ * Updates radio button checked state on the client-side if the
+ * {@link setEnableUpdate EnableUpdate} property is set to true.
+ * @param boolean whether the radio button is to be checked or not.
+ */
+ public function setChecked($value)
+ {
+ $value = TPropertyValue::ensureBoolean($value);
+ parent::setChecked($value);
+ if($value && $this->getActiveControl()->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->check($this, $value);
+ }
+
+ /**
+ * Add the group name as post data loader if group name is set.
+ */
+ protected function addToPostDataLoader()
+ {
+ parent::addToPostDataLoader();
+ $group = $this->getGroupName();
+ if(!empty($group))
+ $this->getPage()->registerPostDataLoader($group);
+ }
+
+ /**
+ * Registers the javascript code for initializing the active control.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getPostBackOptions());
+ }
+
+ /**
+ * @return string corresponding javascript class name for this TActiveRadioButton.
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TActiveRadioButton';
+ }
+
+ /**
+ * Overrides parent implementation to ensure label has ID.
+ * @return TMap list of attributes to be rendered for label beside the radio button
+ */
+ public function getLabelAttributes()
+ {
+ $attributes = parent::getLabelAttributes();
+ $attributes['id'] = $this->getDefaultLabelID();
+ return $attributes;
+ }
+
+ /**
+ * Renders a label beside the radio button.
+ * @param THtmlWriter the writer for the rendering purpose
+ * @param string radio button id
+ * @param string label text
+ */
+ protected function renderLabel($writer,$clientID,$text)
+ {
+ $writer->addAttribute('id', $this->getDefaultLabelID());
+ parent::renderLabel($writer, $clientID, $text);
+ }
+
+ /**
+ * @return string radio button label ID;
+ */
+ protected function getDefaultLabelID()
+ {
+ if($attributes=$this->getViewState('LabelAttributes',null))
+ return $this->getLabelAttributes()->itemAt('id');
+ else
+ return $this->getClientID().'_label';
+ }
}
?> \ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
index 665a8542..daaaf9aa 100644
--- a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
+++ b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
@@ -13,6 +13,15 @@
/**
* TActiveRadioButtonList class.
*
+ * The active control counter part to radio button list control.
+ * The {@link setAutoPostBack AutoPostBack} property is set to true by default.
+ * Thus, when a radio button is clicked a {@link onCallback OnCallback} event is
+ * raised after {@link OnSelectedIndexChanged} event.
+ *
+ * With {@link TBaseActiveControl::setEnableUpdate() ActiveControl.EnabledUpdate}
+ * set to true (default is true), changes to the selection will be updated
+ * on the client side.
+ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version : $ Mon Jun 26 00:48:08 EST 2006 $
* @package System.Web.UI.ActiveControls
@@ -20,6 +29,67 @@
*/
class TActiveRadioButtonList extends TRadioButtonList implements IActiveControl, ICallbackEventHandler
{
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveListControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TActiveListControlAdapter($this));
+ $this->setAutoPostBack(true);
+ }
+
+ /**
+ * @return TBaseActiveCallbackControl standard callback control options.
+ */
+ public function getActiveControl()
+ {
+ return $this->getAdapter()->getBaseActiveControl();
+ }
+
+ /**
+ * No client class for this control.
+ * This method overrides the parent implementation.
+ * @return null no javascript class name.
+ */
+ protected function getClientClassName()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a control used for repetition (used as a template).
+ * @return TControl the control to be repeated
+ */
+ protected function createRepeatedControl()
+ {
+ return new TActiveRadioButton;
+ }
+
+ /**
+ * Raises the callback event. This method is required by {@link
+ * ICallbackEventHandler} interface.
+ * This method is mainly used by framework and control developers.
+ * @param TCallbackEventParameter the event parameter
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->onCallback($param);
+ }
+
+ /**
+ * This method is invoked when a callback is requested. The method raises
+ * 'OnCallback' event to fire up the event handlers. If you override this
+ * method, be sure to call the parent implementation so that the event
+ * handler can be invoked.
+ * @param TCallbackEventParameter event parameter to be passed to the event handlers
+ */
+ public function onCallback($param)
+ {
+ $this->raiseEvent('OnCallback', $this, $param);
+ }
}
?> \ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TCallbackClientScript.php b/framework/Web/UI/ActiveControls/TCallbackClientScript.php
index 6a025802..dbfa935f 100644
--- a/framework/Web/UI/ActiveControls/TCallbackClientScript.php
+++ b/framework/Web/UI/ActiveControls/TCallbackClientScript.php
@@ -205,6 +205,11 @@ class TCallbackClientScript extends TApplicationComponent
$this->callClientFunction('Element.remove', $element);
}
+ public function addPostDataLoader($name)
+ {
+ $this->callClientFunction('Prado.CallbackRequest.addPostLoaders', $name);
+ }
+
/**
* Update the element's innerHTML with new content.
* @param TControl|string control element or element id
diff --git a/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php b/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php
index f4ad222a..8f456b86 100755
--- a/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php
+++ b/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php
@@ -86,7 +86,7 @@ class TCallbackResponseAdapter extends THttpResponseAdapter
*
* The {@link setBoundary Boundary} property sets boundary identifier in the
* HTML comment that forms the boundary. By default, the boundary identifier
- * is generated from the object instance ID.
+ * is generated using microtime.
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version $Revision: $ Sun Jun 18 08:02:21 EST 2006 $
@@ -101,11 +101,11 @@ class TCallbackResponseWriter extends TTextWriter
private $_boundary;
/**
- * Constructor. Generates boundary ID using object instance ID.
+ * Constructor. Generates unique boundary ID using microtime.
*/
public function __construct()
{
- $this->_boundary = sprintf('%x',crc32(time()));
+ $this->_boundary = sprintf('%x',crc32(microtime()));
}
/**
diff --git a/framework/Web/UI/WebControls/TLinkButton.php b/framework/Web/UI/WebControls/TLinkButton.php
index 6c318944..bcf43060 100644
--- a/framework/Web/UI/WebControls/TLinkButton.php
+++ b/framework/Web/UI/WebControls/TLinkButton.php
@@ -81,21 +81,33 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler, IButtonC
parent::addAttributesToRender($writer);
if($this->getEnabled(true))
+ {
+ $this->renderLinkButtonHref($writer);
$this->renderClientControlScript($writer);
+ }
else if($this->getEnabled()) // in this case, parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
}
/**
* Renders the client-script code.
+ * @param THtmlWriter renderer
*/
protected function renderClientControlScript($writer)
{
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions());
+ }
+
+ /**
+ * Renders the Href for link button.
+ * @param THtmlWriter renderer
+ */
+ protected function renderLinkButtonHref($writer)
+ {
//create unique no-op url references
$nop = "javascript:;//".$this->getClientID();
$writer->addAttribute('href', $nop);
- $cs = $this->getPage()->getClientScript();
- $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions());
}
/**
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveLinkButtonTest.page b/tests/FunctionalTests/active-controls/protected/pages/ActiveLinkButtonTest.page
new file mode 100644
index 00000000..cb9f0322
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveLinkButtonTest.page
@@ -0,0 +1,11 @@
+<com:TForm ID="form1">
+
+ <h1>TActiveLinkButton Functional Test</h1>
+ <com:TActiveLinkButton ID="button2" Text="Button 1"
+ OnClick="button2_onclick" OnCallback="button2_oncallback" />
+
+ <com:TActiveLabel ID="label1" Text="Label 1" />
+
+ <com:TJavascriptLogger />
+
+</com:TForm> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveLinkButtonTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveLinkButtonTest.php
new file mode 100644
index 00000000..4fc3a23e
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveLinkButtonTest.php
@@ -0,0 +1,16 @@
+<?php
+
+class ActiveLinkButtonTest extends TPage
+{
+ function button2_onclick($sender, $param)
+ {
+ $this->label1->Text = "Button 1 was clicked ";
+ }
+
+ function button2_oncallback($sender, $param)
+ {
+ $this->label1->Text .= "using callback!";
+ }
+}
+
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxTest.page b/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxTest.page
new file mode 100644
index 00000000..318d53c3
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxTest.page
@@ -0,0 +1,27 @@
+<com:TForm ID="form1">
+
+ <h1>Active List Box Functional Test</h1>
+
+ <com:TActiveListBox ID="list1" OnCallback="list1_callback" SelectionMode="Multiple" style="width:20em;height:10em">
+ <com:TListItem Value="value 1" Text="item 1" />
+ <com:TListItem Value="value 2" Text="item 2" />
+ <com:TListItem Value="value 3" Text="item 3" />
+ <com:TListItem Value="value 4" Text="item 4" />
+ <com:TListItem Value="value 5" Text="item 5" />
+ </com:TActiveListBox>
+
+ <div style="margin:1em; padding:1em; border:1px solid #ccc; text-align:center;">
+ <com:TActiveLabel ID="label1" Text="Label 1" />
+ </div>
+ <div style="margin:1em; padding:0.5em; text-align:center; border:1px solid #ccc;">
+ <com:TActiveButton ID="button1" Text="Select Index 1 2 3" OnClick="select_index_123" />
+ <com:TActiveButton ID="button2" Text="Clear selection" OnClick="clear_selections" />
+ <com:TActiveButton ID="button3" Text="Select Value 'value 1'" OnClick="select_value_1" />
+ <com:TActiveButton ID="button4" Text="Select Index 4" OnClick="select_index_4" />
+ <com:TActiveButton ID="button5" Text="Select Values 'value 2', 'value 5'" OnClick="select_values_25" />
+ <com:TActiveButton ID="button6" Text="Change to Multi-Select" OnClick="change_to_multiple" />
+ <com:TActiveButton ID="button7" Text="Change to Single-Select" OnClick="change_to_single" />
+ </div>
+
+ <com:TJavascriptLogger />
+</com:TForm> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxTest.php
new file mode 100644
index 00000000..942bb1a0
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxTest.php
@@ -0,0 +1,47 @@
+<?php
+
+class ActiveListBoxTest extends TPage
+{
+ function list1_callback($sender, $param)
+ {
+ $values = $sender->getSelectedValues();
+ $this->label1->setText("Selection: ".implode(', ', $values));
+ }
+
+ function select_index_123()
+ {
+ $this->list1->setSelectedIndices(array(1,2,3));
+ }
+
+ function select_index_4()
+ {
+ $this->list1->setSelectedIndex(4);
+ }
+
+ function clear_selections()
+ {
+ $this->list1->clearSelection();
+ }
+
+ function select_value_1()
+ {
+ $this->list1->setSelectedValue("value 1");
+ }
+
+ function select_values_25()
+ {
+ $this->list1->setSelectedValues(array('value 2', 'value 5'));
+ }
+
+ function change_to_multiple()
+ {
+ $this->list1->SelectionMode="Multiple";
+ }
+
+ function change_to_single()
+ {
+ $this->list1->SelectionMode="Single";
+ }
+}
+
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonListTest.page b/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonListTest.page
new file mode 100644
index 00000000..26feb594
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonListTest.page
@@ -0,0 +1,22 @@
+<com:TForm ID="form1">
+ <h1>TActiveRadioButtonList Test Case</h1>
+
+ <com:TActiveRadioButtonList ID="list1" OnCallback="list1_callback">
+ <com:TListItem Value="value 1" Text="item 1" />
+ <com:TListItem Value="value 2" Text="item 2" />
+ <com:TListItem Value="value 3" Text="item 3" />
+ <com:TListItem Value="value 4" Text="item 4" />
+ <com:TListItem Value="value 5" Text="item 5" />
+ </com:TActiveRadioButtonList>
+ <div style="margin:1em; padding:1em; border:1px solid #ccc; text-align:center;">
+ <com:TActiveLabel ID="label1" Text="Label 1" />
+ </div>
+ <div style="margin:1em; padding:0.5em; text-align:center; border:1px solid #ccc;">
+ <com:TActiveButton ID="button2" Text="Clear selection" OnClick="clear_selections" />
+ <com:TActiveButton ID="button3" Text="Select Value 'value 1'" OnClick="select_value_1" />
+ <com:TActiveButton ID="button4" Text="Select Index 4" OnClick="select_index_4" />
+ </div>
+
+ <com:TJavascriptLogger />
+
+</com:TForm> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonListTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonListTest.php
new file mode 100644
index 00000000..930d671b
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonListTest.php
@@ -0,0 +1,27 @@
+<?php
+
+class ActiveRadioButtonListTest extends TPage
+{
+ function list1_callback($sender, $param)
+ {
+ $values = $sender->getSelectedValues();
+ $this->label1->setText("Selection: ".implode(', ', $values));
+ }
+
+ function select_index_4()
+ {
+ $this->list1->setSelectedIndex(4);
+ }
+
+ function clear_selections()
+ {
+ $this->list1->clearSelection();
+ }
+
+ function select_value_1()
+ {
+ $this->list1->setSelectedValue("value 1");
+ }
+}
+
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonTest.page b/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonTest.page
new file mode 100644
index 00000000..c5c40c44
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonTest.page
@@ -0,0 +1,38 @@
+<com:TForm ID="form1">
+ <h1>Active Radio Button Test</h1>
+ <com:TActiveRadioButton ID="radio1"
+ GroupName="group1" Text="Radio Button 1"
+ OnCallback="radiobutton_requested"/>
+ <com:TActiveRadioButton ID="radio2"
+ GroupName="group1" Text="Radio Button 2"
+ OnCallback="radiobutton_requested">
+ <prop:ActiveControl.ClientSide OnLoading="$('status').show()" OnComplete="$('status').hide()" />
+ </com:TActiveRadioButton>
+ <com:TActiveRadioButton ID="radio3"
+ Text="Radio Button 3"
+ OnCallback="radiobutton_requested" />
+ <div style="margin:1em; padding:0.5em; text-align:center; border:1px solid #ccc;">
+ <com:TActiveLabel ID="label1" Text="Label 1" />
+ </div>
+ <div style="margin:1em; padding: 1em; text-align: center">
+ <com:TActiveButton id="change_text1"
+ OnClick="change_radio1_text" Text="Change Radio Button 1 Text"/>
+ <com:TActiveButton id="change_radio1"
+ OnClick="change_radio1_checked" Text="Check Radio Button 1"/>
+
+ <com:TActiveButton id="change_text2"
+ OnClick="change_radio2_text" Text="Change Radio Button 2 Text"/>
+ <com:TActiveButton id="change_radio2"
+ OnClick="change_radio2_checked" Text="Check Radio Button 2"/>
+
+ </div>
+
+ <div id="status" style="margin:1em; padding:0.5em;
+ text-align:center;
+ background-color:#900;
+ color:white; display: none;
+ position: absolute; right: 0; top: 0">
+ Loading...
+ </div>
+ <com:TJavascriptLogger />
+</com:TForm> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonTest.php
new file mode 100644
index 00000000..64e7d92e
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonTest.php
@@ -0,0 +1,34 @@
+<?php
+
+class ActiveRadioButtonTest extends TPage
+{
+ function change_radio1_text()
+ {
+ $this->radio1->Text = "Hello Radio Button 1";
+ }
+
+ function change_radio1_checked()
+ {
+ $this->radio1->Checked = !$this->radio1->Checked;
+ }
+
+ function change_radio2_text()
+ {
+ $this->radio2->Text = "Radio Button 2 World";
+ }
+
+ function change_radio2_checked()
+ {
+ $this->radio2->Checked = !$this->radio2->Checked;
+ }
+
+ function radiobutton_requested($sender, $param)
+ {
+ $this->label1->Text = "Label 1:".$sender->Text.
+ ($sender->checked ? ' Checked ' : ' Not Checked');
+ }
+
+
+}
+
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.page b/tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.page
index b0c22587..7842cde9 100644
--- a/tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.page
+++ b/tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.page
@@ -9,7 +9,16 @@ Main Panel
</com:TPanel>
</com:TPanel>
+<com:TPanel ID="newPanel" Visible="false">
+ Time : <com:TButton Text=<%= time() %> />
+</com:TPanel>
+
+<div>
<com:TTextBox ID="content" />
+<br />
+<com:TCheckBox ID="check1" Text="Replace using Controls" />
+</div>
+
<com:TActiveButton id="btn_append" Text="Append to Sub Panel" OnCallback="appendContent"/>
<com:TActiveButton id="btn_prepend" Text="Prepend to Sub Panel" OnCallback="prependContent" />
<com:TActiveButton id="btn_before" Text="Insert Before Sub Panel" OnCallback="insertContentBefore"/>
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.php b/tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.php
index 0e09a012..a5358d98 100644
--- a/tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.php
+++ b/tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.php
@@ -4,27 +4,38 @@ class ReplaceContentTest extends TPage
{
function appendContent($sender, $param)
{
- $this->CallbackClient->appendContent($this->subpanel, $this->content->Text);
+ $this->CallbackClient->appendContent($this->subpanel, $this->replacementContent());
}
function prependContent($sender, $param)
{
- $this->CallbackClient->prependContent($this->subpanel, $this->content->Text);
+ $this->CallbackClient->prependContent($this->subpanel, $this->replacementContent());
}
function insertContentBefore($sender, $param)
{
- $this->CallbackClient->insertContentBefore($this->subpanel, $this->content->Text);
+ $this->CallbackClient->insertContentBefore($this->subpanel, $this->replacementContent());
}
function insertContentAfter($sender, $param)
{
- $this->CallbackClient->insertContentAfter($this->subpanel, $this->content->Text);
+ $this->CallbackClient->insertContentAfter($this->subpanel, $this->replacementContent());
}
function replaceContent($sender, $param)
{
- $this->CallbackClient->replaceContent($this->subpanel, $this->content->Text);
+ $this->CallbackClient->replaceContent($this->subpanel, $this->replacementContent());
+ }
+
+ function replacementContent()
+ {
+ if($this->check1->Checked)
+ {
+ $this->newPanel->Visible=true;
+ return $this->newPanel;
+ }
+ else
+ return $this->content->Text;
}
}
diff --git a/tests/FunctionalTests/active-controls/tests/ActiveButtonTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveButtonTestCase.php
index 0a294906..a8795de5 100644
--- a/tests/FunctionalTests/active-controls/tests/ActiveButtonTestCase.php
+++ b/tests/FunctionalTests/active-controls/tests/ActiveButtonTestCase.php
@@ -8,7 +8,7 @@ class ActiveButtonTestCase extends SeleniumTestCase
$this->verifyTextPresent("TActiveButton Functional Test");
$this->assertText("label1", "Label 1");
$this->click("button2");
- $this->pause(500);
+ $this->pause(800);
$this->assertText("label1", "Button 1 was clicked using callback!");
}
}
diff --git a/tests/FunctionalTests/active-controls/tests/ActiveCheckBoxListTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveCheckBoxListTestCase.php
index af7ea1f0..a66cf853 100644
--- a/tests/FunctionalTests/active-controls/tests/ActiveCheckBoxListTestCase.php
+++ b/tests/FunctionalTests/active-controls/tests/ActiveCheckBoxListTestCase.php
@@ -6,42 +6,42 @@ class ActiveCheckBoxListTestCase extends SeleniumTestCase
{
$this->open("active-controls/index.php?page=TActiveCheckBoxListTest");
$this->verifyTextPresent("TActiveCheckBoxList Test Case");
-
+
$this->assertText("label1", "Label 1");
-
+
$this->click("button1");
- $this->pause(500);
+ $this->pause(800);
$this->assertCheckBoxes(array(1,2,3));
-
+
$this->click("button2");
- $this->pause(500);
+ $this->pause(800);
$this->assertCheckBoxes(array());
-
-
+
+
$this->click("button3");
- $this->pause(500);
+ $this->pause(800);
$this->assertCheckBoxes(array(0));
-
-
+
+
$this->click("button4");
- $this->pause(500);
+ $this->pause(800);
$this->assertCheckBoxes(array(4));
-
-
+
+
$this->click("button5");
- $this->pause(500);
+ $this->pause(800);
$this->assertCheckBoxes(array(1,4));
-
+
$this->click("list1_c2");
- $this->pause(500);
- $this->assertText("label1", "Selection: value 2, value 3, value 5");
+ $this->pause(800);
+ $this->assertText("label1", "Selection: value 2, value 3, value 5");
$this->click("list1_c2");
- $this->pause(500);
- $this->assertText("label1", "Selection: value 2, value 5");
+ $this->pause(800);
+ $this->assertText("label1", "Selection: value 2, value 5");
}
-
+
function assertCheckBoxes($checks, $total = 5)
{
for($i = 0; $i < $total; $i++)
diff --git a/tests/FunctionalTests/active-controls/tests/ActiveCheckBoxTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveCheckBoxTestCase.php
index 30dda753..6bf00f05 100644
--- a/tests/FunctionalTests/active-controls/tests/ActiveCheckBoxTestCase.php
+++ b/tests/FunctionalTests/active-controls/tests/ActiveCheckBoxTestCase.php
@@ -6,55 +6,55 @@ class ActiveCheckBoxTestCase extends SeleniumTestCase
{
$this->open("active-controls/index.php?page=ActiveCheckBoxTest");
$this->verifyTextPresent("Active CheckBox Test");
-
+
$this->assertText("checkbox1_label", "CheckBox 1");
$this->assertText("checkbox2_label", "CheckBox 2");
$this->assertText('label1', 'Label 1');
-
+
$this->click("change_text1");
- $this->pause(500);
+ $this->pause(800);
$this->assertText('checkbox1_label', 'Hello CheckBox 1');
-
+
$this->click("change_text2");
- $this->pause(500);
+ $this->pause(800);
$this->assertText('checkbox2_label', 'CheckBox 2 World');
-
+
//check box 1
$this->click('change_checked1');
- $this->pause(500);
+ $this->pause(800);
$this->assertChecked('checkbox1');
-
+
$this->click('change_checked1');
- $this->pause(500);
+ $this->pause(800);
$this->assertNotChecked('checkbox1');
//check box 2
$this->click('change_checked2');
- $this->pause(500);
+ $this->pause(800);
$this->assertChecked('checkbox2');
-
+
$this->click('change_checked2');
- $this->pause(500);
+ $this->pause(800);
$this->assertNotChecked('checkbox2');
-
+
//click checkbox 1
$this->click("checkbox1");
- $this->pause(500);
+ $this->pause(800);
$this->assertText("label1", "Label 1:Hello CheckBox 1 Checked");
-
+
$this->click("checkbox1");
- $this->pause(500);
+ $this->pause(800);
$this->assertText("label1", "Label 1:Hello CheckBox 1 Not Checked");
-
+
//click checkbox 2
$this->click("checkbox2");
- $this->pause(500);
+ $this->pause(800);
$this->assertText("label1", "Label 1:CheckBox 2 World Checked");
-
+
$this->click("checkbox2");
- $this->pause(500);
+ $this->pause(800);
$this->assertText("label1", "Label 1:CheckBox 2 World Not Checked");
-
+
}
}
diff --git a/tests/FunctionalTests/active-controls/tests/ActiveDropDownListTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveDropDownListTestCase.php
index 5806a3ec..9d3ad9c3 100644
--- a/tests/FunctionalTests/active-controls/tests/ActiveDropDownListTestCase.php
+++ b/tests/FunctionalTests/active-controls/tests/ActiveDropDownListTestCase.php
@@ -6,33 +6,33 @@ class ActiveDropDownListTestCase extends SeleniumTestCase
{
$this->open("active-controls/index.php?page=ActiveDropDownList");
$this->assertTextPresent('Active Drop Down List Test Case');
-
+
$this->assertText("label1", "Label 1");
-
+
$this->click("button1");
- $this->pause(500);
+ $this->pause(800);
$this->assertSelected("list1", "item 4");
-
+
$this->click("button2");
- $this->pause(500);
+ $this->pause(800);
$this->assertEmptySelection("list1");
-
+
$this->click("button3");
- $this->pause(500);
+ $this->pause(800);
$this->assertSelected("list1", "item 2");
-
+
// due to clearing selection and then updating the selection
// otherwise it should not fire the changed event (fired by js because of change to options).
- $this->assertText("label1", "Selection 1: value 1");
-
+ $this->assertText("label1", "Selection 1: value 1");
+
$this->select("list2", "value 1 - item 4");
- $this->pause(500);
+ $this->pause(800);
$this->assertText("label1", "Selection 2: value 1 - item 4");
-
+
$this->select("list1", "item 3");
- $this->pause(500);
+ $this->pause(800);
$this->select("list2", "value 3 - item 5");
- $this->pause(500);
+ $this->pause(800);
$this->assertText("label1", "Selection 2: value 3 - item 5");
}
diff --git a/tests/FunctionalTests/active-controls/tests/ActiveHyperLinkTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveHyperLinkTestCase.php
index 53198806..6707a442 100644
--- a/tests/FunctionalTests/active-controls/tests/ActiveHyperLinkTestCase.php
+++ b/tests/FunctionalTests/active-controls/tests/ActiveHyperLinkTestCase.php
@@ -6,11 +6,11 @@ class ActiveHyperLinkTestCase extends SeleniumTestCase
{
$this->open("active-controls/index.php?page=ActiveHyperLinkTest");
$this->assertTextPresent("Active HyperLink Test Case");
-
+
$this->assertText("link1", "Link 1");
-
+
$this->click("button1");
- $this->pause(500);
+ $this->pause(800);
$this->assertText("link1", "Pradosoft.com");
}
}
diff --git a/tests/FunctionalTests/active-controls/tests/ActiveLinkButtonTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveLinkButtonTestCase.php
new file mode 100644
index 00000000..305a5c93
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/tests/ActiveLinkButtonTestCase.php
@@ -0,0 +1,16 @@
+<?php
+
+class ActiveLinkButtonTestCase extends SeleniumTestCase
+{
+ function test()
+ {
+ $this->open("active-controls/index.php?page=ActiveLinkButtonTest");
+ $this->verifyTextPresent("TActiveLinkButton Functional Test");
+ $this->assertText("label1", "Label 1");
+ $this->click("button2");
+ $this->pause(800);
+ $this->assertText("label1", "Button 1 was clicked using callback!");
+ }
+}
+
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/tests/ActiveListBoxTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveListBoxTestCase.php
new file mode 100644
index 00000000..24f8099d
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/tests/ActiveListBoxTestCase.php
@@ -0,0 +1,53 @@
+<?php
+
+class ActiveListBoxTestCase extends SeleniumTestCase
+{
+ function test()
+ {
+ $this->open("active-controls/index.php?page=ActiveListBoxTest");
+ $this->assertTextPresent('Active List Box Functional Test');
+
+ $this->assertText("label1", "Label 1");
+
+ $this->click("button1");
+ $this->pause(800);
+ $this->assertSelectedIndexes('list1', '1,2,3');
+
+ $this->click('button3');
+ $this->pause(800);
+ $this->assertSelectedIndexes('list1', '0');
+
+ $this->click('button4');
+ $this->pause(800);
+ $this->assertSelectedIndexes('list1', '4');
+
+ $this->click('button5');
+ $this->pause(800);
+ $this->assertSelectedIndexes('list1', '1,4');
+
+ $this->click('button2');
+ $this->pause(800);
+ $this->assertEmptySelection("list1");
+
+ $this->click('button7');
+ $this->pause(800);
+ $this->click("button1");
+ $this->pause(800);
+ $this->assertSelectedIndexes('list1', '3');
+
+ $this->click('button6');
+ $this->pause(800);
+ $this->click("button1");
+ $this->pause(800);
+ $this->assertSelectedIndexes('list1', '1,2,3');
+
+ $this->select("list1", "item 1");
+ $this->pause(800);
+ $this->assertText('label1', 'Selection: value 1');
+
+ $this->addSelection("list1", "item 4");
+ $this->pause(800);
+ $this->assertText('label1', 'Selection: value 1, value 4');
+ }
+}
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/tests/ActivePanelTestCase.php b/tests/FunctionalTests/active-controls/tests/ActivePanelTestCase.php
index a9fb6c4e..4c8fd3c6 100644
--- a/tests/FunctionalTests/active-controls/tests/ActivePanelTestCase.php
+++ b/tests/FunctionalTests/active-controls/tests/ActivePanelTestCase.php
@@ -8,7 +8,7 @@ class ActivePanelTestCase extends SeleniumTestCase
$this->verifyTextPresent("Active Panel replacement tests");
$this->assertTextNotPresent('Something lalala');
$this->click("div1");
- $this->pause(500);
+ $this->pause(800);
$this->assertTextPresent("Something lalala");
}
}
diff --git a/tests/FunctionalTests/active-controls/tests/ActiveRadioButtonListTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveRadioButtonListTestCase.php
new file mode 100644
index 00000000..386caa55
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/tests/ActiveRadioButtonListTestCase.php
@@ -0,0 +1,47 @@
+<?php
+
+class ActiveRadioButtonListTestCase extends SeleniumTestCase
+{
+ function test()
+ {
+ $this->open("active-controls/index.php?page=ActiveRadioButtonListTest");
+ $this->verifyTextPresent("TActiveRadioButtonList Test Case");
+
+ $this->assertText("label1", "Label 1");
+
+
+ $this->click("button3");
+ $this->pause(800);
+ $this->assertCheckBoxes(array(0));
+
+ $this->click("button2");
+ $this->pause(800);
+ $this->assertCheckBoxes(array());
+
+ $this->click("button4");
+ $this->pause(800);
+ $this->assertCheckBoxes(array(4));
+
+ $this->click("list1_c2");
+ $this->pause(800);
+ $this->assertText("label1", "Selection: value 3");
+
+ $this->click("list1_c3");
+ $this->pause(800);
+ $this->assertText("label1", "Selection: value 4");
+
+ }
+
+ function assertCheckBoxes($checks, $total = 5)
+ {
+ for($i = 0; $i < $total; $i++)
+ {
+ if(in_array($i, $checks))
+ $this->assertChecked("list1_c{$i}");
+ else
+ $this->assertNotChecked("list1_c{$i}");
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/tests/ActiveRadioButtonTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveRadioButtonTestCase.php
new file mode 100644
index 00000000..c21426cb
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/tests/ActiveRadioButtonTestCase.php
@@ -0,0 +1,54 @@
+<?php
+
+class ActiveRadioButtonTestCase extends SeleniumTestCase
+{
+ function test()
+ {
+ $this->open("active-controls/index.php?page=ActiveRadioButtonTest");
+ $this->verifyTextPresent("Active Radio Button Test");
+ $this->assertText('label1', 'Label 1');
+
+ $this->assertNotChecked('radio1');
+ $this->assertNotChecked('radio2');
+ $this->assertNotChecked('radio3');
+
+ $this->assertText('radio1_label', 'Radio Button 1');
+ $this->assertText('radio2_label', 'Radio Button 2');
+ $this->assertText('radio3_label', 'Radio Button 3');
+
+ $this->click('change_text1');
+ $this->pause(800);
+ $this->assertText('radio1_label', 'Hello Radio Button 1');
+ $this->assertText('radio2_label', 'Radio Button 2');
+ $this->assertText('radio3_label', 'Radio Button 3');
+
+ $this->click('change_text2');
+ $this->pause(800);
+ $this->assertText('radio1_label', 'Hello Radio Button 1');
+ $this->assertText('radio2_label', 'Radio Button 2 World');
+ $this->assertText('radio3_label', 'Radio Button 3');
+
+ $this->click('change_radio1');
+ $this->pause(800);
+ $this->assertChecked('radio1');
+ $this->assertNotChecked('radio2');
+ $this->assertNotChecked('radio3');
+
+ $this->click('change_radio2');
+ $this->pause(800);
+ $this->assertNotChecked('radio1');
+ $this->assertChecked('radio2');
+ $this->assertNotChecked('radio3');
+
+
+ $this->click('radio3');
+ $this->pause(800);
+ $this->assertNotChecked('radio1');
+ $this->assertChecked('radio2');
+ $this->assertChecked('radio3');
+ $this->assertText('label1', 'Label 1:Radio Button 3 Checked');
+
+
+ }
+}
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/tests/AutoCompleteTestCase.php b/tests/FunctionalTests/active-controls/tests/AutoCompleteTestCase.php
index f8b4cf55..cb1a6604 100644
--- a/tests/FunctionalTests/active-controls/tests/AutoCompleteTestCase.php
+++ b/tests/FunctionalTests/active-controls/tests/AutoCompleteTestCase.php
@@ -6,15 +6,15 @@ class AutoCompleteTestCase extends SeleniumTestCase
{
$this->open("active-controls/index.php?page=AutoCompleteTest");
$this->verifyTextPresent("TAutoComplete Test");
-
+
$this->assertText("label1", "Label 1");
$this->type("textbox3", "Australia");
- $this->pause(500);
+ $this->pause(800);
$this->click("heading"); //click somewhere else.
- $this->pause(500);
+ $this->pause(800);
$this->assertText("label1", "Label 1: Australia");
-
+
}
}
diff --git a/tests/FunctionalTests/active-controls/tests/CallbackAdapterTestCase.php b/tests/FunctionalTests/active-controls/tests/CallbackAdapterTestCase.php
index 3a3b292c..e49eb513 100644
--- a/tests/FunctionalTests/active-controls/tests/CallbackAdapterTestCase.php
+++ b/tests/FunctionalTests/active-controls/tests/CallbackAdapterTestCase.php
@@ -6,26 +6,26 @@ class CallbackAdapterTestCase extends SeleniumTestCase
{
$this->open("active-controls/index.php?page=ControlAdapterTest");
$this->assertTextPresent('Control Adapter - State Tracking Tests');
-
+
$this->click('button2');
$this->assertAlert('ok');
-
+
$this->click('test6');
- $this->pause(500);
+ $this->pause(800);
$this->click('test7');
- $this->pause(500);
+ $this->pause(800);
$this->click('test8');
- $this->pause(500);
+ $this->pause(800);
$this->click('test9');
- $this->pause(500);
-
+ $this->pause(800);
+
$this->click('button1');
$this->assertAlert('haha!');
-
+
$this->click('button2');
$this->assertAlert('ok');
$this->assertAlert('baz!');
-
+
}
}
diff --git a/tests/FunctionalTests/active-controls/tests/CallbackOptionsTestCase.php b/tests/FunctionalTests/active-controls/tests/CallbackOptionsTestCase.php
index d72499cf..39fa5ec9 100644
--- a/tests/FunctionalTests/active-controls/tests/CallbackOptionsTestCase.php
+++ b/tests/FunctionalTests/active-controls/tests/CallbackOptionsTestCase.php
@@ -6,25 +6,25 @@ class CallbackOptionsTestCase extends SeleniumTestCase
{
$this->open("active-controls/index.php?page=CallbackOptionsTest");
$this->verifyTextPresent("TCallbackOptions Test");
-
+
$this->assertText("label1", "Label 1");
$this->assertText("label2", "Label 2");
$this->assertText("label3", "Label 3");
-
+
$this->click("button1");
- $this->pause(500);
+ $this->pause(800);
$this->assertText("label1", "Button 1 has returned");
$this->assertText("label2", "Label 2");
$this->assertText("label3", "Label 3");
$this->click("button2");
- $this->pause(500);
+ $this->pause(800);
$this->assertText("label1", "Button 1 has returned");
$this->assertText("label2", "Button 2 has returned");
$this->assertText("label3", "Label 3");
$this->click("button3");
- $this->pause(500);
+ $this->pause(800);
$this->assertText("label1", "Button 1 has returned");
$this->assertText("label2", "Button 2 has returned");
$this->assertText("label3", "Button 3 has returned");
diff --git a/tests/FunctionalTests/active-controls/tests/CustomTemplateTestCase.php b/tests/FunctionalTests/active-controls/tests/CustomTemplateTestCase.php
index b927b3e9..9cde186a 100644
--- a/tests/FunctionalTests/active-controls/tests/CustomTemplateTestCase.php
+++ b/tests/FunctionalTests/active-controls/tests/CustomTemplateTestCase.php
@@ -10,7 +10,7 @@ class CustomTemplateTestCase extends SeleniumTestCase
$this->type('foo', 'Foo Bar!');
$this->click('button2');
- $this->pause(500);
+ $this->pause(800);
$this->assertVisible('ctl1_ThePanel');
$this->assertTextPresent('Client ID: ctl1_ThePanel');
diff --git a/tests/FunctionalTests/active-controls/tests/NestedActiveControlsTestCase.php b/tests/FunctionalTests/active-controls/tests/NestedActiveControlsTestCase.php
index 8d0cfb87..f19773ff 100644
--- a/tests/FunctionalTests/active-controls/tests/NestedActiveControlsTestCase.php
+++ b/tests/FunctionalTests/active-controls/tests/NestedActiveControlsTestCase.php
@@ -9,18 +9,18 @@ class NestedActiveControlsTestCase extends SeleniumTestCase
$this->assertText("label1", "Label 1");
$this->assertText("label2", "Label 2");
$this->assertTextNotPresent("Label 3");
-
+
$this->click("div1");
- $this->pause(500);
+ $this->pause(800);
$this->assertTextPresent("Something lalala");
$this->assertText("label3", "Label 3");
-
+
$this->click("button1");
- $this->pause(500);
+ $this->pause(800);
$this->assertText("label1", "Label 1: Button 1 Clicked");
$this->assertText("label2", "Label 2: Button 1 Clicked");
$this->assertText("label3", "Label 3: Button 1 Clicked");
- }
+ }
}
?> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/tests/ReplaceContentTestCase.php b/tests/FunctionalTests/active-controls/tests/ReplaceContentTestCase.php
index de4cbc71..be0d0645 100644
--- a/tests/FunctionalTests/active-controls/tests/ReplaceContentTestCase.php
+++ b/tests/FunctionalTests/active-controls/tests/ReplaceContentTestCase.php
@@ -13,14 +13,14 @@ class ReplaceContentTestCase extends SeleniumTestCase
$this->type('content', 'something');
$this->click('btn_append');
- $this->pause(500);
+ $this->pause(800);
$this->assertText('subpanel', 'Sub Panel something');
$this->assertText('panel1', 'Main Panel Sub Panel something');
$this->type('content', 'more');
$this->click('btn_prepend');
- $this->pause(500);
+ $this->pause(800);
$this->assertText('subpanel', 'more Sub Panel something');
$this->assertText('panel1', 'Main Panel more Sub Panel something');
@@ -28,14 +28,14 @@ class ReplaceContentTestCase extends SeleniumTestCase
$this->type('content', 'prado');
$this->click('btn_before');
- $this->pause(500);
+ $this->pause(800);
$this->assertText('subpanel', 'more Sub Panel something');
$this->assertText('panel1', 'Main Panel pradomore Sub Panel something');
$this->type('content', ' php ');
$this->click('btn_after');
- $this->pause(500);
+ $this->pause(800);
$this->type('content', 'mauahahaha');
$this->click('btn_replace');
diff --git a/tests/FunctionalTests/active-controls/tests/TextBoxCallbackTestCase.php b/tests/FunctionalTests/active-controls/tests/TextBoxCallbackTestCase.php
index 24cba49b..6e5a06be 100644
--- a/tests/FunctionalTests/active-controls/tests/TextBoxCallbackTestCase.php
+++ b/tests/FunctionalTests/active-controls/tests/TextBoxCallbackTestCase.php
@@ -7,9 +7,9 @@ class TextBoxCallbackTestCase extends SeleniumTestCase
$this->open("active-controls/index.php?page=ActiveTextBoxCallback");
$this->verifyTextPresent("ActiveTextBox Callback Test");
$this->assertText("label1", "Label 1");
-
+
$this->type("textbox1", "hello!");
- $this->pause(500);
+ $this->pause(800);
$this->assertText("label1", "Label 1: hello!");
}
}
diff --git a/tests/FunctionalTests/active-controls/tests/TextBoxGroupValidationTestCase.php b/tests/FunctionalTests/active-controls/tests/TextBoxGroupValidationTestCase.php
index b0950cbc..aff9a1b2 100644
--- a/tests/FunctionalTests/active-controls/tests/TextBoxGroupValidationTestCase.php
+++ b/tests/FunctionalTests/active-controls/tests/TextBoxGroupValidationTestCase.php
@@ -16,7 +16,7 @@ class TextBoxGroupValidationTestCase extends SeleniumTestCase
$this->assertNotVisible('validator1');
- $this->pause(500);
+ $this->pause(800);
$this->assertValue('City', 'City: Sydney Zip: 2000');
}
}