From 887da1b3668499821f046665b461aeadb0a9fb2e Mon Sep 17 00:00:00 2001
From: wei <>
Date: Sun, 27 Aug 2006 04:18:31 +0000
Subject: Adding TActiveImage and TActiveImageButton
---
.gitattributes | 7 +-
framework/Web/Javascripts/js/ajax.js | 11 +-
framework/Web/Javascripts/js/prado.js | 10 +-
framework/Web/Javascripts/prado/activecontrols3.js | 16 +-
framework/Web/Javascripts/prado/ajax3.js | 4 +-
framework/Web/Javascripts/prado/controls.js | 55 ++--
framework/Web/UI/ActiveControls/TActiveButton.php | 26 +-
.../Web/UI/ActiveControls/TActiveCheckBox.php | 38 +--
.../Web/UI/ActiveControls/TActiveCheckBoxList.php | 26 +-
.../UI/ActiveControls/TActiveControlAdapter.php | 126 +++++----
.../Web/UI/ActiveControls/TActiveDropDownList.php | 36 +--
.../Web/UI/ActiveControls/TActiveHyperLink.php | 22 +-
framework/Web/UI/ActiveControls/TActiveImage.php | 70 ++++-
.../Web/UI/ActiveControls/TActiveImageButton.php | 139 +++++++++-
framework/Web/UI/ActiveControls/TActiveLabel.php | 14 +-
.../Web/UI/ActiveControls/TActiveLinkButton.php | 2 +-
framework/Web/UI/ActiveControls/TActiveListBox.php | 2 +-
.../ActiveControls/TActiveListControlAdapter.php | 46 ++--
.../Web/UI/ActiveControls/TActivePageAdapter.php | 86 +++---
framework/Web/UI/ActiveControls/TActivePanel.php | 4 +-
.../Web/UI/ActiveControls/TActiveRadioButton.php | 2 +-
.../UI/ActiveControls/TActiveRadioButtonList.php | 2 +-
framework/Web/UI/ActiveControls/TActiveTextBox.php | 14 +-
framework/Web/UI/ActiveControls/TAutoComplete.php | 105 +++----
.../Web/UI/ActiveControls/TBaseActiveControl.php | 20 +-
framework/Web/UI/ActiveControls/TCallback.php | 18 +-
.../UI/ActiveControls/TCallbackClientScript.php | 2 +-
.../Web/UI/ActiveControls/TCallbackClientSide.php | 304 +++++++++++++++++++++
.../ActiveControls/TCallbackClientSideOptions.php | 304 ---------------------
.../Web/UI/ActiveControls/TCallbackOptions.php | 24 +-
.../UI/ActiveControls/TCallbackResponseAdapter.php | 6 +-
.../UI/ActiveControls/TEventTriggeredCallback.php | 24 ++
.../Web/UI/ActiveControls/TPeriodicCallback.php | 147 ----------
.../UI/ActiveControls/TTimeTriggeredCallback.php | 147 ++++++++++
.../Web/UI/ActiveControls/TTriggeredCallback.php | 21 ++
.../UI/ActiveControls/TValueTriggeredCallback.php | 29 ++
framework/Web/UI/TControl.php | 12 +-
.../protected/pages/ActiveButtonTest.page | 10 +-
.../protected/pages/ActiveButtonTest.php | 7 +-
.../protected/pages/ActiveImageButtonTest.page | 24 ++
.../protected/pages/ActiveImageButtonTest.php | 31 +++
.../protected/pages/ActivePanelTest.php | 2 +-
.../protected/pages/AutoCompleteTest.php | 10 +-
.../protected/pages/CustomTemplateControlTest.php | 2 +-
.../protected/pages/NestedActiveControls.php | 2 +-
.../protected/pages/PeriodicCallbackTest.page | 21 --
.../protected/pages/PeriodicCallbackTest.php | 27 --
.../protected/pages/TimeTriggeredCallbackTest.page | 21 ++
.../protected/pages/TimeTriggeredCallbackTest.php | 27 ++
.../active-controls/protected/pages/group.gif | Bin 0 -> 606 bytes
.../active-controls/protected/pages/report.gif | Bin 0 -> 402 bytes
.../tests/ActiveImageButtonTestCase.php | 17 ++
.../tests/PeriodicCallbackTestCase.php | 21 --
.../tests/TimeTriggeredCallbackTestCase.php | 21 ++
54 files changed, 1286 insertions(+), 878 deletions(-)
create mode 100644 framework/Web/UI/ActiveControls/TCallbackClientSide.php
delete mode 100644 framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php
delete mode 100644 framework/Web/UI/ActiveControls/TPeriodicCallback.php
create mode 100644 framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php
create mode 100644 tests/FunctionalTests/active-controls/protected/pages/ActiveImageButtonTest.page
create mode 100644 tests/FunctionalTests/active-controls/protected/pages/ActiveImageButtonTest.php
delete mode 100644 tests/FunctionalTests/active-controls/protected/pages/PeriodicCallbackTest.page
delete mode 100644 tests/FunctionalTests/active-controls/protected/pages/PeriodicCallbackTest.php
create mode 100644 tests/FunctionalTests/active-controls/protected/pages/TimeTriggeredCallbackTest.page
create mode 100644 tests/FunctionalTests/active-controls/protected/pages/TimeTriggeredCallbackTest.php
create mode 100644 tests/FunctionalTests/active-controls/protected/pages/group.gif
create mode 100644 tests/FunctionalTests/active-controls/protected/pages/report.gif
create mode 100644 tests/FunctionalTests/active-controls/tests/ActiveImageButtonTestCase.php
delete mode 100644 tests/FunctionalTests/active-controls/tests/PeriodicCallbackTestCase.php
create mode 100644 tests/FunctionalTests/active-controls/tests/TimeTriggeredCallbackTestCase.php
diff --git a/.gitattributes b/.gitattributes
index 11f87750..bd659c75 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1747,7 +1747,7 @@ framework/Web/UI/ActiveControls/TAutoComplete.php -text
framework/Web/UI/ActiveControls/TBaseActiveControl.php -text
framework/Web/UI/ActiveControls/TCallback.php -text
framework/Web/UI/ActiveControls/TCallbackClientScript.php -text
-framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php -text
+framework/Web/UI/ActiveControls/TCallbackClientSide.php -text
framework/Web/UI/ActiveControls/TCallbackOptions.php -text
framework/Web/UI/ActiveControls/TEventTriggeredCallback.php -text
framework/Web/UI/ActiveControls/TTriggeredCallback.php -text
@@ -1858,6 +1858,8 @@ requirements/messages.txt -text
requirements/template-bg.html -text
requirements/template-zh.html -text
requirements/template.html -text
+tests/FunctionalTests/active-controls/protected/pages/ActiveImageButtonTest.page -text
+tests/FunctionalTests/active-controls/protected/pages/ActiveImageButtonTest.php -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
@@ -1878,6 +1880,9 @@ tests/FunctionalTests/active-controls/protected/pages/TextBoxValidationCallback.
tests/FunctionalTests/active-controls/protected/pages/TextBoxValidationCallback.php -text
tests/FunctionalTests/active-controls/protected/pages/ValueTriggerCallbackTest.page -text
tests/FunctionalTests/active-controls/protected/pages/ValueTriggerCallbackTest.php -text
+tests/FunctionalTests/active-controls/protected/pages/group.gif -text
+tests/FunctionalTests/active-controls/protected/pages/report.gif -text
+tests/FunctionalTests/active-controls/tests/ActiveImageButtonTestCase.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
diff --git a/framework/Web/Javascripts/js/ajax.js b/framework/Web/Javascripts/js/ajax.js
index 95869ade..5d929f77 100644
--- a/framework/Web/Javascripts/js/ajax.js
+++ b/framework/Web/Javascripts/js/ajax.js
@@ -23,10 +23,10 @@ setTimeout(this.onComplete.bind(this),10);}}});Ajax.PeriodicalUpdater=Class.crea
this.timer=setTimeout(this.onTimerEvent.bind(this),this.decay*this.frequency*1000);},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options);}});Object.extend(Ajax.Request.prototype,{respondToReadyState:function(readyState)
{var event=Ajax.Request.Events[readyState];var transport=this.transport,json=this.getHeaderData(Prado.CallbackRequest.DATA_HEADER);if(event=='Complete')
{try
-{Prado.CallbackRequest.updatePageState(this,transport);Ajax.Responders.dispatch('on'+transport.status,this,transport,json);Prado.CallbackRequest.dispatchActions(transport,this.getHeaderData(Prado.CallbackRequest.ACTION_HEADER));(this.options['on'+this.transport.status]||this.options['on'+(this.responseIsSuccess()?'Success':'Failure')]||Prototype.emptyFunction)(transport,json);}catch(e){this.dispatchException(e);}
+{Prado.CallbackRequest.updatePageState(this,transport);Ajax.Responders.dispatch('on'+transport.status,this,transport,json);Prado.CallbackRequest.dispatchActions(transport,this.getHeaderData(Prado.CallbackRequest.ACTION_HEADER));(this.options['on'+this.transport.status]||this.options['on'+(this.responseIsSuccess()?'Success':'Failure')]||Prototype.emptyFunction)(this,json);}catch(e){this.dispatchException(e);}
if((this.header('Content-type')||'').match(/^text\/javascript/i))
this.evalResponse();}
-try{(this.options['on'+event]||Prototype.emptyFunction)(transport,json);Ajax.Responders.dispatch('on'+event,this,transport,json);}catch(e){this.dispatchException(e);}
+try{(this.options['on'+event]||Prototype.emptyFunction)(this,json);Ajax.Responders.dispatch('on'+event,this,transport,json);}catch(e){this.dispatchException(e);}
if(event=='Complete')
this.transport.onreadystatechange=Prototype.emptyFunction;},getHeaderData:function(name)
{try
@@ -200,7 +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.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();Event.stop(event);}});Prado.WebUI.TActiveButton=Class.extend(Prado.WebUI.CallbackControl);Prado.WebUI.TActiveLinkButton=Class.extend(Prado.WebUI.CallbackControl);Prado.WebUI.TActiveImageButton=Class.extend(Prado.WebUI.TImageButton,{onPostBack:function(event,options)
+{this.addXYInput(event,options);request=new Prado.CallbackRequest(options.EventTarget,options);request.dispatch();Event.stop(event);}});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)
@@ -212,9 +213,9 @@ this.onInit(options);},doCallback:function(event,options)
{var element=Event.findElement(event,'LI');this.index=element.autocompleteIndex;this.selectEntry();this.hide();Event.fireEvent(this.element,"change");},getUpdatedChoices:function()
{options=new Array(this.getToken(),"__TAutoComplete_onSuggest__");Prado.Callback(this.options.EventTarget,options,null,this.options);},onComplete:function(request,boundary)
{result=Prado.Element.extractContent(request.responseText,boundary);if(typeof(result)=="string"&&result.length>0)
-this.updateChoices(result);}});Prado.WebUI.TPeriodicCallback=Base.extend({count:0,timeout:0,constructor:function(options)
+this.updateChoices(result);}});Prado.WebUI.TTimeTriggeredCallback=Base.extend({count:0,timeout:0,constructor:function(options)
{this.options=Object.extend({Interval:1,DecayRate:0},options||{})
-this.onComplete=this.options.onComplete;Prado.WebUI.TPeriodicCallback.register(this);},startTimer:function()
+this.onComplete=this.options.onComplete;Prado.WebUI.TTimeTriggeredCallback.register(this);},startTimer:function()
{this.options.onComplete=this.onRequestComplete.bind(this);setTimeout(this.onTimerEvent.bind(this),200);},stopTimer:function()
{(this.onComplete||Prototype.emptyFunction).apply(this,arguments);this.options.onComplete=undefined;clearTimeout(this.timer);this.timer=undefined;this.count=0;},onTimerEvent:function()
{this.options.params=this.timeout/1000;request=new Prado.CallbackRequest(this.options.ID,this.options);request.dispatch();},onRequestComplete:function()
diff --git a/framework/Web/Javascripts/js/prado.js b/framework/Web/Javascripts/js/prado.js
index e3930cfd..87996c28 100644
--- a/framework/Web/Javascripts/js/prado.js
+++ b/framework/Web/Javascripts/js/prado.js
@@ -360,7 +360,15 @@ Event.stop(event);},onPostBack:function(event,options)
{if(!this.hasXYInput)
{this.addXYInput(event,options);this.hasXYInput=true;}
Prado.PostBack(event,options);},addXYInput:function(event,options)
-{var imagePos=Position.cumulativeOffset(this.element);var clickedPos=[event.clientX,event.clientY];var x=clickedPos[0]-imagePos[0]+1;var y=clickedPos[1]-imagePos[1]+1;var id=options['EventTarget'];var x_input=INPUT({type:'hidden',name:id+'_x',value:x});var y_input=INPUT({type:'hidden',name:id+'_y',value:y});this.element.parentNode.appendChild(x_input);this.element.parentNode.appendChild(y_input);}});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)
+{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);}
+Logger.info("x="+x+", y="+y);}});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.checked)
this.onRadioButtonInitialize(options);}});Prado.WebUI.TTextBox=Class.extend(Prado.WebUI.PostBackControl,{onInit:function(options)
{if(options['TextMode']!='MultiLine')
diff --git a/framework/Web/Javascripts/prado/activecontrols3.js b/framework/Web/Javascripts/prado/activecontrols3.js
index ca1d5b37..bd8aa6a5 100644
--- a/framework/Web/Javascripts/prado/activecontrols3.js
+++ b/framework/Web/Javascripts/prado/activecontrols3.js
@@ -20,6 +20,16 @@ Prado.WebUI.TActiveButton = Class.extend(Prado.WebUI.CallbackControl);
*/
Prado.WebUI.TActiveLinkButton = Class.extend(Prado.WebUI.CallbackControl);
+Prado.WebUI.TActiveImageButton = Class.extend(Prado.WebUI.TImageButton,
+{
+ onPostBack : function(event, options)
+ {
+ this.addXYInput(event,options);
+ request = new Prado.CallbackRequest(options.EventTarget, options);
+ request.dispatch();
+ Event.stop(event);
+ }
+});
/**
* Active check box.
*/
@@ -112,9 +122,9 @@ Prado.WebUI.TAutoComplete = Class.extend(Prado.WebUI.TAutoComplete,
});
/**
- * Period Callback class.
+ * Time Triggered Callback class.
*/
-Prado.WebUI.TPeriodicCallback = Base.extend(
+Prado.WebUI.TTimeTriggeredCallback = Base.extend(
{
count : 0,
timeout : 0,
@@ -128,7 +138,7 @@ Prado.WebUI.TPeriodicCallback = Base.extend(
}, options || {})
this.onComplete = this.options.onComplete;
- Prado.WebUI.TPeriodicCallback.register(this);
+ Prado.WebUI.TTimeTriggeredCallback.register(this);
},
startTimer : function()
diff --git a/framework/Web/Javascripts/prado/ajax3.js b/framework/Web/Javascripts/prado/ajax3.js
index de5af4ca..c5683139 100644
--- a/framework/Web/Javascripts/prado/ajax3.js
+++ b/framework/Web/Javascripts/prado/ajax3.js
@@ -22,7 +22,7 @@ Object.extend(Ajax.Request.prototype,
(this.options['on' + this.transport.status]
|| this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]
- || Prototype.emptyFunction)(transport, json);
+ || Prototype.emptyFunction)(this, json);
} catch (e) {
this.dispatchException(e);
}
@@ -31,7 +31,7 @@ Object.extend(Ajax.Request.prototype,
}
try {
- (this.options['on' + event] || Prototype.emptyFunction)(transport, json);
+ (this.options['on' + event] || Prototype.emptyFunction)(this, json);
Ajax.Responders.dispatch('on' + event, this, transport, json);
} catch (e) {
this.dispatchException(e);
diff --git a/framework/Web/Javascripts/prado/controls.js b/framework/Web/Javascripts/prado/controls.js
index 285374a3..c31d783d 100644
--- a/framework/Web/Javascripts/prado/controls.js
+++ b/framework/Web/Javascripts/prado/controls.js
@@ -7,12 +7,12 @@ Prado.WebUI.PostBackControl.prototype =
initialize : function(options)
{
this.element = $(options['ID']);
-
+
/* if(options.CausesValidation && typeof(Prado.Validation) != 'undefined')
{
Prado.Validation.registerTarget(options);
}
-
+
//TODO: what do the following options do?
//options['PostBackUrl']
//options['ClientSubmit']
@@ -35,7 +35,7 @@ Prado.WebUI.TButton = Prado.WebUI.createPostBackComponent();
*/
Prado.WebUI.PostBackControl = Class.create();
-Prado.WebUI.PostBackControl.prototype =
+Prado.WebUI.PostBackControl.prototype =
{
_elementOnClick : null, //capture the element's onclick function
@@ -45,7 +45,7 @@ Prado.WebUI.PostBackControl.prototype =
if(this.onInit)
this.onInit(options);
},
-
+
onInit : function(options)
{
if(typeof(this.element.onclick)=="function")
@@ -53,7 +53,7 @@ Prado.WebUI.PostBackControl.prototype =
this._elementOnClick = this.element.onclick;
this.element.onclick = null;
}
- Event.observe(this.element, "click", this.elementClicked.bindEvent(this,options));
+ Event.observe(this.element, "click", this.elementClicked.bindEvent(this,options));
},
elementClicked : function(event, options)
@@ -87,7 +87,7 @@ Prado.WebUI.TBulletedList = Class.extend(Prado.WebUI.PostBackControl);
Prado.WebUI.TImageMap = Class.extend(Prado.WebUI.PostBackControl);
/**
- * TImageButton client-side behaviour. With validation, Firefox needs
+ * 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);
@@ -97,7 +97,7 @@ Object.extend(Prado.WebUI.TImageButton.prototype,
* Only add the hidden inputs once.
*/
hasXYInput : false,
-
+
/**
* Override parent onPostBack function, tried to add hidden forms
* inputs to capture x,y clicked point.
@@ -111,7 +111,7 @@ Object.extend(Prado.WebUI.TImageButton.prototype,
}
Prado.PostBack(event, options);
},
-
+
/**
* Add hidden inputs to capture the x,y point clicked on the image.
* @param event DOM click event.
@@ -119,15 +119,34 @@ Object.extend(Prado.WebUI.TImageButton.prototype,
*/
addXYInput : function(event,options)
{
- var imagePos = Position.cumulativeOffset(this.element);
- var clickedPos = [event.clientX, event.clientY];
- var x = clickedPos[0]-imagePos[0]+1;
- var y = clickedPos[1]-imagePos[1]+1;
- var id = options['EventTarget'];
- var x_input = INPUT({type:'hidden',name:id+'_x',value:x});
- var y_input = INPUT({type:'hidden',name:id+'_y',value:y});
- this.element.parentNode.appendChild(x_input);
- this.element.parentNode.appendChild(y_input);
+ 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);
+ }
+ Logger.info("x="+x+", y="+y);
}
});
@@ -183,7 +202,7 @@ 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 =
+Prado.WebUI.DefaultButton.prototype =
{
initialize : function(options)
{
diff --git a/framework/Web/UI/ActiveControls/TActiveButton.php b/framework/Web/UI/ActiveControls/TActiveButton.php
index 232e639c..a96c1580 100644
--- a/framework/Web/UI/ActiveControls/TActiveButton.php
+++ b/framework/Web/UI/ActiveControls/TActiveButton.php
@@ -15,23 +15,23 @@
*/
Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
-/**
+/**
* TActiveButton is the active control counter part to TButton.
- *
+ *
* When a TActiveButton 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
+ * callback request is initiated.
+ *
+ * The {@link onCallback OnCallback} event is raised during a callback request
* and it is raise after 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 button's caption upon callback response completion.
- *
+ *
* @author Wei Zhuo
* @version $Revision: $ $Date: $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActiveButton extends TButton implements ICallbackEventHandler, IActiveControl
{
@@ -59,7 +59,7 @@ class TActiveButton extends TButton implements ICallbackEventHandler, IActiveCon
* 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.
+ * 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
*/
@@ -81,8 +81,8 @@ class TActiveButton extends TButton implements ICallbackEventHandler, IActiveCon
$this->raiseEvent('OnCallback', $this, $param);
}
- /**
- * Updates the button text on the client-side if the
+ /**
+ * Updates the button text on the client-side if the
* {@link setEnableUpdate EnableUpdate} property is set to true.
* @param string caption of the button
*/
@@ -94,7 +94,7 @@ class TActiveButton extends TButton implements ICallbackEventHandler, IActiveCon
}
/**
- * Override parent implementation, no javascript is rendered here instead
+ * Override parent implementation, no javascript is rendered here instead
* the javascript required for active control is registered in {@link addAttributesToRender}.
*/
protected function renderClientControlScript($writer)
@@ -110,7 +110,7 @@ class TActiveButton extends TButton implements ICallbackEventHandler, IActiveCon
parent::addAttributesToRender($writer);
$writer->addAttribute('id',$this->getClientID());
$this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getPostBackOptions());
+ $this->getClientClassName(), $this->getPostBackOptions());
}
/**
diff --git a/framework/Web/UI/ActiveControls/TActiveCheckBox.php b/framework/Web/UI/ActiveControls/TActiveCheckBox.php
index a7f3ac2a..3752c820 100644
--- a/framework/Web/UI/ActiveControls/TActiveCheckBox.php
+++ b/framework/Web/UI/ActiveControls/TActiveCheckBox.php
@@ -17,18 +17,18 @@ Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
/**
* TActiveCheckBox class.
- *
+ *
* The active control counter part to checkbox. The {@link setAutoPostBack AutoPostBack}
- * property is set to true by default. Thus, when the checkbox is clicked a
+ * property is set to true by default. Thus, when the checkbox is clicked a
* {@link onCallback OnCallback} event is raise after {@link OnCheckedChanged} event.
- *
- * The {@link setText Text} and {@link setChecked Checked} properties can be
+ *
+ * The {@link setText Text} and {@link setChecked Checked} properties can be
* changed during a callback.
*
* @author Wei Zhuo
* @version : $ Tue Jun 20 01:29:35 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActiveCheckBox extends TCheckBox implements ICallbackEventHandler, IActiveControl
{
@@ -54,7 +54,7 @@ class TActiveCheckBox extends TCheckBox implements ICallbackEventHandler, IActiv
/**
* Raises the callback event. This method is required by {@link
- * ICallbackEventHandler} interface.
+ * ICallbackEventHandler} interface.
* This method is mainly used by framework and control developers.
* @param TCallbackEventParameter the event parameter
*/
@@ -75,8 +75,8 @@ class TActiveCheckBox extends TCheckBox implements ICallbackEventHandler, IActiv
$this->raiseEvent('OnCallback', $this, $param);
}
- /**
- * Updates the button text on the client-side if the
+ /**
+ * Updates the button text on the client-side if the
* {@link setEnableUpdate EnableUpdate} property is set to true.
* @param string caption of the button
*/
@@ -87,10 +87,10 @@ class TActiveCheckBox extends TCheckBox implements ICallbackEventHandler, IActiv
$this->getPage()->getCallbackClient()->update(
$this->getDefaultLabelID(), $value);
}
-
+
/**
* Sets a value indicating whether the checkbox is to be checked or not.
- * Updates checkbox checked state on the client-side if the
+ * Updates checkbox checked state on the client-side if the
* {@link setEnableUpdate EnableUpdate} property is set to true.
* @param boolean whether the checkbox is to be checked or not.
*/
@@ -100,7 +100,7 @@ class TActiveCheckBox extends TCheckBox implements ICallbackEventHandler, IActiv
parent::setChecked($value);
if($this->getActiveControl()->canUpdateClientSide())
$this->getPage()->getCallbackClient()->check($this, $value);
- }
+ }
/**
* Registers the javascript code for initializing the active control.
@@ -108,7 +108,7 @@ class TActiveCheckBox extends TCheckBox implements ICallbackEventHandler, IActiv
protected function renderClientControlScript($writer)
{
$this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getPostBackOptions());
+ $this->getClientClassName(), $this->getPostBackOptions());
}
/**
@@ -118,9 +118,9 @@ class TActiveCheckBox extends TCheckBox implements ICallbackEventHandler, IActiv
{
return 'Prado.WebUI.TActiveCheckBox';
}
-
- /**
- * Overrides parent implementation to ensure label has ID.
+
+ /**
+ * Overrides parent implementation to ensure label has ID.
* @return TMap list of attributes to be rendered for label beside the checkbox
*/
public function getLabelAttributes()
@@ -129,7 +129,7 @@ class TActiveCheckBox extends TCheckBox implements ICallbackEventHandler, IActiv
$attributes['id'] = $this->getDefaultLabelID();
return $attributes;
}
-
+
/**
* Renders a label beside the checkbox.
* @param THtmlWriter the writer for the rendering purpose
@@ -140,8 +140,8 @@ class TActiveCheckBox extends TCheckBox implements ICallbackEventHandler, IActiv
{
$writer->addAttribute('id', $this->getDefaultLabelID());
parent::renderLabel($writer, $clientID, $text);
- }
-
+ }
+
/**
* @return string checkbox label ID;
*/
@@ -149,7 +149,7 @@ class TActiveCheckBox extends TCheckBox implements ICallbackEventHandler, IActiv
{
if($attributes=$this->getViewState('LabelAttributes',null))
return $this->getLabelAttributes()->itemAt('id');
- else
+ else
return $this->getClientID().'_label';
}
}
diff --git a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php
index 3a33ccc2..458a26f6 100644
--- a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php
+++ b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php
@@ -17,12 +17,12 @@ Prado::using('System.Web.UI.ActiveControls.TActiveListControlAdapter');
/**
* TActiveCheckBoxList class.
- *
- * The active control counter part to checkbox list control.
- * The {@link setAutoPostBack AutoPostBack} property is set to true by default.
- * Thus, when a checkbox is clicked a {@link onCallback OnCallback} event is
- * raised after {@link OnSelectedIndexChanged} event.
- *
+ *
+ * The active control counter part to checkbox list control.
+ * The {@link setAutoPostBack AutoPostBack} property is set to true by default.
+ * Thus, when a checkbox 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.
@@ -30,7 +30,7 @@ Prado::using('System.Web.UI.ActiveControls.TActiveListControlAdapter');
* @author Wei Zhuo
* @version : $ Sun Jun 25 01:50:27 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActiveCheckBoxList extends TCheckBoxList implements IActiveControl, ICallbackEventHandler
{
@@ -53,7 +53,7 @@ class TActiveCheckBoxList extends TCheckBoxList implements IActiveControl, ICall
{
return $this->getAdapter()->getBaseActiveControl();
}
-
+
/**
* No client class for this control.
* This method overrides the parent implementation.
@@ -62,8 +62,8 @@ class TActiveCheckBoxList extends TCheckBoxList implements IActiveControl, ICall
protected function getClientClassName()
{
return null;
- }
-
+ }
+
/**
* Creates a control used for repetition (used as a template).
* @return TControl the control to be repeated
@@ -72,10 +72,10 @@ class TActiveCheckBoxList extends TCheckBoxList implements IActiveControl, ICall
{
return new TActiveCheckBox;
}
-
+
/**
* Raises the callback event. This method is required by {@link
- * ICallbackEventHandler} interface.
+ * ICallbackEventHandler} interface.
* This method is mainly used by framework and control developers.
* @param TCallbackEventParameter the event parameter
*/
@@ -94,7 +94,7 @@ class TActiveCheckBoxList extends TCheckBoxList implements IActiveControl, ICall
public function onCallback($param)
{
$this->raiseEvent('OnCallback', $this, $param);
- }
+ }
}
?>
\ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
index 75c9ba21..0ea10f4e 100644
--- a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
+++ b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
@@ -17,21 +17,21 @@ Prado::using('System.Web.UI.ActiveControls.TBaseActiveControl');
/**
* TActiveControlAdapter class.
- *
- * Customize the parent TControl class for active control classes.
+ *
+ * Customize the parent TControl class for active control classes.
* TActiveControlAdapter instantiates a common base active control class
* throught the {@link getBaseActiveControl BaseActiveControl} property.
* The type of BaseActiveControl can be provided in the second parameter in the
* constructor. Default is TBaseActiveControl or TBaseActiveCallbackControl if
* the control adapted implements ICallbackEventHandler.
- *
- * TActiveControlAdapter will tracking viewstate changes to update the
+ *
+ * TActiveControlAdapter will tracking viewstate changes to update the
* corresponding client-side properties.
*
* @author Wei Zhuo
* @version $Revision: $ Sun Jun 18 20:35:34 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActiveControlAdapter extends TControlAdapter
{
@@ -47,7 +47,7 @@ class TActiveControlAdapter extends TControlAdapter
* @var TCallbackPageStateTracker view state tracker.
*/
private $_stateTracker;
-
+
/**
* Constructor.
* @param IActiveControl active control to adapt.
@@ -58,7 +58,7 @@ class TActiveControlAdapter extends TControlAdapter
parent::__construct($control);
$this->setBaseControlClass($baseCallbackClass);
}
-
+
/**
* @param string base active control instance
*/
@@ -74,7 +74,7 @@ class TActiveControlAdapter extends TControlAdapter
else
$this->_activeControlType = $type;
}
-
+
/**
* Renders the callback client scripts.
*/
@@ -83,9 +83,9 @@ class TActiveControlAdapter extends TControlAdapter
$this->renderCallbackClientScripts();
parent::render($writer);
}
-
+
/**
- * Register the callback clientscripts and sets the post loader IDs.
+ * Register the callback clientscripts and sets the post loader IDs.
*/
protected function renderCallbackClientScripts()
{
@@ -103,7 +103,7 @@ class TActiveControlAdapter extends TControlAdapter
}
}
}
-
+
/**
* @return TBaseActiveControl Common active control options.
*/
@@ -116,7 +116,7 @@ class TActiveControlAdapter extends TControlAdapter
}
return $this->_baseActiveControl;
}
-
+
/**
* @return boolean true if the viewstate needs to be tracked.
*/
@@ -127,13 +127,13 @@ class TActiveControlAdapter extends TControlAdapter
$target = $this->getPage()->getCallbackEventTarget();
if($target instanceof ICallbackEventHandler)
{
- $client = $target->getActiveControl()->getClientSide();
+ $client = $target->getActiveControl()->getClientSide();
return $client->getEnablePageStateUpdate();
}
}
return false;
}
-
+
/**
* Loads additional persistent control state. Starts viewstate tracking
* if necessary.
@@ -147,21 +147,21 @@ class TActiveControlAdapter extends TControlAdapter
}
parent::loadState();
}
-
+
/**
* Saves additional persistent control state. Respond to viewstate changes
* if necessary.
*/
public function saveState()
{
- if(!is_null($this->_stateTracker)
+ if(!is_null($this->_stateTracker)
&& $this->getControl()->getActiveControl()->canUpdateClientSide())
{
$this->_stateTracker->respondToChanges();
}
parent::saveState();
}
-
+
/**
* @return TCallbackPageStateTracker state tracker.
*/
@@ -169,19 +169,17 @@ class TActiveControlAdapter extends TControlAdapter
{
return $this->_stateTracker;
}
-}
+}
/**
* TCallbackPageStateTracker class.
- *
+ *
* Tracking changes to the page state during callback.
- *
- * @todo Complete this class! (Wei)
- *
+ *
* @author Wei Zhuo
* @version $Revision: $ Sun Jun 18 20:51:25 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TCallbackPageStateTracker
{
@@ -201,7 +199,7 @@ class TCallbackPageStateTracker
* @var object null object.
*/
private $_nullObject;
-
+
/**
* Constructor. Add a set of default states to track.
* @param TControl control to track.
@@ -214,7 +212,7 @@ class TCallbackPageStateTracker
$this->_states = new TMap;
$this->addStatesToTrack();
}
-
+
/**
* Add a list of view states to track. Each state is added
* to the StatesToTrack property with the view state name as key.
@@ -232,9 +230,9 @@ class TCallbackPageStateTracker
$states['Style'] = array('TStyleDiff', array($this, 'updateStyle'));
$states['TabIndex'] = array('TScalarDiff', array($this, 'updateTabIndex'));
$states['ToolTip'] = array('TScalarDiff', array($this, 'updateToolTip'));
- $states['AccessKey'] = array('TScalarDiff', array($this, 'updateAccessKey'));
+ $states['AccessKey'] = array('TScalarDiff', array($this, 'updateAccessKey'));
}
-
+
/**
* @return TMap list of viewstates to track.
*/
@@ -242,7 +240,7 @@ class TCallbackPageStateTracker
{
return $this->_states;
}
-
+
/**
* Start tracking view state changes. The clone function on objects are called
* for those viewstate having an object as value.
@@ -255,7 +253,7 @@ class TCallbackPageStateTracker
$this->_existingState[$name] = is_object($obj) ? clone($obj) : $obj;
}
}
-
+
/**
* @array list of viewstate and the changed data.
*/
@@ -275,7 +273,7 @@ class TCallbackPageStateTracker
}
return $changes;
}
-
+
/**
* For each of the changes call the corresponding change handlers.
*/
@@ -284,7 +282,7 @@ class TCallbackPageStateTracker
foreach($this->getChanges() as $change)
call_user_func_array($change[0], $change[1]);
}
-
+
/**
* @return TCallbackClientScript callback client scripting
*/
@@ -292,36 +290,36 @@ class TCallbackPageStateTracker
{
return $this->_control->getPage()->getCallbackClient();
}
-
+
/**
* Updates the tooltip.
* @param string new tooltip
*/
protected function updateToolTip($value)
{
- $this->client()->setAttribute($this->_control, 'title', $value);
+ $this->client()->setAttribute($this->_control, 'title', $value);
}
-
+
/**
* Updates the tab index.
* @param integer tab index
*/
protected function updateTabIndex($value)
{
- $this->client()->setAttribute($this->_control, 'tabindex', $value);
+ $this->client()->setAttribute($this->_control, 'tabindex', $value);
}
-
+
/**
* Updates the modifier access key
* @param string access key
*/
protected function updateAccessKey($value)
{
- $this->client()->setAttribute($this->_control, 'accesskey', $value);
+ $this->client()->setAttribute($this->_control, 'accesskey', $value);
}
-
+
/**
- * Hides or shows the control on the client-side. The control must be
+ * Hides or shows the control on the client-side. The control must be
* already rendered on the client-side.
* @param boolean true to show the control, false to hide.
*/
@@ -332,7 +330,7 @@ class TCallbackPageStateTracker
else
$this->client()->show($this->_control);
}
-
+
/**
* Enables or Disables the control on the client-side.
* @param boolean true to enable the control, false to disable.
@@ -341,7 +339,7 @@ class TCallbackPageStateTracker
{
$this->client()->setAttribute($this->_control, 'disabled', $enable===false);
}
-
+
/**
* Updates the CSS style on the control on the client-side.
* @param array list of new CSS style declarations.
@@ -353,7 +351,7 @@ class TCallbackPageStateTracker
if(count($style['Style']) > 0)
$this->client()->setStyle($this->_control, $style['Style']);
}
-
+
/**
* Updates/adds a list of attributes on the control.
* @param array list of attribute name-value pairs.
@@ -371,12 +369,12 @@ class TCallbackPageStateTracker
* @author Wei Zhuo
* @version $Revision: $ Thu Jun 22 02:50:45 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
abstract class TViewStateDiff
{
/**
- * @var mixed updated viewstate
+ * @var mixed updated viewstate
*/
protected $_new;
/**
@@ -387,9 +385,9 @@ abstract class TViewStateDiff
* @var object null value.
*/
protected $_null;
-
+
/**
- * Constructor.
+ * Constructor.
* @param mixed updated viewstate value.
* @param mixed viewstate value at the begining of the request.
* @param object representing the null value.
@@ -400,7 +398,7 @@ abstract class TViewStateDiff
$this->_old = $old;
$this->_null = $null;
}
-
+
/**
* @return mixed view state changes, nullObject if no difference.
*/
@@ -409,13 +407,13 @@ abstract class TViewStateDiff
/**
* TScalarDiff class.
- *
+ *
* Calculate the changes to a scalar value.
*
* @author Wei Zhuo
* @version $Revision: $ Thu Jun 22 02:54:42 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TScalarDiff extends TViewStateDiff
{
@@ -424,8 +422,8 @@ class TScalarDiff extends TViewStateDiff
*/
public function getDifference()
{
- if(gettype($this->_new) === gettype($this->_old)
- && $this->_new === $this->_old)
+ if(gettype($this->_new) === gettype($this->_old)
+ && $this->_new === $this->_old)
return $this->_null;
else
return $this->_new;
@@ -434,23 +432,23 @@ class TScalarDiff extends TViewStateDiff
/**
* TStyleDiff class.
- *
+ *
* Calculates the changes to the Style properties.
*
* @author Wei Zhuo
* @version $Revision: $ Thu Jun 22 02:55:47 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TStyleDiff extends TViewStateDiff
{
- /**
+ /**
* @param TStyle control style
* @return array all the style properties combined.
*/
protected function getCombinedStyle($obj)
{
- if(!($obj instanceof TStyle))
+ if(!($obj instanceof TStyle))
return array();
$style = $obj->getStyleFields();
$style = array_merge($style,$this->getStyleFromString($obj->getCustomStyle()));
@@ -458,7 +456,7 @@ class TStyleDiff extends TViewStateDiff
$style = array_merge($style, $this->getStyleFromString($obj->getFont()->toString()));
return $style;
}
-
+
/**
* @param string CSS custom style string.
* @param array CSS style as name-value array.
@@ -476,7 +474,7 @@ class TStyleDiff extends TViewStateDiff
}
return $style;
}
-
+
/**
* @return string changes to the CSS class name.
*/
@@ -484,16 +482,16 @@ class TStyleDiff extends TViewStateDiff
{
if(is_null($this->_old))
{
- return !is_null($this->_new) && $this->_new->hasCssClass()
- ? $this->_new->getCssClass() : null;
+ return !is_null($this->_new) && $this->_new->hasCssClass()
+ ? $this->_new->getCssClass() : null;
}
else
{
- return $this->_old->getCssClass() !== $this->_new->getCssClass() ?
+ return $this->_old->getCssClass() !== $this->_new->getCssClass() ?
$this->_new->getCssClass() : null;
}
}
-
+
/**
* @return array list of changes to the control style.
*/
@@ -526,13 +524,13 @@ class TStyleDiff extends TViewStateDiff
/**
* TAttributesDiff class.
- *
+ *
* Calculate the changes to attributes collection.
*
* @author Wei Zhuo
* @version $Revision: $ Thu Jun 22 02:54:42 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TMapCollectionDiff extends TViewStateDiff
{
@@ -543,7 +541,7 @@ class TMapCollectionDiff extends TViewStateDiff
{
if(is_null($this->_old))
{
- return !is_null($this->_new) ? $this->_new->toArray() : $this->_null;
+ return !is_null($this->_new) ? $this->_new->toArray() : $this->_null;
}
else
{
diff --git a/framework/Web/UI/ActiveControls/TActiveDropDownList.php b/framework/Web/UI/ActiveControls/TActiveDropDownList.php
index 679996b5..0a6a3832 100644
--- a/framework/Web/UI/ActiveControls/TActiveDropDownList.php
+++ b/framework/Web/UI/ActiveControls/TActiveDropDownList.php
@@ -18,12 +18,12 @@ Prado::using('System.Web.UI.ActiveControls.TActiveListControlAdapter');
/**
/**
* TActiveDropDownList class.
- *
- * The active control counter part to drop down list control.
- * The {@link setAutoPostBack AutoPostBack} property is set to true by default.
- * Thus, when the drop down list selection is changed the {@link onCallback OnCallback} event is
- * raised after {@link OnSelectedIndexChanged} event.
- *
+ *
+ * The active control counter part to drop down list control.
+ * The {@link setAutoPostBack AutoPostBack} property is set to true by default.
+ * Thus, when the drop down list selection is changed the {@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, after OnLoad event has
* been raised, will be updated.
@@ -32,7 +32,7 @@ Prado::using('System.Web.UI.ActiveControls.TActiveListControlAdapter');
* @author Wei Zhuo
* @version : $ Sun Jun 25 19:55:19 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActiveDropDownList extends TDropDownList implements ICallbackEventHandler, IActiveControl
{
@@ -65,7 +65,7 @@ class TActiveDropDownList extends TDropDownList implements ICallbackEventHandler
{
return 'Prado.WebUI.TActiveDropDownList';
}
-
+
/**
* Loads user input data.
* Disables ActiveControl.EnableUpdate subproperty during loading post data
@@ -82,7 +82,7 @@ class TActiveDropDownList extends TDropDownList implements ICallbackEventHandler
$this->getActiveControl()->setEnableUpdate($enabled);
return $result;
}
-
+
/**
* Creates a collection object to hold list items. A specialized
* TActiveListItemCollection is created to allow the drop down list options
@@ -96,15 +96,15 @@ class TActiveDropDownList extends TDropDownList implements ICallbackEventHandler
$collection->setControl($this);
return $collection;
}
-
+
/**
- * Override parent implementation, no javascript is rendered here instead
+ * 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.
@@ -114,12 +114,12 @@ class TActiveDropDownList extends TDropDownList implements ICallbackEventHandler
parent::addAttributesToRender($writer);
$writer->addAttribute('id',$this->getClientID());
$this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getPostBackOptions());
- }
-
+ $this->getClientClassName(), $this->getPostBackOptions());
+ }
+
/**
* Raises the callback event. This method is required by {@link
- * ICallbackEventHandler} interface.
+ * ICallbackEventHandler} interface.
* This method is mainly used by framework and control developers.
* @param TCallbackEventParameter the event parameter
*/
@@ -138,8 +138,8 @@ class TActiveDropDownList extends TDropDownList implements ICallbackEventHandler
public function onCallback($param)
{
$this->raiseEvent('OnCallback', $this, $param);
- }
-
+ }
+
/**
* Updates the client-side options if the item list has changed after the OnLoad event.
*/
diff --git a/framework/Web/UI/ActiveControls/TActiveHyperLink.php b/framework/Web/UI/ActiveControls/TActiveHyperLink.php
index ac99089d..946625b5 100644
--- a/framework/Web/UI/ActiveControls/TActiveHyperLink.php
+++ b/framework/Web/UI/ActiveControls/TActiveHyperLink.php
@@ -15,15 +15,15 @@
*
* The active control counterpart of THyperLink component. When
* {@link TBaseActiveControl::setEnableUpdate ActiveControl.EnableUpdate}
- * property is true the during a callback request, setting {@link setText Text}
- * property will also set the text of the label on the client upon callback
+ * property is true the during a callback request, setting {@link setText Text}
+ * property will also set the text of the label on the client upon callback
* completion. Similarly, for other properties such as {@link setImageUrl ImageUrl},
* {@link setNavigateUrl NavigateUrl} and {@link setTarget Target}.
- *
+ *
* @author Wei Zhuo
* @version : $ Mon Jun 26 00:08:24 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActiveHyperLink extends THyperLink implements IActiveControl
{
@@ -37,7 +37,7 @@ class TActiveHyperLink extends THyperLink implements IActiveControl
parent::__construct();
$this->setAdapter(new TActiveControlAdapter($this));
}
-
+
/**
* @return TBaseActiveControl basic active control options.
*/
@@ -45,7 +45,7 @@ class TActiveHyperLink extends THyperLink implements IActiveControl
{
return $this->getAdapter()->getBaseActiveControl();
}
-
+
/**
* On callback response, the inner HTMl of the label is updated.
* @param string the text value of the label
@@ -56,7 +56,7 @@ class TActiveHyperLink extends THyperLink implements IActiveControl
if($this->getActiveControl()->canUpdateClientSide())
$this->getPage()->getCallbackClient()->update($this, $value);
}
-
+
/**
* Sets the location of image file of the THyperLink.
* @param string the image file location
@@ -72,7 +72,7 @@ class TActiveHyperLink extends THyperLink implements IActiveControl
$this->getPage()->getCallbackClient()->update($this, $textWriter->flush());
}
}
-
+
/**
* Sets the URL to link to when the THyperLink component is clicked.
* @param string the URL
@@ -83,7 +83,7 @@ class TActiveHyperLink extends THyperLink implements IActiveControl
if($this->getActiveControl()->canUpdateClientSide())
$this->getPage()->getCallbackClient()->setAttribute($this, 'href', $value);
}
-
+
/**
* Sets the target window or frame to display the Web page content linked to when the THyperLink component is clicked.
* @param string the target window, valid values include '_blank', '_parent', '_self', '_top' and empty string.
@@ -92,8 +92,8 @@ class TActiveHyperLink extends THyperLink implements IActiveControl
{
parent::setTarget($value);
if($this->getActiveControl()->canUpdateClientSide())
- $this->getPage()->getCallbackClient()->setAttribute($this, 'target', $value);
- }
+ $this->getPage()->getCallbackClient()->setAttribute($this, 'target', $value);
+ }
}
?>
\ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActiveImage.php b/framework/Web/UI/ActiveControls/TActiveImage.php
index eb0f4ca9..6d18d61d 100644
--- a/framework/Web/UI/ActiveControls/TActiveImage.php
+++ b/framework/Web/UI/ActiveControls/TActiveImage.php
@@ -10,18 +10,84 @@
* @package System.Web.UI.WebControls
*/
-
/**
* TActiveImage class.
*
+ * TActiveImage allows the {@link setAlternateText AlternateText},
+ * {@link setImageAlign ImageAlign}, {@link setImageUrl ImageUrl},
+ * and {@link setDescriptionUrl DescriptionUrl} to be updated during
+ * a callback request.
+ *
* @author Wei Zhuo
* @version : $ Mon Jun 26 00:44:25 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActiveImage extends TImage implements IActiveControl
{
+ /**
+ * 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 TBaseActiveControl basic active control options.
+ */
+ public function getActiveControl()
+ {
+ return $this->getAdapter()->getBaseActiveControl();
+ }
+
+ /**
+ * Sets the alternative text to be displayed in the TImage when the image is unavailable.
+ * @param string the alternative text
+ */
+ public function setAlternateText($value)
+ {
+ parent::setAlternateText($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->setAttribute($this, 'alt', $value);
+ }
+
+ /**
+ * Sets the alignment of the image with respective to other elements on the page.
+ * Possible values include: absbottom, absmiddle, baseline, bottom, left,
+ * middle, right, texttop, and top. If an empty string is passed in,
+ * imagealign attribute will not be rendered.
+ * @param string the alignment of the image
+ */
+ public function setImageAlign($value)
+ {
+ parent::setImageAlign($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->setAttribute($this, 'align', $value);
+ }
+
+ /**
+ * @param string the URL of the image file
+ */
+ public function setImageUrl($value)
+ {
+ parent::setImageUrl($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->setAttribute($this, 'src', $value);
+ }
+ /**
+ * @param string the URL to the long description of the image.
+ */
+ public function setDescriptionUrl($value)
+ {
+ parent::setDescriptionUrl($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->setAttribute($this, 'longdesc', $value);
+ }
}
?>
\ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActiveImageButton.php b/framework/Web/UI/ActiveControls/TActiveImageButton.php
index 74e99781..5c599120 100644
--- a/framework/Web/UI/ActiveControls/TActiveImageButton.php
+++ b/framework/Web/UI/ActiveControls/TActiveImageButton.php
@@ -13,13 +13,150 @@
/**
* TActiveImageButton class.
*
+ * TActiveImageButton is the active control counter part to TLinkButton.
+ * When a TActiveImageButton 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 after the {@link onClick OnClick} event.
+ *
* @author Wei Zhuo
* @version : $ Mon Jun 26 00:45:39 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActiveImageButton extends TImageButton 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 TBaseActiveControl basic active control options.
+ */
+ public function getActiveControl()
+ {
+ return $this->getAdapter()->getBaseActiveControl();
+ }
+
+ /**
+ * Sets the alternative text to be displayed in the TImage when the image is unavailable.
+ * @param string the alternative text
+ */
+ public function setAlternateText($value)
+ {
+ parent::setAlternateText($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->setAttribute($this, 'alt', $value);
+ }
+
+ /**
+ * Sets the alignment of the image with respective to other elements on the page.
+ * Possible values include: absbottom, absmiddle, baseline, bottom, left,
+ * middle, right, texttop, and top. If an empty string is passed in,
+ * imagealign attribute will not be rendered.
+ * @param string the alignment of the image
+ */
+ public function setImageAlign($value)
+ {
+ parent::setImageAlign($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->setAttribute($this, 'align', $value);
+ }
+
+ /**
+ * @param string the URL of the image file
+ */
+ public function setImageUrl($value)
+ {
+ parent::setImageUrl($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->setAttribute($this, 'src', $value);
+ }
+
+ /**
+ * @param string the URL to the long description of the image.
+ */
+ public function setDescriptionUrl($value)
+ {
+ parent::setDescriptionUrl($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->setAttribute($this, 'longdesc', $value);
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Override parent implementation, no javascript is rendered here instead
+ * the javascript required for active control is registered in {@link addAttributesToRender}.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ }
+
+ /**
+ * Register the x and y hidden input names of the position clicked.
+ * @param THtmlWriter the renderer.
+ */
+ public function onPreRender($writer)
+ {
+ parent::onPreRender($writer);
+ $uid = $uid=$this->getUniqueID();
+ $this->getPage()->registerPostDataLoader($uid.'_x');
+ $this->getPage()->registerPostDataLoader($uid.'_y');
+ }
+
+ /**
+ * 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->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getPostBackOptions());
+ }
+
+ /**
+ * @return string corresponding javascript class name for this TActiveLinkButton.
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TActiveImageButton';
+ }
}
?>
\ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActiveLabel.php b/framework/Web/UI/ActiveControls/TActiveLabel.php
index f6c0ce81..c4b38cb4 100644
--- a/framework/Web/UI/ActiveControls/TActiveLabel.php
+++ b/framework/Web/UI/ActiveControls/TActiveLabel.php
@@ -20,15 +20,15 @@ Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
*
* The active control counterpart of TLabel component. When
* {@link TBaseActiveControl::setEnableUpdate ActiveControl.EnableUpdate}
- * property is true the during a callback request, setting {@link setText Text}
- * property will also set the text of the label on the client upon callback
+ * property is true the during a callback request, setting {@link setText Text}
+ * property will also set the text of the label on the client upon callback
* completion. Similarly, setting {@link setForControl ForControl} will also set
* the client-side "for" attribute on the label.
*
* @author Wei Zhuo
* @version $Revision: $ $Date: $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActiveLabel extends TLabel implements IActiveControl
{
@@ -42,7 +42,7 @@ class TActiveLabel extends TLabel implements IActiveControl
parent::__construct();
$this->setAdapter(new TActiveControlAdapter($this));
}
-
+
/**
* @return TBaseActiveControl basic active control options.
*/
@@ -50,7 +50,7 @@ class TActiveLabel extends TLabel implements IActiveControl
{
return $this->getAdapter()->getBaseActiveControl();
}
-
+
/**
* On callback response, the inner HTMl of the label is updated.
* @param string the text value of the label
@@ -61,7 +61,7 @@ class TActiveLabel extends TLabel implements IActiveControl
if($this->getActiveControl()->canUpdateClientSide())
$this->getPage()->getCallbackClient()->update($this, $value);
}
-
+
/**
* Sets the ID of the control that the label is associated with.
* The control must be locatable via {@link TControl::findControl} using the ID.
@@ -77,6 +77,6 @@ class TActiveLabel extends TLabel implements IActiveControl
$this->getPage()->getCallbackClient()->setAttribute($this, 'for', $id);
}
}
-}
+}
?>
\ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActiveLinkButton.php b/framework/Web/UI/ActiveControls/TActiveLinkButton.php
index 16c02519..28bba04b 100644
--- a/framework/Web/UI/ActiveControls/TActiveLinkButton.php
+++ b/framework/Web/UI/ActiveControls/TActiveLinkButton.php
@@ -26,7 +26,7 @@
* @author Wei Zhuo
* @version : $ Mon Jun 26 00:49:25 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActiveLinkButton extends TLinkButton implements IActiveControl, ICallbackEventHandler
{
diff --git a/framework/Web/UI/ActiveControls/TActiveListBox.php b/framework/Web/UI/ActiveControls/TActiveListBox.php
index 77ca615a..30eeba2c 100644
--- a/framework/Web/UI/ActiveControls/TActiveListBox.php
+++ b/framework/Web/UI/ActiveControls/TActiveListBox.php
@@ -16,7 +16,7 @@
* @author Wei Zhuo
* @version : $ Mon Jun 26 00:50:16 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActiveListBox extends TListBox implements IActiveControl, ICallbackEventHandler
{
diff --git a/framework/Web/UI/ActiveControls/TActiveListControlAdapter.php b/framework/Web/UI/ActiveControls/TActiveListControlAdapter.php
index e6f3759a..5280e419 100644
--- a/framework/Web/UI/ActiveControls/TActiveListControlAdapter.php
+++ b/framework/Web/UI/ActiveControls/TActiveListControlAdapter.php
@@ -18,14 +18,14 @@ Prado::using('System.Web.UI.WebControls.TListControl');
/**
* TActiveListControlAdapter class.
- *
+ *
* Adapte the list controls to allows the selections on the client-side to be altered
* during callback response.
*
* @author Wei Zhuo
* @version $Revision: $ Sun Jun 25 04:53:43 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActiveListControlAdapter extends TActiveControlAdapter implements IListControlAdapter
{
@@ -36,9 +36,9 @@ class TActiveListControlAdapter extends TActiveControlAdapter implements IListCo
{
return $this->getControl()->getActiveControl()->canUpdateClientSide();
}
-
- /**
- * Selects an item based on zero-base index on the client side.
+
+ /**
+ * Selects an item based on zero-base index on the client side.
* @param integer the index (zero-based) of the item to be selected
*/
public function setSelectedIndex($index)
@@ -48,8 +48,8 @@ class TActiveListControlAdapter extends TActiveControlAdapter implements IListCo
$this->getControl(), 'Index', $index);
}
- /**
- * Selects a list of item based on zero-base indices on the client side.
+ /**
+ * Selects a list of item based on zero-base indices on the client side.
* @param array list of index of items to be selected
*/
public function setSelectedIndices($indices)
@@ -66,7 +66,7 @@ class TActiveListControlAdapter extends TActiveControlAdapter implements IListCo
}
if(count($list) > 0)
$this->getPage()->getCallbackClient()->select(
- $this->getControl(), 'Indices', $list);
+ $this->getControl(), 'Indices', $list);
}
}
@@ -80,8 +80,8 @@ class TActiveListControlAdapter extends TActiveControlAdapter implements IListCo
$this->getPage()->getCallbackClient()->select(
$this->getControl(), 'Value', $value);
}
-
- /**
+
+ /**
* Sets selection by a list of item values on the client side.
* @param array list of the selected item values
*/
@@ -97,7 +97,7 @@ class TActiveListControlAdapter extends TActiveControlAdapter implements IListCo
$this->getControl(), 'Values', $list);
}
}
-
+
/**
* Clears all existing selections on the client side.
*/
@@ -123,19 +123,19 @@ class TActiveListControlAdapter extends TActiveControlAdapter implements IListCo
/**
* TActiveListItemCollection class.
- *
+ *
* Allows TActiveDropDownList and TActiveListBox to add new options
* during callback response. New options can only be added after the
- * {@link TControl::onLoad OnLoad} event.
- *
- * The {@link getListHasChanged ListHasChanged} property is true when the
+ * {@link TControl::onLoad OnLoad} event.
+ *
+ * The {@link getListHasChanged ListHasChanged} property is true when the
* list items has changed. The control responsible for the list needs to
* repopulate the client-side options.
*
* @author Wei Zhuo
* @version $Revision: $ Sun Jun 25 21:15:05 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActiveListItemCollection extends TListItemCollection
{
@@ -147,7 +147,7 @@ class TActiveListItemCollection extends TListItemCollection
* @var boolean true if list items were changed.
*/
private $_hasChanged=false;
-
+
/**
* @return boolean true if active controls can update client-side and
* the onLoad event has already been raised.
@@ -157,7 +157,7 @@ class TActiveListItemCollection extends TListItemCollection
return $this->getControl()->getActiveControl()->canUpdateClientSide()
&& $this->getControl()->getHasLoaded();
}
-
+
/**
* @param IActiveControl a active list control.
*/
@@ -165,7 +165,7 @@ class TActiveListItemCollection extends TListItemCollection
{
$this->_control = $control;
}
-
+
/**
* @return IActiveControl active control using the collection.
*/
@@ -173,7 +173,7 @@ class TActiveListItemCollection extends TListItemCollection
{
return $this->_control;
}
-
+
/**
* @return boolean true if the list has changed after onLoad event.
*/
@@ -181,7 +181,7 @@ class TActiveListItemCollection extends TListItemCollection
{
return $this->_hasChanged;
}
-
+
/**
* Inserts an item into the collection.
* The new option is added on the client-side during callback.
@@ -196,7 +196,7 @@ class TActiveListItemCollection extends TListItemCollection
if($this->canUpdateClientSide())
$this->_hasChanged = true;
}
-
+
/**
* Removes an item from at specified index.
* @param int zero based index.
@@ -205,7 +205,7 @@ class TActiveListItemCollection extends TListItemCollection
{
parent::removeAt($index);
if($this->canUpdateClientSide())
- $this->_hasChanged = true;
+ $this->_hasChanged = true;
}
}
diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php
index 656b959c..5dce985a 100644
--- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php
+++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php
@@ -1,6 +1,7 @@
* @link http://www.pradosoft.com/
@@ -17,16 +18,16 @@ Prado::using('System.Web.UI.ActiveControls.TCallbackResponseAdapter');
/**
* TActivePageAdapter class.
- *
+ *
* Callback request handler.
- *
+ *
* @author Wei Zhuo
* @version $Revision: $ $Date: $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActivePageAdapter extends TControlAdapter
-{
+{
/**
* Callback response data header name.
*/
@@ -43,9 +44,9 @@ class TActivePageAdapter extends TControlAdapter
* Callback page state header name.
*/
const CALLBACK_PAGESTATE_HEADER = 'X-PRADO-PAGESTATE';
-
+
/**
- * @var ICallbackEventHandler callback event handler.
+ * @var ICallbackEventHandler callback event handler.
*/
private $_callbackEventTarget;
/**
@@ -64,11 +65,11 @@ class TActivePageAdapter extends TControlAdapter
public function __construct(TPage $control)
{
parent::__construct($control);
-
+
//TODO: can this be done later?
$response = $this->getApplication()->getResponse();
$response->setAdapter(new TCallbackResponseAdapter($response));
-
+
$this->trapCallbackErrorsExceptions();
}
@@ -81,7 +82,7 @@ class TActivePageAdapter extends TControlAdapter
Prado::trace("ActivePage raiseCallbackEvent()",'System.Web.UI.ActiveControls.TActivePageAdapter');
$this->raiseCallbackEvent();
}
-
+
/**
* Trap errors and exceptions to be handled by TCallbackErrorHandler.
*/
@@ -89,7 +90,7 @@ class TActivePageAdapter extends TControlAdapter
{
$this->getApplication()->setErrorHandler(new TCallbackErrorHandler);
}
-
+
/**
* Render the callback response.
* @param THtmlWriter html content writer.
@@ -98,8 +99,8 @@ class TActivePageAdapter extends TControlAdapter
{
Prado::trace("ActivePage renderCallbackResponse()",'System.Web.UI.ActiveControls.TActivePageAdapter');
$this->renderResponse($writer);
- }
-
+ }
+
/**
* Renders the callback response by adding additional callback data and
* javascript actions in the header and page state if required.
@@ -119,7 +120,7 @@ class TActivePageAdapter extends TControlAdapter
$response->appendHeader(self::CALLBACK_DATA_HEADER.': '.$data);
}
}
-
+
//sends page state in header
if(($handler = $this->getCallbackEventTarget()) !== null)
{
@@ -129,7 +130,7 @@ class TActivePageAdapter extends TControlAdapter
$response->appendHeader(self::CALLBACK_PAGESTATE_HEADER.': '.$pagestate);
}
}
-
+
//safari must receive at least 1 byte of data.
$writer->write(" ");
@@ -140,7 +141,7 @@ class TActivePageAdapter extends TControlAdapter
$this->getPage()->getClientScript()->renderEndScripts($writer);
$this->getPage()->getCallbackClient()->evaluateScript($writer);
}
-
+
//output the actions
$executeJavascript = $this->getCallbackClientHandler()->getClientFunctionsToExecute();
$actions = TJavascript::jsonEncode($executeJavascript);
@@ -176,7 +177,7 @@ class TActivePageAdapter extends TControlAdapter
throw new TInvalidCallbackException('callback_invalid_target', $target);
}
}
-
+
/**
* @return TControl the control responsible for the current callback event,
* null if nonexistent
@@ -215,7 +216,7 @@ class TActivePageAdapter extends TControlAdapter
}
return $this->_callbackEventParameter;
}
-
+
/**
* @param mixed postback event parameter
*/
@@ -223,10 +224,10 @@ class TActivePageAdapter extends TControlAdapter
{
$this->_callbackEventParameter=$value;
}
-
+
/**
* Gets the callback client script handler. It handlers the javascript functions
- * to be executed during the callback response.
+ * to be executed during the callback response.
* @return TCallbackClientScript callback client handler.
*/
public function getCallbackClientHandler()
@@ -234,23 +235,30 @@ class TActivePageAdapter extends TControlAdapter
if(is_null($this->_callbackClient))
$this->_callbackClient = new TCallbackClientScript;
return $this->_callbackClient;
- }
+ }
}
/**
* TCallbackEventParameter class.
- *
+ *
* The TCallbackEventParameter provides the parameter passed during the callback
* requestion in the {@link getParameter Parameter} property. The
- * callback response response content (e.g. new HTML content) can be written to
- * the {@link getOutput Output} property, which returns an instance of
- * THtmlWriter. The response data (i.e., passing results back to the client-side
- * callback handler function) can be set using {@link setData Data} property.
- *
+ * callback response content (e.g. new HTML content) must be rendered
+ * using an THtmlWriter obtained from the {@link getNewWriter NewWriter}
+ * property, which returns a NEW instance of TCallbackResponseWriter.
+ *
+ * Each instance TCallbackResponseWriter is associated with a unique
+ * boundary delimited. By default each panel only renders its own content.
+ * To replace the content of ONE panel with that of rendered from multiple panels
+ * use the same writer instance for the panels to be rendered.
+ *
+ * The response data (i.e., passing results back to the client-side
+ * callback handler function) can be set using {@link setData Data} property.
+ *
* @author Wei Zhuo
* @version $Revision: $ $Date: $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TCallbackEventParameter extends TEventParameter
{
@@ -273,13 +281,13 @@ class TCallbackEventParameter extends TEventParameter
}
/**
- * @return THtmlWriter holds the response content.
+ * @return TCallbackResponseWriter holds the response content.
*/
- public function getOutput()
+ public function getNewWriter()
{
return $this->_response->createHtmlWriter(null);
}
-
+
/**
* @return mixed callback request parameter.
*/
@@ -287,7 +295,7 @@ class TCallbackEventParameter extends TEventParameter
{
return $this->_parameter;
}
-
+
/**
* @param mixed callback response data.
*/
@@ -295,7 +303,7 @@ class TCallbackEventParameter extends TEventParameter
{
$this->_response->getAdapter()->setResponseData($value);
}
-
+
/**
* @return mixed callback response data.
*/
@@ -307,7 +315,7 @@ class TCallbackEventParameter extends TEventParameter
/**
* TCallbackErrorHandler class.
- *
+ *
* Captures errors and exceptions and send them back during callback response.
* When the application is in debug mode, the error and exception stack trace
* are shown. A TJavascriptLogger must be present on the client-side to view
@@ -316,7 +324,7 @@ class TCallbackEventParameter extends TEventParameter
* @author Wei Zhuo
* @version $Revision: $ Sun Jun 18 19:11:47 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TCallbackErrorHandler extends TErrorHandler
{
@@ -330,7 +338,7 @@ class TCallbackErrorHandler extends TErrorHandler
if($this->getApplication()->getMode()===TApplication::STATE_DEBUG)
{
$response = $this->getApplication()->getResponse();
- $trace = TJavascript::jsonEncode($this->getExceptionStackTrace($exception));
+ $trace = TJavascript::jsonEncode($this->getExceptionStackTrace($exception));
$response->appendHeader('HTTP/1.0 500 Internal Error');
$response->appendHeader(TActivePageAdapter::CALLBACK_ERROR_HEADER.': '.$trace);
}
@@ -341,7 +349,7 @@ class TCallbackErrorHandler extends TErrorHandler
}
$this->getApplication()->getResponse()->flush();
}
-
+
/**
* @param Exception exception details.
* @return array exception stack trace details.
@@ -376,10 +384,10 @@ class TCallbackErrorHandler extends TErrorHandler
* @author Wei Zhuo
* @version $Revision: $ Sun Jun 18 19:17:13 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TInvalidCallbackException extends TException
{
-}
+}
?>
\ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActivePanel.php b/framework/Web/UI/ActiveControls/TActivePanel.php
index 467209ef..45817541 100644
--- a/framework/Web/UI/ActiveControls/TActivePanel.php
+++ b/framework/Web/UI/ActiveControls/TActivePanel.php
@@ -27,14 +27,14 @@ Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
*
* function callback1_requested($sender, $param)
* {
- * $this->panel1->flush($param->getOutput());
+ * $this->panel1->render($param->getNewWriter());
* }
*
*
* @author Wei Zhuo
* @version $Revision: $ Sun Jun 18 01:23:54 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActivePanel extends TPanel implements IActiveControl
{
diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButton.php b/framework/Web/UI/ActiveControls/TActiveRadioButton.php
index 334de3a1..cb4e7ef1 100644
--- a/framework/Web/UI/ActiveControls/TActiveRadioButton.php
+++ b/framework/Web/UI/ActiveControls/TActiveRadioButton.php
@@ -28,7 +28,7 @@
* @author Wei Zhuo
* @version $Revision: $ Mon Jun 26 00:47:14 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActiveRadioButton extends TRadioButton implements IActiveControl, ICallbackEventHandler
{
diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
index daaaf9aa..a54fa2d5 100644
--- a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
+++ b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
@@ -25,7 +25,7 @@
* @author Wei Zhuo
* @version : $ Mon Jun 26 00:48:08 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActiveRadioButtonList extends TRadioButtonList implements IActiveControl, ICallbackEventHandler
{
diff --git a/framework/Web/UI/ActiveControls/TActiveTextBox.php b/framework/Web/UI/ActiveControls/TActiveTextBox.php
index 950a5dcb..20358a36 100644
--- a/framework/Web/UI/ActiveControls/TActiveTextBox.php
+++ b/framework/Web/UI/ActiveControls/TActiveTextBox.php
@@ -17,7 +17,7 @@ Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
/**
* TActiveTextBox class.
- *
+ *
* TActiveTextBox allows the {@link setText Text} property of the textbox to
* be changed during callback. When {@link setAutoPostBack AutoPostBack} property
* is true, changes to the textbox contents will perform a callback request causing
@@ -27,7 +27,7 @@ Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
* @author Wei Zhuo
* @version $Revision: $ Sun Jun 18 20:05:16 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TActiveTextBox extends TTextBox implements ICallbackEventHandler, IActiveControl
{
@@ -41,7 +41,7 @@ class TActiveTextBox extends TTextBox implements ICallbackEventHandler, IActiveC
parent::__construct();
$this->setAdapter(new TActiveControlAdapter($this));
}
-
+
/**
* @return TBaseActiveCallbackControl standard callback control options.
*/
@@ -60,18 +60,18 @@ class TActiveTextBox extends TTextBox implements ICallbackEventHandler, IActiveC
if($this->getActiveControl()->canUpdateClientSide() && $this->getHasLoadedPostData())
$this->getPage()->getCallbackClient()->setValue($this, $value);
}
-
+
/**
* Raises the callback event. This method is required by {@link
- * ICallbackEventHandler} interface.
+ * 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
diff --git a/framework/Web/UI/ActiveControls/TAutoComplete.php b/framework/Web/UI/ActiveControls/TAutoComplete.php
index f64e48aa..fe446f99 100644
--- a/framework/Web/UI/ActiveControls/TAutoComplete.php
+++ b/framework/Web/UI/ActiveControls/TAutoComplete.php
@@ -17,25 +17,25 @@ Prado::using('System.Web.UI.ActiveControls.TActiveTextBox');
/**
* TAutoComplete class.
- *
- * TAutoComplete is a textbox that provides a list of suggestion on
+ *
+ * TAutoComplete is a textbox that provides a list of suggestion on
* the current partial word typed in the textbox. The suggestions are
* requested using callbacks, and raises the {@link onSuggestion OnSuggestion}
* event. The events of the TActiveText (from which TAutoComplete is extended from)
* and {@link onSuggestion OnSuggestion} are mutually exculsive. That is,
* if {@link onTextChange OnTextChange} and/or {@link onCallback OnCallback}
* events are raise, then {@link onSuggestion OnSuggestion} will not be raise, and
- * vice versa.
- *
+ * vice versa.
+ *
* The list of suggestions should be set in the {@link onSuggestion OnSuggestion}
- * event handler. The partial word to match the suggestion is in the
+ * event handler. The partial word to match the suggestion is in the
* {@link TCallbackEventParameter::getParameter TCallbackEventParameter::Parameter}
* property. The datasource of the TAutoComplete must be set using {@link setDataSource}
* method. This sets the datasource for the suggestions repeater, available through
- * the {@link getSuggestions Suggestions} property. Header, footer templates and
+ * the {@link getSuggestions Suggestions} property. Header, footer templates and
* other properties of the repeater can be access via the {@link getSuggestions Suggestions}
* property (e.g. they can be set in the .page templates).
- *
+ *
* To return the list of suggestions back to the browser, in your {@link onSuggestion OnSuggestion}
* event handler, do
*
@@ -44,27 +44,27 @@ Prado::using('System.Web.UI.ActiveControls.TActiveTextBox');
* $token = $param->getParameter(); //the partial word to match
* $sender->setDataSource($this->getSuggestionsFor($token)); //set suggestions
* $sender->dataBind();
- * $sender->flush($param->getOutput()); //sends suggestion back to browser.
+ * $sender->render($param->getNewWriter()); //sends suggestion back to browser.
* }
*
- *
+ *
* TAutoComplete allows multiple suggestions within one textbox with each
- * word or phrase separated by any characters specified in the
+ * word or phrase separated by any characters specified in the
* {@link setSeparator Separator} property. The {@link setFrequency Frequency}
* and {@link setMinChars MinChars} properties sets the delay and minimum number
* of characters typed, respectively, before requesting for sugggestions.
- *
+ *
* Use {@link onTextChange OnTextChange} and/or {@link onCallback OnCallback} events
* to handle post backs due to {@link setAutoPostBack AutoPostBack}.
- *
+ *
* In the {@link getSuggestions Suggestions} TRepater item template, all HTML text elements
* are considered as text for the suggestion. Text within HTML elements with CSS class name
* "informal" are ignored as text for suggestions.
*
* @author Wei Zhuo
* @version $Revision: $ Mon Jun 19 03:50:05 EST 2006 $
- * @package System
- * @since 3.0
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
*/
class TAutoComplete extends TActiveTextBox implements INamingContainer
{
@@ -76,7 +76,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
* @var TPanel result panel holding the suggestion items.
*/
private $_resultPanel=null;
-
+
/**
* @return string word or token separators (delimiters).
*/
@@ -84,7 +84,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
{
return $this->getViewState('tokens', '');
}
-
+
/**
* @return string word or token separators (delimiters).
*/
@@ -92,7 +92,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
{
$this->setViewState('tokens', TPropertyValue::ensureString($value), '');
}
-
+
/**
* @return float maximum delay (in seconds) before requesting a suggestion.
*/
@@ -100,7 +100,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
{
return $this->getViewState('frequency', '');
}
-
+
/**
* @param float maximum delay (in seconds) before requesting a suggestion.
* Default is 0.4.
@@ -109,7 +109,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
{
$this->setViewState('frequency', TPropertyValue::ensureFloat($value),'');
}
-
+
/**
* @return integer minimum number of characters before requesting a suggestion.
*/
@@ -117,7 +117,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
{
return $this->getViewState('minChars','');
}
-
+
/**
* @param integer minimum number of characters before requesting a suggestion.
*/
@@ -125,17 +125,17 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
{
$this->setViewState('minChars', TPropertyValue::ensureInteger($value), '');
}
-
+
/**
* Raises the callback event. This method is overrides the parent implementation.
- * If {@link setAutoPostBack AutoPostBack} is enabled it will raise
- * {@link onTextChanged OnTextChanged} event event and then the
+ * If {@link setAutoPostBack AutoPostBack} is enabled it will raise
+ * {@link onTextChanged OnTextChanged} event event and then the
* {@link onCallback OnCallback} event. The {@link onSuggest OnSuggest} event is
* raise if the request is to find sugggestions, the {@link onTextChanged OnTextChanged}
* and {@link onCallback OnCallback} events are NOT raised.
* This method is mainly used by framework and control developers.
* @param TCallbackEventParameter the event parameter
- */
+ */
public function raiseCallbackEvent($param)
{
$token = $param->getParameter();
@@ -149,17 +149,17 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
}
/**
- * This method is invoked when a autocomplete suggestion is requested.
+ * This method is invoked when a autocomplete suggestion is requested.
* The method raises 'OnSuggest' event. 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 onSuggest($param)
{
$this->raiseEvent('OnSuggest', $this, $param);
}
-
+
/**
* @param array data source for suggestions.
*/
@@ -167,7 +167,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
{
$this->getSuggestions()->setDataSource($data);
}
-
+
/**
* @return TPanel suggestion results panel.
*/
@@ -177,7 +177,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
$this->_resultPanel = $this->createResultPanel();
return $this->_resultPanel;
}
-
+
/**
* @return TPanel new instance of result panel. Default uses TPanel.
*/
@@ -188,7 +188,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
$panel->setID('result');
return $panel;
}
-
+
/**
* @return TRepeater suggestion list repeater
*/
@@ -198,7 +198,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
$this->_repeater = $this->createRepeater();
return $this->_repeater;
}
-
+
/**
* @return TRepeater new instance of TRepater to render the list of suggestions.
*/
@@ -221,22 +221,24 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
parent::renderEndTag($writer);
$this->renderResultPanel($writer);
}
-
+
/**
* Renders the result panel.
* @param THtmlWriter the renderer.
*/
protected function renderResultPanel($writer)
{
- $this->getResultPanel()->render($writer);
+ $this->getResultPanel()->render($writer);
}
-
+
/**
* Flush and returns the suggestions content back to the browser client.
* @param THtmlWriter the renderer.
*/
- public function flush($writer)
+ public function render($writer)
{
+ if(!$this->getPage()->getIsCallback())
+ parent::render($writer);
if($this->getActiveControl()->canUpdateClientSide())
$this->renderSuggestions($writer);
}
@@ -249,12 +251,12 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
{
if($this->getSuggestions()->getItems()->getCount() > 0)
{
- $this->getSuggestions()->render($writer);
+ $this->getSuggestions()->render($writer);
$boundary = $writer->getWriter()->getBoundary();
$this->getResponse()->getAdapter()->setResponseData($boundary);
- }
+ }
}
-
+
/**
* @return array list of callback options.
*/
@@ -266,7 +268,7 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
$string = strtr($string,array('\t'=>"\t",'\n'=>"\n",'\r'=>"\r"));
$token = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY);
$options['tokens'] = TJavascript::encode($token,false);
- }
+ }
if($this->getAutoPostBack())
{
$options = array_merge($options,$this->getPostBackOptions());
@@ -277,15 +279,15 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
$options['EventTarget'] = $this->getUniqueID();
return $options;
}
-
+
/**
- * Override parent implementation, no javascript is rendered here instead
+ * 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.
@@ -305,21 +307,24 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer
protected function getClientClassName()
{
return 'Prado.WebUI.TAutoComplete';
- }
+ }
}
/**
- * TWizardSideBarTemplate class.
- * TWizardSideBarTemplate is the default template for wizard sidebar.
- * @author Qiang Xue
- * @version $Revision: $ $Date: $
- * @package System.Web.UI.WebControls
- * @since 3.0
+ * TAutoCompleteTemplate class.
+ *
+ * TAutoCompleteTemplate is the default template for TAutoCompleteTemplate
+ * item template.
+ *
+ * @author Wei Zhuo
+ * @version $Revision: $ Mon Jun 19 03:50:05 EST 2006 $
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
*/
class TAutoCompleteTemplate extends TComponent implements ITemplate
{
private $_template;
-
+
public function __construct($template)
{
$this->_template = $template;
diff --git a/framework/Web/UI/ActiveControls/TBaseActiveControl.php b/framework/Web/UI/ActiveControls/TBaseActiveControl.php
index c368cb68..e5fe8f16 100644
--- a/framework/Web/UI/ActiveControls/TBaseActiveControl.php
+++ b/framework/Web/UI/ActiveControls/TBaseActiveControl.php
@@ -10,7 +10,7 @@
* @package System.Web.UI.ActiveControls
*/
-Prado::using('System.Web.UI.ActiveControls.TCallbackClientSideOptions');
+Prado::using('System.Web.UI.ActiveControls.TCallbackClientSide');
/**
* TBaseActiveControl class provided additional basic property for every
@@ -25,7 +25,7 @@ Prado::using('System.Web.UI.ActiveControls.TCallbackClientSideOptions');
* @author Wei Zhuo
* @version $Revision: $ $Date: $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TBaseActiveControl extends TComponent
{
@@ -154,21 +154,21 @@ class TBaseActiveControl extends TComponent
* @author Wei Zhuo
* @version $Revision: $ Fri Jun 16 08:40:43 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TBaseActiveCallbackControl extends TBaseActiveControl
{
/**
* Callback client-side options can be set by setting the properties of
* the ClientSide property. E.g.
- * See {@link TCallbackClientSideOptions} for details on the properties of ClientSide.
- * @return TCallbackClientSideOptions client-side callback options.
+ * See {@link TCallbackClientSide} for details on the properties of ClientSide.
+ * @return TCallbackClientSide client-side callback options.
*/
public function getClientSide()
{
if(is_null($client = $this->getOption('ClientSide')))
{
- $client = $this->createClientSideOptions();
+ $client = $this->createClientSide();
$this->setOption('ClientSide', $client);
}
return $client;
@@ -176,7 +176,7 @@ class TBaseActiveCallbackControl extends TBaseActiveControl
/**
* Sets the client side options. Can only be set when client side is null.
- * @param TCallbackClientSideOptions client side options.
+ * @param TCallbackClientSide client side options.
*/
public function setClientSide($client)
{
@@ -188,11 +188,11 @@ class TBaseActiveCallbackControl extends TBaseActiveControl
}
/**
- * @return TCallbackClientSideOptions callback client-side options.
+ * @return TCallbackClientSide callback client-side options.
*/
- protected function createClientSideOptions()
+ protected function createClientSide()
{
- return new TCallbackClientSideOptions;
+ return new TCallbackClientSide;
}
/**
diff --git a/framework/Web/UI/ActiveControls/TCallback.php b/framework/Web/UI/ActiveControls/TCallback.php
index e87cea11..22d6a01e 100644
--- a/framework/Web/UI/ActiveControls/TCallback.php
+++ b/framework/Web/UI/ActiveControls/TCallback.php
@@ -20,9 +20,9 @@ Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
*
* The TCallback provides a basic callback handler that can be invoke from the
* client side by running the javascript code obtained from the
- * {@link TBaseActiveCallbackControl::getJavascript ActiveControl.Javascript} property.
+ * {@link TBaseActiveCallbackControl::getJavascript ActiveControl.Javascript} property.
* The event {@link onCallback OnCallback} is raise when a callback is requested made.
- *
+ *
* Example usage:
*
*
@@ -38,10 +38,10 @@ Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
* @author Wei Zhuo
* @version $Revision: $ $Date: $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TCallback extends TControl implements ICallbackEventHandler, IActiveControl
-{
+{
/**
* Creates a new callback control, sets the adapter to
* TActiveControlAdapter. If you override this class, be sure to set the
@@ -60,7 +60,7 @@ class TCallback extends TControl implements ICallbackEventHandler, IActiveContro
{
return $this->getAdapter()->getBaseActiveControl();
}
-
+
/**
* Raises the callback event. This method is required by {@link
* ICallbackEventHandler} interface. If {@link getCausesValidation
@@ -69,25 +69,25 @@ class TCallback extends TControl implements ICallbackEventHandler, IActiveContro
* OnCallback} event. This method is mainly used by framework and control
* developers.
* @param TCallbackEventParameter the event parameter
- */
+ */
public function raiseCallbackEvent($param)
{
if($this->getActiveControl()->canCauseValidation())
$this->getPage()->validate($this->getActiveControl()->getValidationGroup());
$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 dbfa935f..4aa3efc6 100644
--- a/framework/Web/UI/ActiveControls/TCallbackClientScript.php
+++ b/framework/Web/UI/ActiveControls/TCallbackClientScript.php
@@ -30,7 +30,7 @@
* @author Wei Zhuo
* @version $Revision: $ $Date: $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TCallbackClientScript extends TApplicationComponent
{
diff --git a/framework/Web/UI/ActiveControls/TCallbackClientSide.php b/framework/Web/UI/ActiveControls/TCallbackClientSide.php
new file mode 100644
index 00000000..6d298a4f
--- /dev/null
+++ b/framework/Web/UI/ActiveControls/TCallbackClientSide.php
@@ -0,0 +1,304 @@
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2005 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Revision: $ $Date: $
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * TCallbackClientSide class.
+ *
+ * The following client side events are executing in order if the callback
+ * request and response are send and received successfuly.
+ *
+ * - onUninitialized executed when callback request is uninitialized.
+ * - onLoading executed when callback request is initiated
+ * - onLoaded executed when callback request begins.
+ * - onInteractive executed when callback request is in progress.
+ * - onCompleteexecuted when callback response returns.
+ *
+ * The OnSuccess and OnFailure events are raised when the
+ * response is returned. A successful request/response will raise
+ * OnSuccess event otherwise OnFailure will be raised.
+ *
+ * - onSuccess executed when callback request returns and is successful.
+ * - onFailure executed when callback request returns and fails.
+ * - onException raised when callback request fails due to
+ * request/response errors.
+ *
+ * - PostInputs true to collect the form inputs and post them during
+ * callback, default is true.
+ * - RequestTimeOut The request timeout in milliseconds.
+ * - HasPriority true to ensure that the callback request will be sent
+ * immediately and will abort existing prioritized requests. It does not affect
+ * callbacks that are not prioritized.
+ * - EnablePageStateUpdate enable the callback response to enable the
+ * viewstate update. This will automatically set HasPrority to true when
+ * enabled.
+ *
+ * @author Wei Zhuo
+ * @version $Revision: $ $Date: $
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TCallbackClientSide extends TClientSideOptions
+{
+ /**
+ * Returns javascript statement enclosed within a javascript function.
+ * @param string javascript statement, if string begins within
+ * "javascript:" the whole string is assumed to be a function.
+ * @return string javascript statement wrapped in a javascript function
+ */
+ protected function ensureFunction($javascript)
+ {
+ return "function(sender, parameter){ {$javascript} }";
+ }
+
+ /**
+ * @return string javascript code for client-side onUninitialized event
+ */
+ public function getOnUninitialized()
+ {
+ return $this->getOption('onUninitialized');
+ }
+
+ /**
+ * @param string javascript code for client-side onUninitialized event.
+ */
+ public function setOnUninitialized($javascript)
+ {
+ $this->setFunction('onUninitialized', $javascript);
+ }
+
+ /**
+ * @return string javascript code for client-side onLoading event
+ */
+ public function getOnLoading()
+ {
+ return $this->getOption('onLoading');
+ }
+
+ /**
+ * @param string javascript code for client-side onLoading event.
+ */
+ public function setOnLoading($javascript)
+ {
+ $this->setFunction('onLoading', $javascript);
+ }
+
+ /**
+ * @return string javascript code for client-side onLoaded event
+ */
+ public function getOnLoaded()
+ {
+ return $this->getOption('onLoaded');
+ }
+
+ /**
+ * @param string javascript code for client-side onLoaded event.
+ */
+ public function setOnLoaded($javascript)
+ {
+ $this->setFunction('onLoaded', $javascript);
+ }
+ /**
+ * @return string javascript code for client-side onInteractive event
+ */
+ public function getOnInteractive()
+ {
+ return $this->getOption('onInteractive');
+ }
+
+ /**
+ * @param string javascript code for client-side onInteractive event.
+ */
+ public function setonInteractive($javascript)
+ {
+ $this->setFunction('onInteractive', $javascript);
+ }
+ /**
+ * @return string javascript code for client-side onComplete event
+ */
+ public function getOnComplete()
+ {
+ return $this->getOption('onComplete');
+ }
+
+ /**
+ * @param string javascript code for client-side onComplete event.
+ */
+ public function setOnComplete($javascript)
+ {
+ $this->setFunction('onComplete', $javascript);
+ }
+ /**
+ * @return string javascript code for client-side onSuccess event
+ */
+ public function getOnSuccess()
+ {
+ return $this->getOption('onSuccess');
+ }
+
+ /**
+ * @param string javascript code for client-side onSuccess event.
+ */
+ public function setOnSuccess($javascript)
+ {
+ $this->setFunction('onSuccess', $javascript);
+ }
+
+ /**
+ * @return string javascript code for client-side onFailure event
+ */
+ public function getOnFailure()
+ {
+ return $this->getOption('onFailure');
+ }
+
+ /**
+ * @param string javascript code for client-side onFailure event.
+ */
+ public function setOnFailure($javascript)
+ {
+ $this->setFunction('onFailure', $javascript);
+ }
+
+ /**
+ * @return string javascript code for client-side onException event
+ */
+ public function getOnException()
+ {
+ return $this->getOption('onException');
+ }
+
+ /**
+ * @param string javascript code for client-side onException event.
+ */
+ public function setOnException($javascript)
+ {
+ $this->setFunction('onException', $javascript);
+ }
+
+ /**
+ * @return boolean true to post the inputs of the form on callback, default
+ * is post the inputs on callback.
+ */
+ public function getPostState()
+ {
+ return $this->getOption('PostInputs');
+ }
+
+ /**
+ * @param boolean true to post the inputs of the form with callback
+ * requests. Default is to post the inputs.
+ */
+ public function setPostState($value)
+ {
+ $this->setOption('PostInputs', TPropertyValue::ensureBoolean($value));
+ }
+
+ /**
+ * @return integer callback request timeout.
+ */
+ public function getRequestTimeOut()
+ {
+ return $this->getOption('RequestTimeOut');
+ }
+
+ /**
+ * @param integer callback request timeout
+ */
+ public function setRequestTimeOut($value)
+ {
+ $this->setOption('RequestTimeOut', TPropertyValue::ensureInteger($value));
+ }
+
+ /**
+ * @return boolean true if the callback request has priority and will abort
+ * existing prioritized request in order to send immediately. It does not
+ * affect callbacks that are not prioritized. Default is true.
+ */
+ public function getHasPriority()
+ {
+ $option = $this->getOption('HasPriority');
+ return is_null($option) ? true : $option;
+ }
+
+ /**
+ * @param boolean true to ensure that the callback request will be sent
+ * immediately and will abort existing prioritized requests. It does not
+ * affect callbacks that are not prioritized.
+ */
+ public function setHasPriority($value)
+ {
+ $hasPriority = TPropertyValue::ensureBoolean($value);
+ $this->setOption('HasPriority', $hasPriority);
+ if(!$hasPriority)
+ $this->setEnablePageStateUpdate(false);
+ }
+
+ /**
+ * Set to true to enable the callback response to enable the viewstate
+ * update. This will automatically set HasPrority to true.
+ * @param boolean true enables the callback response to update the
+ * viewstate.
+ */
+ public function setEnablePageStateUpdate($value)
+ {
+ $enabled = TPropertyValue::ensureBoolean($value);
+ $this->setOption('EnablePageStateUpdate', $enabled);
+ if($enabled)
+ $this->setHasPriority(true);
+ }
+
+ /**
+ * @return boolean client-side viewstate will be updated on callback
+ * response if true. Default is true.
+ */
+ public function getEnablePageStateUpdate()
+ {
+ $option = $this->getOption('EnablePageStateUpdate');
+ return is_null($option) ? true : $option;
+ }
+
+ /**
+ * @return string post back target ID
+ */
+ public function getPostBackTarget()
+ {
+ return $this->getOption('EventTarget');
+ }
+
+ /**
+ * @param string post back target ID
+ */
+ public function setPostBackTarget($value)
+ {
+ if($value instanceof TControl)
+ $value = $value->getUniqueID();
+ $this->setOption('EventTarget', $value);
+ }
+
+ /**
+ * @return string post back event parameter.
+ */
+ public function getPostBackParameter()
+ {
+ return $this->getOption('EventParameter');
+ }
+
+ /**
+ * @param string post back event parameter.
+ */
+ public function setPostBackParameter($value)
+ {
+ $this->setOption('EventParameter', $value);
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php b/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php
deleted file mode 100644
index e8c2dc26..00000000
--- a/framework/Web/UI/ActiveControls/TCallbackClientSideOptions.php
+++ /dev/null
@@ -1,304 +0,0 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2005 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Revision: $ $Date: $
- * @package System.Web.UI.ActiveControls
- */
-
-/**
- * TCallbackClientSideOptions class.
- *
- * The following client side events are executing in order if the callback
- * request and response are send and received successfuly.
- *
- * - onUninitialized executed when callback request is uninitialized.
- * - onLoading executed when callback request is initiated
- * - onLoaded executed when callback request begins.
- * - onInteractive executed when callback request is in progress.
- * - onCompleteexecuted when callback response returns.
- *
- * The OnSuccess and OnFailure events are raised when the
- * response is returned. A successful request/response will raise
- * OnSuccess event otherwise OnFailure will be raised.
- *
- * - onSuccess executed when callback request returns and is successful.
- * - onFailure executed when callback request returns and fails.
- * - onException raised when callback request fails due to
- * request/response errors.
- *
- * - PostInputs true to collect the form inputs and post them during
- * callback, default is true.
- * - RequestTimeOut The request timeout in milliseconds.
- * - HasPriority true to ensure that the callback request will be sent
- * immediately and will abort existing prioritized requests. It does not affect
- * callbacks that are not prioritized.
- * - EnablePageStateUpdate enable the callback response to enable the
- * viewstate update. This will automatically set HasPrority to true when
- * enabled.
- *
- * @author Wei Zhuo
- * @version $Revision: $ $Date: $
- * @package System.Web.UI.ActiveControls
- * @since 3.0
- */
-class TCallbackClientSideOptions extends TClientSideOptions
-{
- /**
- * Returns javascript statement enclosed within a javascript function.
- * @param string javascript statement, if string begins within
- * "javascript:" the whole string is assumed to be a function.
- * @return string javascript statement wrapped in a javascript function
- */
- protected function ensureFunction($javascript)
- {
- return "function(request, result){ {$javascript} }";
- }
-
- /**
- * @return string javascript code for client-side onUninitialized event
- */
- public function getOnUninitialized()
- {
- return $this->getOption('onUninitialized');
- }
-
- /**
- * @param string javascript code for client-side onUninitialized event.
- */
- public function setOnUninitialized($javascript)
- {
- $this->setFunction('onUninitialized', $javascript);
- }
-
- /**
- * @return string javascript code for client-side onLoading event
- */
- public function getOnLoading()
- {
- return $this->getOption('onLoading');
- }
-
- /**
- * @param string javascript code for client-side onLoading event.
- */
- public function setOnLoading($javascript)
- {
- $this->setFunction('onLoading', $javascript);
- }
-
- /**
- * @return string javascript code for client-side onLoaded event
- */
- public function getOnLoaded()
- {
- return $this->getOption('onLoaded');
- }
-
- /**
- * @param string javascript code for client-side onLoaded event.
- */
- public function setOnLoaded($javascript)
- {
- $this->setFunction('onLoaded', $javascript);
- }
- /**
- * @return string javascript code for client-side onInteractive event
- */
- public function getOnInteractive()
- {
- return $this->getOption('onInteractive');
- }
-
- /**
- * @param string javascript code for client-side onInteractive event.
- */
- public function setonInteractive($javascript)
- {
- $this->setFunction('onInteractive', $javascript);
- }
- /**
- * @return string javascript code for client-side onComplete event
- */
- public function getOnComplete()
- {
- return $this->getOption('onComplete');
- }
-
- /**
- * @param string javascript code for client-side onComplete event.
- */
- public function setOnComplete($javascript)
- {
- $this->setFunction('onComplete', $javascript);
- }
- /**
- * @return string javascript code for client-side onSuccess event
- */
- public function getOnSuccess()
- {
- return $this->getOption('onSuccess');
- }
-
- /**
- * @param string javascript code for client-side onSuccess event.
- */
- public function setOnSuccess($javascript)
- {
- $this->setFunction('onSuccess', $javascript);
- }
-
- /**
- * @return string javascript code for client-side onFailure event
- */
- public function getOnFailure()
- {
- return $this->getOption('onFailure');
- }
-
- /**
- * @param string javascript code for client-side onFailure event.
- */
- public function setOnFailure($javascript)
- {
- $this->setFunction('onFailure', $javascript);
- }
-
- /**
- * @return string javascript code for client-side onException event
- */
- public function getOnException()
- {
- return $this->getOption('onException');
- }
-
- /**
- * @param string javascript code for client-side onException event.
- */
- public function setOnException($javascript)
- {
- $this->setFunction('onException', $javascript);
- }
-
- /**
- * @return boolean true to post the inputs of the form on callback, default
- * is post the inputs on callback.
- */
- public function getPostState()
- {
- return $this->getOption('PostInputs');
- }
-
- /**
- * @param boolean true to post the inputs of the form with callback
- * requests. Default is to post the inputs.
- */
- public function setPostState($value)
- {
- $this->setOption('PostInputs', TPropertyValue::ensureBoolean($value));
- }
-
- /**
- * @return integer callback request timeout.
- */
- public function getRequestTimeOut()
- {
- return $this->getOption('RequestTimeOut');
- }
-
- /**
- * @param integer callback request timeout
- */
- public function setRequestTimeOut($value)
- {
- $this->setOption('RequestTimeOut', TPropertyValue::ensureInteger($value));
- }
-
- /**
- * @return boolean true if the callback request has priority and will abort
- * existing prioritized request in order to send immediately. It does not
- * affect callbacks that are not prioritized. Default is true.
- */
- public function getHasPriority()
- {
- $option = $this->getOption('HasPriority');
- return is_null($option) ? true : $option;
- }
-
- /**
- * @param boolean true to ensure that the callback request will be sent
- * immediately and will abort existing prioritized requests. It does not
- * affect callbacks that are not prioritized.
- */
- public function setHasPriority($value)
- {
- $hasPriority = TPropertyValue::ensureBoolean($value);
- $this->setOption('HasPriority', $hasPriority);
- if(!$hasPriority)
- $this->setEnablePageStateUpdate(false);
- }
-
- /**
- * Set to true to enable the callback response to enable the viewstate
- * update. This will automatically set HasPrority to true.
- * @param boolean true enables the callback response to update the
- * viewstate.
- */
- public function setEnablePageStateUpdate($value)
- {
- $enabled = TPropertyValue::ensureBoolean($value);
- $this->setOption('EnablePageStateUpdate', $enabled);
- if($enabled)
- $this->setHasPriority(true);
- }
-
- /**
- * @return boolean client-side viewstate will be updated on callback
- * response if true. Default is true.
- */
- public function getEnablePageStateUpdate()
- {
- $option = $this->getOption('EnablePageStateUpdate');
- return is_null($option) ? true : $option;
- }
-
- /**
- * @return string post back target ID
- */
- public function getPostBackTarget()
- {
- return $this->getOption('EventTarget');
- }
-
- /**
- * @param string post back target ID
- */
- public function setPostBackTarget($value)
- {
- if($value instanceof TControl)
- $value = $value->getUniqueID();
- $this->setOption('EventTarget', $value);
- }
-
- /**
- * @return string post back event parameter.
- */
- public function getPostBackParameter()
- {
- return $this->getOption('EventParameter');
- }
-
- /**
- * @param string post back event parameter.
- */
- public function setPostBackParameter($value)
- {
- $this->setOption('EventParameter', $value);
- }
-}
-
-?>
\ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TCallbackOptions.php b/framework/Web/UI/ActiveControls/TCallbackOptions.php
index 588cbf8a..9a603b6f 100644
--- a/framework/Web/UI/ActiveControls/TCallbackOptions.php
+++ b/framework/Web/UI/ActiveControls/TCallbackOptions.php
@@ -12,42 +12,42 @@
/**
* TCallbackOptions class.
- *
+ *
* TCallbackOptions allows common set of callback client-side options
* to be attached to other active controls.
*
* @author Wei Zhuo
* @version $Revision: $ Sun Jun 18 08:10:50 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TCallbackOptions extends TControl
-{
+{
/**
- * @var TCallbackClientSideOptions client side callback options.
+ * @var TCallbackClientSide client side callback options.
*/
private $_clientSide;
-
+
/**
* Callback client-side options can be set by setting the properties of
* the ClientSide property. E.g.
- * See {@link TCallbackClientSideOptions} for details on the properties of
+ * See {@link TCallbackClientSide} for details on the properties of
* ClientSide.
- * @return TCallbackClientSideOptions client-side callback options.
+ * @return TCallbackClientSide client-side callback options.
*/
public function getClientSide()
{
if(is_null($this->_clientSide))
- $this->_clientSide = $this->createClientSideOptions();
+ $this->_clientSide = $this->createClientSide();
return $this->_clientSide;
}
-
+
/**
- * @return TCallbackClientSideOptions callback client-side options.
+ * @return TCallbackClientSide callback client-side options.
*/
- protected function createClientSideOptions()
+ protected function createClientSide()
{
- return new TCallbackClientSideOptions;
+ return new TCallbackClientSide;
}
}
diff --git a/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php b/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php
index 8f456b86..d59b66ba 100755
--- a/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php
+++ b/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php
@@ -6,7 +6,7 @@
* @link http://www.pradosoft.com/
* @copyright Copyright © 2006 PradoSoft
* @license http://www.pradosoft.com/license/
- * @version 3.0
+ * @version $Revision: $ Sun Jun 18 07:52:14 EST 2006 $
* @package System.Web.UI.ActiveControls
*/
@@ -24,7 +24,7 @@
* @author Wei Zhuo
* @version $Revision: $ Sun Jun 18 07:52:14 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TCallbackResponseAdapter extends THttpResponseAdapter
{
@@ -91,7 +91,7 @@ class TCallbackResponseAdapter extends THttpResponseAdapter
* @author Wei Zhuo
* @version $Revision: $ Sun Jun 18 08:02:21 EST 2006 $
* @package System.Web.UI.ActiveControls
- * @since 3.0
+ * @since 3.1
*/
class TCallbackResponseWriter extends TTextWriter
{
diff --git a/framework/Web/UI/ActiveControls/TEventTriggeredCallback.php b/framework/Web/UI/ActiveControls/TEventTriggeredCallback.php
index 42f49976..e9b7a1b2 100644
--- a/framework/Web/UI/ActiveControls/TEventTriggeredCallback.php
+++ b/framework/Web/UI/ActiveControls/TEventTriggeredCallback.php
@@ -1,5 +1,29 @@
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Revision: 27/08/2006 $
+ * @package System.Web.UI.ActiveControls
+ */
+/**
+ * TEventTriggeredCallback Class
+ *
+ * Triggers a new callback request when a particular {@link setEventName EventName}
+ * on a control with ID given by {@link setControlID ControlID} is raised.
+ *
+ * The default action of the event on the client-side can be prevented when
+ * {@link setPreventDefaultAction PreventDefaultAction} is set to true.
+ *
+ * @author Wei Zhuo
+ * @version $Revision: $ 27/08/2006 $
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
class TEventTriggeredCallback extends TTriggeredCallback
{
/**
diff --git a/framework/Web/UI/ActiveControls/TPeriodicCallback.php b/framework/Web/UI/ActiveControls/TPeriodicCallback.php
deleted file mode 100644
index e620ac46..00000000
--- a/framework/Web/UI/ActiveControls/TPeriodicCallback.php
+++ /dev/null
@@ -1,147 +0,0 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Revision: $ : $
- * @package System.Web.UI.ActiveControls
- */
-
-/**
- * Load active callback control.
- */
-Prado::using('System.Web.UI.ActiveControls.TCallback');
-
-/**
- * TPeriodicCallback class.
- *
- * TPeriodicCallback sends callback request every {@link setInterval Interval} seconds.
- * Upon each callback request, the {@link onCallback OnCallback} event is raised.
- *
- * The intervals between each request can be increased when the browser is inactive
- * by changing the {@link setDecayRate DecayRate} to a positive number. The
- * default decay rate, {@link setDecayType DecayType}, is linear and can be changed to
- * 'Exponential', 'Linear', 'Quadratic' or 'Cubic'.
- *
- * @author Wei Zhuo
- * @version : $ Mon Jun 19 21:29:42 EST 2006 $
- * @package System.Web.UI.ActiveControls
- * @since 3.0
- */
-class TPeriodicCallback extends TCallback
-{
- /**
- * @return float seconds between callback requests. Default is 1 second.
- */
- public function getInterval()
- {
- return $this->getViewState('Interval', 1);
- }
-
- /**
- * @param float seconds between callback requests, must be a positive number, default is 1 second.
- */
- public function setInterval($value)
- {
- $interval = TPropertyValue::ensureFloat($value);
- if($interval <= 0)
- throw new TConfigurationException('callback_interval_be_positive', $this->getID());
- $this->setViewState('Interval', $interval, 1);
- }
-
- /**
- * Gets the decay rate between callbacks. Default is 0;
- * @return float decay rate between callbacks.
- */
- public function getDecayRate()
- {
- return $this->getViewState('Decay', 0);
- }
-
- /**
- * Sets the decay rate between callback. Default is 0;
- * @param float decay rate between callbacks.
- */
- public function setDecayRate($value)
- {
- $decay = TPropertyValue::ensureFloat($value);
- if($decay < 0)
- throw new TConfigurationException('callback_decay_be_not_negative', $this->getID());
- $this->setViewState('Decay', $decay);
- }
-
- /**
- * @param string Decay type, allows 'Exponential', 'Linear', 'Quadratic' and 'Cubic'. Default is 'Linear'.
- */
- public function setDecayType($value)
- {
- $this->setViewState('DecayType', TPropertyValue::ensureEnum($value,
- 'Exponential', 'Linear', 'Quadratic', 'Cubic'), 'Linear');
- }
-
- /**
- * @return string decay type, default is 'Linear', valid types are 'Exponential', 'Linear', 'Quadratic' and 'Cubic'.
- */
- public function getDecayType()
- {
- return $this->getViewState('DecayType', 'Linear');
- }
-
- /**
- * Registers the javascript code to start the timer.
- */
- public function startTimer()
- {
- $id = $this->getClientID();
- $code = "Prado.WebUI.TPeriodicCallback.start('{$id}');";
- $cs = $this->getPage()->getClientScript();
- $cs->registerEndScript("{$id}:start", $code);
- }
-
- /**
- * Registers the javascript code to stop the timer.
- */
- public function stopTimer()
- {
- $id = $this->getClientID();
- $code = "Prado.WebUI.TPeriodicCallback.stop('{$id}');";
- $cs = $this->getPage()->getClientScript();
- $cs->registerEndScript("{$id}:stop", $code);
- }
-
- /**
- * @return array list of timer options for client-side.
- */
- protected function getTimerOptions()
- {
- $options['ID'] = $this->getClientID();
- $options['Interval'] = $this->getInterval();
- $options['DecayRate'] = $this->getDecayRate();
- $options['DecayType'] = $this->getDecayType();
- return $options;
- }
-
- /**
- * Registers the javascript code for initializing the active control.
- * @param THtmlWriter the renderer.
- */
- public function render($writer)
- {
- parent::render($writer);
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getTimerOptions());
- }
-
- /**
- * @return string corresponding javascript class name for TPeriodicCallback.
- */
- protected function getClientClassName()
- {
- return 'Prado.WebUI.TPeriodicCallback';
- }
-}
-
-?>
\ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php b/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php
new file mode 100644
index 00000000..176539b4
--- /dev/null
+++ b/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php
@@ -0,0 +1,147 @@
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Revision: $ : $
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * Load active callback control.
+ */
+Prado::using('System.Web.UI.ActiveControls.TCallback');
+
+/**
+ * TTimeTriggeredCallback class.
+ *
+ * TTimeTriggeredCallback sends callback request every {@link setInterval Interval} seconds.
+ * Upon each callback request, the {@link onCallback OnCallback} event is raised.
+ *
+ * The intervals between each request can be increased when the browser is inactive
+ * by changing the {@link setDecayRate DecayRate} to a positive number. The
+ * default decay rate, {@link setDecayType DecayType}, is linear and can be changed to
+ * 'Exponential', 'Linear', 'Quadratic' or 'Cubic'.
+ *
+ * @author Wei Zhuo
+ * @version : $ Mon Jun 19 21:29:42 EST 2006 $
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TTimeTriggeredCallback extends TCallback
+{
+ /**
+ * @return float seconds between callback requests. Default is 1 second.
+ */
+ public function getInterval()
+ {
+ return $this->getViewState('Interval', 1);
+ }
+
+ /**
+ * @param float seconds between callback requests, must be a positive number, default is 1 second.
+ */
+ public function setInterval($value)
+ {
+ $interval = TPropertyValue::ensureFloat($value);
+ if($interval <= 0)
+ throw new TConfigurationException('callback_interval_be_positive', $this->getID());
+ $this->setViewState('Interval', $interval, 1);
+ }
+
+ /**
+ * Gets the decay rate between callbacks. Default is 0;
+ * @return float decay rate between callbacks.
+ */
+ public function getDecayRate()
+ {
+ return $this->getViewState('Decay', 0);
+ }
+
+ /**
+ * Sets the decay rate between callback. Default is 0;
+ * @param float decay rate between callbacks.
+ */
+ public function setDecayRate($value)
+ {
+ $decay = TPropertyValue::ensureFloat($value);
+ if($decay < 0)
+ throw new TConfigurationException('callback_decay_be_not_negative', $this->getID());
+ $this->setViewState('Decay', $decay);
+ }
+
+ /**
+ * @param string Decay type, allows 'Exponential', 'Linear', 'Quadratic' and 'Cubic'. Default is 'Linear'.
+ */
+ public function setDecayType($value)
+ {
+ $this->setViewState('DecayType', TPropertyValue::ensureEnum($value,
+ 'Exponential', 'Linear', 'Quadratic', 'Cubic'), 'Linear');
+ }
+
+ /**
+ * @return string decay type, default is 'Linear', valid types are 'Exponential', 'Linear', 'Quadratic' and 'Cubic'.
+ */
+ public function getDecayType()
+ {
+ return $this->getViewState('DecayType', 'Linear');
+ }
+
+ /**
+ * Registers the javascript code to start the timer.
+ */
+ public function startTimer()
+ {
+ $id = $this->getClientID();
+ $code = "Prado.WebUI.TTimeTriggeredCallback.start('{$id}');";
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerEndScript("{$id}:start", $code);
+ }
+
+ /**
+ * Registers the javascript code to stop the timer.
+ */
+ public function stopTimer()
+ {
+ $id = $this->getClientID();
+ $code = "Prado.WebUI.TTimeTriggeredCallback.stop('{$id}');";
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerEndScript("{$id}:stop", $code);
+ }
+
+ /**
+ * @return array list of timer options for client-side.
+ */
+ protected function getTimerOptions()
+ {
+ $options['ID'] = $this->getClientID();
+ $options['Interval'] = $this->getInterval();
+ $options['DecayRate'] = $this->getDecayRate();
+ $options['DecayType'] = $this->getDecayType();
+ return $options;
+ }
+
+ /**
+ * Registers the javascript code for initializing the active control.
+ * @param THtmlWriter the renderer.
+ */
+ public function render($writer)
+ {
+ parent::render($writer);
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getTimerOptions());
+ }
+
+ /**
+ * @return string corresponding javascript class name for TTimeTriggeredCallback.
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TTimeTriggeredCallback';
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TTriggeredCallback.php b/framework/Web/UI/ActiveControls/TTriggeredCallback.php
index 076166c9..2ccdda1a 100644
--- a/framework/Web/UI/ActiveControls/TTriggeredCallback.php
+++ b/framework/Web/UI/ActiveControls/TTriggeredCallback.php
@@ -1,5 +1,26 @@
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Revision: 27/08/2006 $
+ * @package System.Web.UI.ActiveControls
+ */
+/**
+ * TTriggeredCallback abstract Class
+ *
+ * Base class for triggered callback controls. The {@link setControlID ControlID}
+ * property sets the control ID to observe the trigger.
+ *
+ * @author Wei Zhuo
+ * @version $Revision: $ 27/08/2006 $
+ * @package System.package
+ * @since version
+ */
abstract class TTriggeredCallback extends TCallback
{
/**
diff --git a/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php b/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php
index bb50e4f1..ae9263ab 100644
--- a/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php
+++ b/framework/Web/UI/ActiveControls/TValueTriggeredCallback.php
@@ -1,5 +1,34 @@
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Revision: 27/08/2006 $
+ * @package System.Web.UI.ActiveControls
+ */
+/**
+ * TValueTriggeredCallback Class
+ *
+ * Observes the value with {@link setPropertyName PropertyName} of a
+ * control with {@link setControlID ControlID}. Changes to the observed
+ * property value will trigger a new callback request. The values are
+ * observed using a {@link setPollingInterval PollingInterval} (in seconds).
+ * That is, the property is checked for changes every
+ * {@link setPollingInterval PollingInterval} seconds.
+ *
+ * A {@link setDecayRate DecayRate} can be set to increase the polling
+ * interval linearly if no changes are observed. Once a change is
+ * observe, the polling interval is reset to the original value.
+ *
+ * @author Wei Zhuo
+ * @version $Revision: $ 27/08/2006 $
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
class TValueTriggeredCallback extends TTriggeredCallback
{
/**
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php
index 2bc6ba6a..4e9361aa 100644
--- a/framework/Web/UI/TControl.php
+++ b/framework/Web/UI/TControl.php
@@ -471,7 +471,7 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable
*/
public function setCustomData($value)
{
- $this->getViewState('CustomData',$value,null);
+ $this->setViewState('CustomData',$value,null);
}
/**
@@ -1034,7 +1034,7 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable
*/
public function getHasInitialized()
{
- return $this->getControlStage() >= self::CS_INITIALIZED;
+ return $this->getControlStage() >= self::CS_INITIALIZED;
}
/**
@@ -1052,7 +1052,7 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable
{
return $this->getControlStage() >= self::CS_LOADED;
}
-
+
/**
* @return boolean true if onPreRender event has raised.
*/
@@ -1300,14 +1300,14 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable
}
$this->_stage=self::CS_PRERENDERED;
}
-
+
/**
- * Add controls implementing IPostBackDataHandler to post data loaders.
+ * Add controls implementing IPostBackDataHandler to post data loaders.
*/
protected function addToPostDataLoader()
{
if($this instanceof IPostBackDataHandler)
- $this->getPage()->registerPostDataLoader($this);
+ $this->getPage()->registerPostDataLoader($this);
}
/**
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveButtonTest.page b/tests/FunctionalTests/active-controls/protected/pages/ActiveButtonTest.page
index c475f17f..2e192c19 100644
--- a/tests/FunctionalTests/active-controls/protected/pages/ActiveButtonTest.page
+++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveButtonTest.page
@@ -1,11 +1,11 @@
-
+
TActiveButton Functional Test
-
-
+
-
+
-
+
\ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveButtonTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveButtonTest.php
index 6282b804..42322ea1 100644
--- a/tests/FunctionalTests/active-controls/protected/pages/ActiveButtonTest.php
+++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveButtonTest.php
@@ -2,11 +2,16 @@
class ActiveButtonTest extends TPage
{
+ function onLoad($param)
+ {
+ new TActiveButton;
+ }
+
function button2_onclick($sender, $param)
{
$this->label1->Text = "Button 1 was clicked ";
}
-
+
function button2_oncallback($sender, $param)
{
$this->label1->Text .= "using callback!";
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveImageButtonTest.page b/tests/FunctionalTests/active-controls/protected/pages/ActiveImageButtonTest.page
new file mode 100644
index 00000000..7696261a
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveImageButtonTest.page
@@ -0,0 +1,24 @@
+
+
+ TActiveImageButton Functional Test
+
+ This is
+ OnClick="image1_clicked" />
+ an image.
+
+
+
+
+
+
+
+ OnClick="change_image" />
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveImageButtonTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveImageButtonTest.php
new file mode 100644
index 00000000..eced2457
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveImageButtonTest.php
@@ -0,0 +1,31 @@
+image1->AlternateText = "Muahahahah";
+ }
+
+ function change_image($sender, $param)
+ {
+ $this->image1->ImageUrl = $sender->CustomData;
+ }
+
+ function change_align($sender, $param)
+ {
+ $this->image1->ImageAlign="absbottom";
+ }
+
+ function change_description($sender, $param)
+ {
+ $this->image1->DescriptionUrl = "maahahhaa";
+ }
+
+ function image1_clicked($sender, $param)
+ {
+ $this->label1->Text = "Image clicked at x={$param->x}, y={$param->y}";
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActivePanelTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActivePanelTest.php
index 8a0a4316..b29f8920 100644
--- a/tests/FunctionalTests/active-controls/protected/pages/ActivePanelTest.php
+++ b/tests/FunctionalTests/active-controls/protected/pages/ActivePanelTest.php
@@ -5,7 +5,7 @@ class ActivePanelTest extends TPage
function callback1_requested($sender, $param)
{
$this->content1->visible = true;
- $this->panel1->render($param->output);
+ $this->panel1->render($param->NewWriter);
}
}
diff --git a/tests/FunctionalTests/active-controls/protected/pages/AutoCompleteTest.php b/tests/FunctionalTests/active-controls/protected/pages/AutoCompleteTest.php
index df314891..21f61abe 100644
--- a/tests/FunctionalTests/active-controls/protected/pages/AutoCompleteTest.php
+++ b/tests/FunctionalTests/active-controls/protected/pages/AutoCompleteTest.php
@@ -9,15 +9,15 @@ class AutoCompleteTest extends TPage
{
$sender->setDataSource($this->matchCountries($param->getParameter()));
$sender->dataBind();
- $sender->flush($param->getOutput());
+ $sender->render($param->getNewWriter());
$this->label1->Text = "suggestion for ".$param->getParameter();
}
-
+
public function callback_requested($sender, $param)
{
$this->label1->Text = "Label 1: ".$this->textbox3->Text;
}
-
+
protected function matchCountries($token)
{
$info = Prado::createComponent('System.I18N.core.CultureInfo', 'en');
@@ -31,9 +31,9 @@ class AutoCompleteTest extends TPage
$list[] = $country;
$count++;
if($count > 10) break;
- }
+ }
}
- return $list;
+ return $list;
}
}
diff --git a/tests/FunctionalTests/active-controls/protected/pages/CustomTemplateControlTest.php b/tests/FunctionalTests/active-controls/protected/pages/CustomTemplateControlTest.php
index 753de25c..18005a2b 100644
--- a/tests/FunctionalTests/active-controls/protected/pages/CustomTemplateControlTest.php
+++ b/tests/FunctionalTests/active-controls/protected/pages/CustomTemplateControlTest.php
@@ -16,7 +16,7 @@ class CustomTemplateControlTest extends TPage
function button2_callback($sender, $param)
{
- $this->placeholder->render($param->output);
+ $this->placeholder->render($param->NewWriter);
$this->label1->Text .= " using callback!";
$this->label1->Text .= "... and this is the textbox text: ". $this->foo->Text;
diff --git a/tests/FunctionalTests/active-controls/protected/pages/NestedActiveControls.php b/tests/FunctionalTests/active-controls/protected/pages/NestedActiveControls.php
index 4c6190ee..76b77ff7 100644
--- a/tests/FunctionalTests/active-controls/protected/pages/NestedActiveControls.php
+++ b/tests/FunctionalTests/active-controls/protected/pages/NestedActiveControls.php
@@ -5,7 +5,7 @@ class NestedActiveControls extends TPage
function callback1_requested($sender, $param)
{
$this->content1->visible = true;
- $this->panel1->render($param->output);
+ $this->panel1->render($param->NewWriter);
}
function button1_clicked($sender, $param)
diff --git a/tests/FunctionalTests/active-controls/protected/pages/PeriodicCallbackTest.page b/tests/FunctionalTests/active-controls/protected/pages/PeriodicCallbackTest.page
deleted file mode 100644
index bbc12862..00000000
--- a/tests/FunctionalTests/active-controls/protected/pages/PeriodicCallbackTest.page
+++ /dev/null
@@ -1,21 +0,0 @@
-
- TPeriodicCallback + ViewState Tests
-
-
-
-
-
-
-
-
-
- Loading...
-
-
-
\ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/PeriodicCallbackTest.php b/tests/FunctionalTests/active-controls/protected/pages/PeriodicCallbackTest.php
deleted file mode 100644
index 13633a00..00000000
--- a/tests/FunctionalTests/active-controls/protected/pages/PeriodicCallbackTest.php
+++ /dev/null
@@ -1,27 +0,0 @@
-timer1->startTimer();
- $this->setViewState('count', 0);
- }
-
- function stop_timer($sender, $param)
- {
- $this->timer1->stopTimer();
- }
-
- function tick($sender, $param)
- {
- $count = intval($this->getViewState('count'));
- $this->setViewState('count', ++$count);
- if($count > 10)
- $this->timer1->stopTimer();
- else
- $this->label1->Text .= " ".$count;
- }
-}
-
-?>
\ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/TimeTriggeredCallbackTest.page b/tests/FunctionalTests/active-controls/protected/pages/TimeTriggeredCallbackTest.page
new file mode 100644
index 00000000..36b3bc05
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/TimeTriggeredCallbackTest.page
@@ -0,0 +1,21 @@
+
+ TTimeTriggeredCallback + ViewState Tests
+
+
+
+
+
+
+
+
+
+ Loading...
+
+
+
\ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/TimeTriggeredCallbackTest.php b/tests/FunctionalTests/active-controls/protected/pages/TimeTriggeredCallbackTest.php
new file mode 100644
index 00000000..788857f8
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/TimeTriggeredCallbackTest.php
@@ -0,0 +1,27 @@
+timer1->startTimer();
+ $this->setViewState('count', 0);
+ }
+
+ function stop_timer($sender, $param)
+ {
+ $this->timer1->stopTimer();
+ }
+
+ function tick($sender, $param)
+ {
+ $count = intval($this->getViewState('count'));
+ $this->setViewState('count', ++$count);
+ if($count > 10)
+ $this->timer1->stopTimer();
+ else
+ $this->label1->Text .= " ".$count;
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/group.gif b/tests/FunctionalTests/active-controls/protected/pages/group.gif
new file mode 100644
index 00000000..89c577f7
Binary files /dev/null and b/tests/FunctionalTests/active-controls/protected/pages/group.gif differ
diff --git a/tests/FunctionalTests/active-controls/protected/pages/report.gif b/tests/FunctionalTests/active-controls/protected/pages/report.gif
new file mode 100644
index 00000000..f7169762
Binary files /dev/null and b/tests/FunctionalTests/active-controls/protected/pages/report.gif differ
diff --git a/tests/FunctionalTests/active-controls/tests/ActiveImageButtonTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveImageButtonTestCase.php
new file mode 100644
index 00000000..3d9937bd
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/tests/ActiveImageButtonTestCase.php
@@ -0,0 +1,17 @@
+open("active-controls/index.php?page=ActiveImageButtonTest");
+ $this->assertTextPresent("TActiveImageButton Functional Test");
+ $this->assertText("label1", "Label 1");
+ $this->click("image1");
+ $this->pause(800);
+ //unable to determine mouse position
+ $this->assertTextPresent("Image clicked at x=0, y=0");
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/tests/PeriodicCallbackTestCase.php b/tests/FunctionalTests/active-controls/tests/PeriodicCallbackTestCase.php
deleted file mode 100644
index 2468aebf..00000000
--- a/tests/FunctionalTests/active-controls/tests/PeriodicCallbackTestCase.php
+++ /dev/null
@@ -1,21 +0,0 @@
-open("active-controls/index.php?page=PeriodicCallbackTest");
- $this->verifyTextPresent("TPeriodicCallback + ViewState Tests");
-
- $this->assertText("label1", "ViewState Counter :");
-
- $this->click("button1");
-
- $this->pause(8000);
-
- $this->assertText("label1", "ViewState Counter : 1 2 3 4 5 6 7 8 9 10");
-
- }
-}
-
-?>
\ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/tests/TimeTriggeredCallbackTestCase.php b/tests/FunctionalTests/active-controls/tests/TimeTriggeredCallbackTestCase.php
new file mode 100644
index 00000000..675e3311
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/tests/TimeTriggeredCallbackTestCase.php
@@ -0,0 +1,21 @@
+open("active-controls/index.php?page=TimeTriggeredCallbackTest");
+ $this->verifyTextPresent("TimeTriggeredCallback + ViewState Tests");
+
+ $this->assertText("label1", "ViewState Counter :");
+
+ $this->click("button1");
+
+ $this->pause(8000);
+
+ $this->assertText("label1", "ViewState Counter : 1 2 3 4 5 6 7 8 9 10");
+
+ }
+}
+
+?>
\ No newline at end of file
--
cgit v1.2.3