summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwei <>2006-10-01 03:09:18 +0000
committerwei <>2006-10-01 03:09:18 +0000
commit36f2ce766bde98c11d57b889fd9e1a7f8dff6010 (patch)
tree87c33c9e4447e20159932824b4de6167da495d49
parent1c32172efb18e8d08ea483e2460813670ebfe1a5 (diff)
Fixed #350 and #148, Add TActiveRatingList, should remove TRatingList from WebControls.
-rw-r--r--.gitattributes21
-rw-r--r--buildscripts/jsbuilder/build.php6
-rw-r--r--framework/Web/Javascripts/extended/event.js49
-rw-r--r--framework/Web/Javascripts/js/compressed/ajax.js45
-rw-r--r--framework/Web/Javascripts/js/compressed/prado.js29
-rw-r--r--framework/Web/Javascripts/js/debug/ajax.js157
-rw-r--r--framework/Web/Javascripts/js/debug/prado.js136
-rw-r--r--framework/Web/Javascripts/prado/activecontrols3.js31
-rw-r--r--framework/Web/Javascripts/prado/controls.js35
-rw-r--r--framework/Web/Javascripts/ratings/blocks.css24
-rw-r--r--framework/Web/Javascripts/ratings/blocks.pngbin29885 -> 28159 bytes
-rw-r--r--framework/Web/Javascripts/ratings/blocks_blank.gifbin72 -> 0 bytes
-rw-r--r--framework/Web/Javascripts/ratings/blocks_blank.pngbin0 -> 227 bytes
-rw-r--r--framework/Web/Javascripts/ratings/blocks_combined.pngbin0 -> 453 bytes
-rw-r--r--framework/Web/Javascripts/ratings/blocks_half.gifbin94 -> 0 bytes
-rw-r--r--framework/Web/Javascripts/ratings/blocks_half.pngbin0 -> 247 bytes
-rw-r--r--framework/Web/Javascripts/ratings/blocks_hover.gifbin75 -> 0 bytes
-rw-r--r--framework/Web/Javascripts/ratings/blocks_selected.gifbin75 -> 0 bytes
-rw-r--r--framework/Web/Javascripts/ratings/blocks_selected.pngbin0 -> 245 bytes
-rw-r--r--framework/Web/Javascripts/ratings/default.css22
-rw-r--r--framework/Web/Javascripts/ratings/default.pngbin0 -> 64293 bytes
-rw-r--r--framework/Web/Javascripts/ratings/default_blank.gifbin271 -> 0 bytes
-rw-r--r--framework/Web/Javascripts/ratings/default_blank.pngbin0 -> 841 bytes
-rw-r--r--framework/Web/Javascripts/ratings/default_combined.pngbin0 -> 2672 bytes
-rw-r--r--framework/Web/Javascripts/ratings/default_half.gifbin619 -> 0 bytes
-rw-r--r--framework/Web/Javascripts/ratings/default_half.pngbin0 -> 857 bytes
-rw-r--r--framework/Web/Javascripts/ratings/default_hover.gifbin618 -> 0 bytes
-rw-r--r--framework/Web/Javascripts/ratings/default_selected.gifbin614 -> 0 bytes
-rw-r--r--framework/Web/Javascripts/ratings/default_selected.pngbin0 -> 831 bytes
-rw-r--r--framework/Web/Javascripts/ratings/ratings.js119
-rw-r--r--framework/Web/Javascripts/ratings/stars1.pngbin53016 -> 0 bytes
-rw-r--r--framework/Web/UI/ActiveControls/TActiveCheckBoxList.php21
-rw-r--r--framework/Web/UI/ActiveControls/TActiveControlAdapter.php8
-rw-r--r--framework/Web/UI/ActiveControls/TActiveRadioButtonList.php21
-rw-r--r--framework/Web/UI/ActiveControls/TActiveRatingList.php240
-rw-r--r--framework/Web/UI/WebControls/TButton.php18
-rw-r--r--framework/Web/UI/WebControls/TCheckBox.php24
-rw-r--r--framework/Web/UI/WebControls/TCheckBoxList.php43
-rw-r--r--framework/Web/UI/WebControls/TImageButton.php31
-rw-r--r--framework/Web/UI/WebControls/TLinkButton.php18
-rw-r--r--framework/Web/UI/WebControls/TListControl.php22
-rw-r--r--framework/Web/UI/WebControls/TRadioButton.php23
-rw-r--r--framework/Web/UI/WebControls/TRadioButtonList.php20
-rw-r--r--framework/Web/UI/WebControls/TTextBox.php23
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/RatingList.page72
-rw-r--r--tests/FunctionalTests/active-controls/protected/pages/RatingList.php22
46 files changed, 1029 insertions, 251 deletions
diff --git a/.gitattributes b/.gitattributes
index 20b15a72..5b131e88 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1769,17 +1769,17 @@ framework/Web/Javascripts/prototype/selector.js -text
framework/Web/Javascripts/prototype/string.js -text
framework/Web/Javascripts/ratings/blocks.css -text
framework/Web/Javascripts/ratings/blocks.png -text
-framework/Web/Javascripts/ratings/blocks_blank.gif -text
-framework/Web/Javascripts/ratings/blocks_half.gif -text
-framework/Web/Javascripts/ratings/blocks_hover.gif -text
-framework/Web/Javascripts/ratings/blocks_selected.gif -text
+framework/Web/Javascripts/ratings/blocks_blank.png -text
+framework/Web/Javascripts/ratings/blocks_combined.png -text
+framework/Web/Javascripts/ratings/blocks_half.png -text
+framework/Web/Javascripts/ratings/blocks_selected.png -text
framework/Web/Javascripts/ratings/default.css -text
-framework/Web/Javascripts/ratings/default_blank.gif -text
-framework/Web/Javascripts/ratings/default_half.gif -text
-framework/Web/Javascripts/ratings/default_hover.gif -text
-framework/Web/Javascripts/ratings/default_selected.gif -text
+framework/Web/Javascripts/ratings/default.png -text
+framework/Web/Javascripts/ratings/default_blank.png -text
+framework/Web/Javascripts/ratings/default_combined.png -text
+framework/Web/Javascripts/ratings/default_half.png -text
+framework/Web/Javascripts/ratings/default_selected.png -text
framework/Web/Javascripts/ratings/ratings.js -text
-framework/Web/Javascripts/ratings/stars1.png -text
framework/Web/Javascripts/rico/colors.js -text
framework/Web/Javascripts/rico/extension.js -text
framework/Web/Javascripts/rico/rico.js -text
@@ -1817,6 +1817,7 @@ framework/Web/UI/ActiveControls/TActiveCustomValidator.php -text
framework/Web/UI/ActiveControls/TActiveLabel.php -text
framework/Web/UI/ActiveControls/TActivePageAdapter.php -text
framework/Web/UI/ActiveControls/TActivePanel.php -text
+framework/Web/UI/ActiveControls/TActiveRatingList.php -text
framework/Web/UI/ActiveControls/TActiveTextBox.php -text
framework/Web/UI/ActiveControls/TAutoComplete.php -text
framework/Web/UI/ActiveControls/TBaseActiveControl.php -text
@@ -1974,6 +1975,8 @@ tests/FunctionalTests/active-controls/protected/pages/PopulateActiveList.page -t
tests/FunctionalTests/active-controls/protected/pages/PopulateActiveList.php -text
tests/FunctionalTests/active-controls/protected/pages/PostLoadingTest.page -text
tests/FunctionalTests/active-controls/protected/pages/PostLoadingTest.php -text
+tests/FunctionalTests/active-controls/protected/pages/RatingList.page -text
+tests/FunctionalTests/active-controls/protected/pages/RatingList.php -text
tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.page -text
tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.php -text
tests/FunctionalTests/active-controls/protected/pages/TInPlaceTextBoxTest.page -text
diff --git a/buildscripts/jsbuilder/build.php b/buildscripts/jsbuilder/build.php
index dbfb169f..30c99ac1 100644
--- a/buildscripts/jsbuilder/build.php
+++ b/buildscripts/jsbuilder/build.php
@@ -89,8 +89,7 @@ $libraries = array(
'prado/element.js',
//controls
- 'prado/controls.js',
- 'ratings/ratings.js'
+ 'prado/controls.js'
),
//effects
@@ -105,7 +104,8 @@ $libraries = array(
'extra/json.js',
'effects/controls.js',
'prado/activecontrols3.js',
- 'prado/inlineeditor.js'
+ 'prado/inlineeditor.js',
+ 'ratings/ratings.js'
// 'effects/dragdrop.js',
// 'effects/slider.js',
// 'prado/activecontrols.js'
diff --git a/framework/Web/Javascripts/extended/event.js b/framework/Web/Javascripts/extended/event.js
index e464fa94..e257931a 100644
--- a/framework/Web/Javascripts/extended/event.js
+++ b/framework/Web/Javascripts/extended/event.js
@@ -1,14 +1,14 @@
/**
* @class Event extensions.
*/
-Object.extend(Event,
+Object.extend(Event,
{
/**
- * Register a function to be executed when the page is loaded.
- * Note that the page is only loaded if all resources (e.g. images)
+ * Register a function to be executed when the page is loaded.
+ * Note that the page is only loaded if all resources (e.g. images)
* are loaded.
- *
- * Example: Show an alert box with message "Page Loaded!" when the
+ *
+ * Example: Show an alert box with message "Page Loaded!" when the
* page finished loading.
* <code>
* Event.OnLoad(function(){ alert("Page Loaded!"); });
@@ -16,18 +16,18 @@ Object.extend(Event,
*
* @param {Function} function to execute when page is loaded.
*/
- OnLoad : function (fn)
+ OnLoad : function (fn)
{
// opera onload is in document, not window
- var w = document.addEventListener &&
+ var w = document.addEventListener &&
!window.addEventListener ? document : window;
Event.observe(w,'load',fn);
},
/**
* @param {Event} a keyboard event
- * @return {Number} the Unicode character code generated by the key
- * that was struck.
+ * @return {Number} the Unicode character code generated by the key
+ * that was struck.
*/
keyCode : function(e)
{
@@ -36,64 +36,65 @@ Object.extend(Event,
/**
* @param {String} event type or event name.
- * @return {Boolean} true if event type is of HTMLEvent, false
+ * @return {Boolean} true if event type is of HTMLEvent, false
* otherwise
*/
isHTMLEvent : function(type)
{
- var events = ['abort', 'blur', 'change', 'error', 'focus',
- 'load', 'reset', 'resize', 'scroll', 'select',
+ var events = ['abort', 'blur', 'change', 'error', 'focus',
+ 'load', 'reset', 'resize', 'scroll', 'select',
'submit', 'unload'];
return events.include(type);
},
/**
* @param {String} event type or event name
- * @return {Boolean} true if event type is of MouseEvent,
+ * @return {Boolean} true if event type is of MouseEvent,
* false otherwise
*/
isMouseEvent : function(type)
{
- var events = ['click', 'mousedown', 'mousemove', 'mouseout',
+ var events = ['click', 'mousedown', 'mousemove', 'mouseout',
'mouseover', 'mouseup'];
return events.include(type);
},
/**
- * Dispatch the DOM event of a given <tt>type</tt> on a DOM
- * <tt>element</tt>. Only HTMLEvent and MouseEvent can be
- * dispatched, keyboard events or UIEvent can not be dispatch
+ * Dispatch the DOM event of a given <tt>type</tt> on a DOM
+ * <tt>element</tt>. Only HTMLEvent and MouseEvent can be
+ * dispatched, keyboard events or UIEvent can not be dispatch
* via javascript consistently.
* For the "submit" event the submit() method is called.
* @param {Object} element id string or a DOM element.
* @param {String} event type to dispatch.
*/
- fireEvent : function(element,type)
+ fireEvent : function(element,type,canBubble)
{
+ canBubble = (typeof(canBubble) == undefined) ? true : canBubble;
element = $(element);
if(type == "submit")
return element.submit();
if(document.createEvent)
- {
+ {
if(Event.isHTMLEvent(type))
{
var event = document.createEvent('HTMLEvents');
- event.initEvent(type, true, true);
+ event.initEvent(type, canBubble, true);
}
else if(Event.isMouseEvent(type))
{
- var event = document.createEvent('MouseEvents');
+ var event = document.createEvent('MouseEvents');
if (event.initMouseEvent)
{
- event.initMouseEvent(type,true,true,
- document.defaultView, 1, 0, 0, 0, 0, false,
+ event.initMouseEvent(type,canBubble,true,
+ document.defaultView, 1, 0, 0, 0, 0, false,
false, false, false, 0, null);
}
else
{
// Safari
// TODO we should be initialising other mouse-event related attributes here
- event.initEvent(type, true, true);
+ event.initEvent(type, canBubble, true);
}
}
element.dispatchEvent(event);
diff --git a/framework/Web/Javascripts/js/compressed/ajax.js b/framework/Web/Javascripts/js/compressed/ajax.js
index 79ef1848..e620399f 100644
--- a/framework/Web/Javascripts/js/compressed/ajax.js
+++ b/framework/Web/Javascripts/js/compressed/ajax.js
@@ -214,7 +214,9 @@ this.editField=this.cached_selectTag;if(this.options.loadTextURL)this.loadExtern
{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);if(request.dispatch()==false)
-Event.stop(event);}});Prado.WebUI.TActiveRadioButton=Class.extend(Prado.WebUI.TActiveCheckBox);Prado.WebUI.TActiveTextBox=Class.extend(Prado.WebUI.TTextBox,{onInit:function(options)
+Event.stop(event);}});Prado.WebUI.TActiveRadioButton=Class.extend(Prado.WebUI.TActiveCheckBox);Prado.WebUI.TActiveCheckBoxList=Base.extend({constructor:function(options)
+{for(var i=0;i<options.ItemCount;i++)
+{var checkBoxOptions=Object.extend({ID:options.ListID+"_c"+i,EventTarget:options.ListName+"$c"+i},options);new Prado.WebUI.TActiveCheckBox(checkBoxOptions);}}});Prado.WebUI.TActiveRadioButtonList=Prado.WebUI.TActiveCheckBoxList;Prado.WebUI.TActiveTextBox=Class.extend(Prado.WebUI.TTextBox,{onInit:function(options)
{if(options['TextMode']!='MultiLine')
Event.observe(this.element,"keydown",this.handleReturnKey.bind(this));Event.observe(this.element,"change",this.doCallback.bindEvent(this,options));},doCallback:function(event,options)
{request=new Prado.CallbackRequest(options.EventTarget,options);request.dispatch();Event.stop(event);}});Prado.WebUI.TAutoComplete=Class.extend(Autocompleter.Base,Prado.WebUI.TActiveTextBox.prototype);Prado.WebUI.TAutoComplete=Class.extend(Prado.WebUI.TAutoComplete,{initialize:function(options)
@@ -228,18 +230,16 @@ this.onInit(options);},doCallback:function(event,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.TTimeTriggeredCallback.register(this);},startTimer:function()
-{this.options.onComplete=this.onRequestComplete.bind(this);setTimeout(this.onTimerEvent.bind(this),200);},stopTimer:function()
+{this.options.onComplete=this.onRequestComplete.bind(this);this.timer=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.EventTarget,this.options);request.dispatch();},onRequestComplete:function()
{(this.onComplete||Prototype.emptyFunction).apply(this,arguments);this.timer=setTimeout(this.onTimerEvent.bind(this),this.getNewTimeout())},getNewTimeout:function()
{switch(this.options.DecayType)
{case'Exponential':t=(Math.exp(this.options.DecayRate*this.count*this.options.Interval))-1;break;case'Linear':t=this.options.DecayRate*this.count*this.options.Interval;break;case'Quadratic':t=this.options.DecayRate*this.count*this.count*this.options.Interval;break;case'Cubic':t=this.options.DecayRate*this.count*this.count*this.count*this.options.Interval;break;default:t=0;}
this.timeout=(t+this.options.Interval)*1000;this.count++;return parseInt(this.timeout);}},{timers:{},register:function(timer)
-{this.timers[timer.options.ID]=timer;},start:function(id)
-{if(this.timers[id])
-this.timers[id].startTimer();},stop:function(id)
-{if(this.timers[id])
-this.timers[id].stopTimer();}});Prado.WebUI.ActiveListControl=Base.extend({constructor:function(options)
+{Prado.WebUI.TTimeTriggeredCallback.timers[timer.options.ID]=timer;},start:function(id)
+{Prado.WebUI.TTimeTriggeredCallback.timers[id].startTimer();},stop:function(id)
+{Prado.WebUI.TTimeTriggeredCallback.timers[id].stopTimer();}});Prado.WebUI.ActiveListControl=Base.extend({constructor:function(options)
{this.element=$(options.ID);this.options=options;Event.observe(this.element,"change",this.doCallback.bind(this));},doCallback:function(event)
{request=new Prado.CallbackRequest(this.options.EventTarget,this.options);request.dispatch();Event.stop(event);}});Prado.WebUI.TActiveDropDownList=Prado.WebUI.ActiveListControl;Prado.WebUI.TActiveListBox=Prado.WebUI.ActiveListControl;Prado.WebUI.TEventTriggeredCallback=Base.extend({constructor:function(options)
{this.options=options;element=$(options['ControlID']);if(element)
@@ -260,9 +260,8 @@ else
this.count=this.count+this.options.Decay;if(this.observing)
this.time=setTimeout(this.checkChanges.bind(this),parseInt(this.options.Interval*1000*this.count));}},doCallback:function(oldValue,newValue)
{request=new Prado.CallbackRequest(this.options.EventTarget,this.options);param={'OldValue':oldValue,'NewValue':newValue};request.setCallbackParameter(param);request.dispatch();}},{timers:{},register:function(timer)
-{this.timers[timer.options.ID]=timer;},stop:function(id)
-{if(this.timers[id])
-this.timers[id].stopObserving();}});Prado.WebUI.TInPlaceTextBox=Base.extend({isSaving:false,isEditing:false,editField:null,constructor:function(options)
+{Prado.WebUI.TValueTriggeredCallback.timers[timer.options.ID]=timer;},stop:function(id)
+{Prado.WebUI.TValueTriggeredCallback.timers[id].stopObserving();}});Prado.WebUI.TInPlaceTextBox=Base.extend({isSaving:false,isEditing:false,editField:null,constructor:function(options)
{this.options=Object.extend({LoadTextFromSource:false,TextMode:'SingleLine'},options||{});this.element=$(this.options.ID);this.initializeListeners();},initializeListeners:function()
{this.onclickListener=this.enterEditMode.bindAsEventListener(this);Event.observe(this.element,'click',this.onclickListener);if(this.options.ExternalControl)
Event.observe($(this.options.ExternalControl),'click',this.onclickListener);},enterEditMode:function(evt)
@@ -303,4 +302,28 @@ this.showLabel();}},onTextChanged:function(text)
{this.isSaving=false;this.isEditing=false;this.showLabel();},onTextChangedSuccess:function(sender,parameter)
{this.isSaving=false;this.isEditing=false;if(this.options.AutoHide)
this.showLabel();this.element.innerHTML=parameter==null?this.editField.value:parameter;this.editField.disabled=false;},onTextChangedFailure:function(sender,parameter)
-{this.editField.disabled=false;this.isSaving=false;this.isEditing=false;}}); \ No newline at end of file
+{this.editField.disabled=false;this.isSaving=false;this.isEditing=false;}});Prado.WebUI.TRatingList=Base.extend({selectedIndex:-1,enabled:true,constructor:function(options)
+{var cap=$(options.CaptionID);this.options=Object.extend({caption:cap?cap.innerHTML:''},options||{});Prado.WebUI.TRatingList.register(this);this._init();this.selectedIndex=options.SelectedIndex;this.setRating(this.selectedIndex);},_init:function(options)
+{Element.addClassName($(this.options.ListID),this.options.Style);var radios=document.getElementsByName(this.options.ListName);this.radios=new Array();var index=0;for(var i=0;i<radios.length;i++)
+{var node=radios[i].parentNode;if(node.tagName.toLowerCase()=='td')
+{this.radios.push(radios[i]);Event.observe(node,"mouseover",this.hover.bindEvent(this,index));Event.observe(node,"mouseout",this.recover.bindEvent(this,index));Event.observe(node,"click",this.click.bindEvent(this,index));index++;Element.addClassName(node,"rating");}}},hover:function(ev,index)
+{if(this.enabled==false)return;for(var i=0;i<this.radios.length;i++)
+{var action=i<=index?'addClassName':'removeClassName'
+Element[action](this.radios[i].parentNode,"rating_hover");}
+this.setCaption(index);},recover:function(ev,index)
+{if(this.enabled==false)return;for(var i=0;i<=index;i++)
+Element.removeClassName(this.radios[i].parentNode,"rating_hover");this.setRating(this.selectedIndex);},click:function(ev,index)
+{if(this.enabled==false)return;for(var i=0;i<this.radios.length;i++)
+this.radios[i].checked=(i==index);this.selectedIndex=index;this.setRating(index);var requestOptions=Object.extend({ID:this.options.ListID+"_c"+index,EventTarget:this.options.ListName+"$c"+index},this.options);var request=new Prado.CallbackRequest(requestOptions.EventTarget,requestOptions);if(request.dispatch()==false)
+Event.stop(ev);},setRating:function(index)
+{for(var i=0;i<this.radios.length;i++)
+{var action=i<=index?'addClassName':'removeClassName'
+Element[action](this.radios[i].parentNode,"rating_selected");}
+this.setCaption(index);},setCaption:function(index)
+{var value=index>-1?this.radios[index].value:this.options.caption;var caption=$(this.options.CaptionID);if(caption)caption.innerHTML=value;$(this.options.ListName).title=value;},setEnabled:function(value)
+{this.enabled=value;for(var i=0;i<this.radios.length;i++)
+{var action=value?'removeClassName':'addClassName'
+Element[action](this.radios[i].parentNode,"rating_disabled");Element.removeClassName(this.radios[i].parentNode,"rating_hover");}}},{ratings:{},register:function(rating)
+{Prado.WebUI.TRatingList.ratings[rating.options.ListID]=rating;},setEnabled:function(id,value)
+{Prado.WebUI.TRatingList.ratings[id].setEnabled(value);},setRating:function(id,value)
+{Prado.WebUI.TRatingList.ratings[id].setRating(value);Prado.WebUI.TRatingList.ratings[id].selectedIndex=value;}}); \ No newline at end of file
diff --git a/framework/Web/Javascripts/js/compressed/prado.js b/framework/Web/Javascripts/js/compressed/prado.js
index 2f6f7eed..376e3a7b 100644
--- a/framework/Web/Javascripts/js/compressed/prado.js
+++ b/framework/Web/Javascripts/js/compressed/prado.js
@@ -131,16 +131,16 @@ Event.observe(window,'unload',Event.unloadCache,false);Object.extend(Event,{OnLo
{var w=document.addEventListener&&!window.addEventListener?document:window;Event.observe(w,'load',fn);},keyCode:function(e)
{return e.keyCode!=null?e.keyCode:e.charCode},isHTMLEvent:function(type)
{var events=['abort','blur','change','error','focus','load','reset','resize','scroll','select','submit','unload'];return events.include(type);},isMouseEvent:function(type)
-{var events=['click','mousedown','mousemove','mouseout','mouseover','mouseup'];return events.include(type);},fireEvent:function(element,type)
-{element=$(element);if(type=="submit")
+{var events=['click','mousedown','mousemove','mouseout','mouseover','mouseup'];return events.include(type);},fireEvent:function(element,type,canBubble)
+{canBubble=(typeof(canBubble)==undefined)?true:canBubble;element=$(element);if(type=="submit")
return element.submit();if(document.createEvent)
{if(Event.isHTMLEvent(type))
-{var event=document.createEvent('HTMLEvents');event.initEvent(type,true,true);}
+{var event=document.createEvent('HTMLEvents');event.initEvent(type,canBubble,true);}
else if(Event.isMouseEvent(type))
{var event=document.createEvent('MouseEvents');if(event.initMouseEvent)
-{event.initMouseEvent(type,true,true,document.defaultView,1,0,0,0,0,false,false,false,false,0,null);}
+{event.initMouseEvent(type,canBubble,true,document.defaultView,1,0,0,0,0,false,false,false,false,0,null);}
else
-{event.initEvent(type,true,true);}}
+{event.initEvent(type,canBubble,true);}}
element.dispatchEvent(event);}
else if(document.createEventObject)
{var evObj=document.createEventObject();element.fireEvent('on'+type,evObj);}
@@ -390,17 +390,8 @@ text+=node.nodeValue;}
if(text.length>0)
window.clipboardData.setData("Text",text);},hover:function(obj)
{obj.parentNode.className="copycode copycode_hover";},out:function(obj)
-{obj.parentNode.className="copycode";}});Prado.WebUI.TRatingList=Class.create();Prado.WebUI.TRatingList.prototype={selectedIndex:-1,initialize:function(options)
-{this.options=options;this.element=$(options['ID']);Element.addClassName(this.element,options.cssClass);this.radios=document.getElementsByName(options.field);for(var i=0;i<this.radios.length;i++)
-{Event.observe(this.radios[i].parentNode,"mouseover",this.hover.bindEvent(this,i));Event.observe(this.radios[i].parentNode,"mouseout",this.recover.bindEvent(this,i));Event.observe(this.radios[i].parentNode,"click",this.click.bindEvent(this,i));}
-this.caption=CAPTION();this.element.appendChild(this.caption);this.selectedIndex=options.selectedIndex;this.setRating(this.selectedIndex);},hover:function(ev,index)
-{for(var i=0;i<this.radios.length;i++)
-this.radios[i].parentNode.className=(i<=index)?"rating_hover":"";this.setCaption(index);},recover:function(ev,index)
-{for(var i=0;i<=index;i++)
-Element.removeClassName(this.radios[i].parentNode,"rating_hover");this.setRating(this.selectedIndex);},click:function(ev,index)
-{for(var i=0;i<this.radios.length;i++)
-this.radios[i].checked=(i==index);this.selectedIndex=index;this.setRating(index);if(isFunction(this.options.onChange))
-this.options.onChange(this,index);},setRating:function(index)
-{for(var i=0;i<=index;i++)
-this.radios[i].parentNode.className="rating_selected";this.setCaption(index);},setCaption:function(index)
-{this.caption.innerHTML=index>-1?this.radios[index].value:this.options.caption;}} \ No newline at end of file
+{obj.parentNode.className="copycode";}});Prado.WebUI.TCheckBoxList=Base.extend({constructor:function(options)
+{for(var i=0;i<options.ItemCount;i++)
+{var checkBoxOptions=Object.extend({ID:options.ListID+"_c"+i,EventTarget:options.ListName+"$c"+i},options);new Prado.WebUI.TCheckBox(checkBoxOptions);}}});Prado.WebUI.TRadioButtonList=Base.extend({constructor:function(options)
+{for(var i=0;i<options.ItemCount;i++)
+{var radioButtonOptions=Object.extend({ID:options.ListID+"_c"+i,EventTarget:options.ListName+"$c"+i},options);new Prado.WebUI.TRadioButton(radioButtonOptions);}}}); \ No newline at end of file
diff --git a/framework/Web/Javascripts/js/debug/ajax.js b/framework/Web/Javascripts/js/debug/ajax.js
index 5acdfb63..dc35043d 100644
--- a/framework/Web/Javascripts/js/debug/ajax.js
+++ b/framework/Web/Javascripts/js/debug/ajax.js
@@ -2065,6 +2065,24 @@ Prado.WebUI.TActiveCheckBox = Class.extend(Prado.WebUI.CallbackControl,
Prado.WebUI.TActiveRadioButton = Class.extend(Prado.WebUI.TActiveCheckBox);
+Prado.WebUI.TActiveCheckBoxList = Base.extend(
+{
+ constructor : function(options)
+ {
+ for(var i = 0; i<options.ItemCount; i++)
+ {
+ var checkBoxOptions = Object.extend(
+ {
+ ID : options.ListID+"_c"+i,
+ EventTarget : options.ListName+"$c"+i
+ }, options);
+ new Prado.WebUI.TActiveCheckBox(checkBoxOptions);
+ }
+ }
+});
+
+Prado.WebUI.TActiveRadioButtonList = Prado.WebUI.TActiveCheckBoxList;
+
/**
* TActiveTextBox control, handles onchange event.
*/
@@ -2161,7 +2179,7 @@ Prado.WebUI.TTimeTriggeredCallback = Base.extend(
startTimer : function()
{
this.options.onComplete = this.onRequestComplete.bind(this);
- setTimeout(this.onTimerEvent.bind(this), 200);
+ this.timer = setTimeout(this.onTimerEvent.bind(this), 200);
},
stopTimer : function()
@@ -2215,19 +2233,17 @@ Prado.WebUI.TTimeTriggeredCallback = Base.extend(
register : function(timer)
{
- this.timers[timer.options.ID] = timer;
+ Prado.WebUI.TTimeTriggeredCallback.timers[timer.options.ID] = timer;
},
start : function(id)
{
- if(this.timers[id])
- this.timers[id].startTimer();
+ Prado.WebUI.TTimeTriggeredCallback.timers[id].startTimer();
},
stop : function(id)
{
- if(this.timers[id])
- this.timers[id].stopTimer();
+ Prado.WebUI.TTimeTriggeredCallback.timers[id].stopTimer();
}
});
@@ -2355,13 +2371,12 @@ Prado.WebUI.TValueTriggeredCallback = Base.extend(
register : function(timer)
{
- this.timers[timer.options.ID] = timer;
+ Prado.WebUI.TValueTriggeredCallback.timers[timer.options.ID] = timer;
},
stop : function(id)
{
- if(this.timers[id])
- this.timers[id].stopObserving();
+ Prado.WebUI.TValueTriggeredCallback.timers[id].stopObserving();
}
});
@@ -2595,3 +2610,127 @@ Prado.WebUI.TInPlaceTextBox = Base.extend(
}
});
+Prado.WebUI.TRatingList = Base.extend(
+{
+ selectedIndex : -1,
+ enabled : true,
+
+ constructor : function(options)
+ {
+ var cap = $(options.CaptionID);
+ this.options = Object.extend(
+ {
+ caption : cap ? cap.innerHTML : ''
+ }, options || {});
+
+ Prado.WebUI.TRatingList.register(this);
+ this._init();
+ this.selectedIndex = options.SelectedIndex;
+ this.setRating(this.selectedIndex);
+ },
+
+ _init: function(options)
+ {
+ Element.addClassName($(this.options.ListID),this.options.Style);
+ var radios = document.getElementsByName(this.options.ListName);
+ this.radios = new Array();
+ var index=0;
+ for(var i = 0; i<radios.length; i++)
+ {
+ var node = radios[i].parentNode;
+ if(node.tagName.toLowerCase()=='td')
+ {
+ this.radios.push(radios[i]);
+ Event.observe(node, "mouseover", this.hover.bindEvent(this,index));
+ Event.observe(node, "mouseout", this.recover.bindEvent(this,index));
+ Event.observe(node, "click", this.click.bindEvent(this, index));
+ index++;
+ Element.addClassName(node,"rating");
+ }
+ }
+ },
+
+ hover : function(ev,index)
+ {
+ if(this.enabled==false) return;
+ for(var i = 0; i<this.radios.length; i++)
+ {
+ var action = i <= index ? 'addClassName' : 'removeClassName'
+ Element[action](this.radios[i].parentNode,"rating_hover");
+ }
+ this.setCaption(index);
+ },
+
+ recover : function(ev,index)
+ {
+ if(this.enabled==false) return;
+ for(var i = 0; i<=index; i++)
+ Element.removeClassName(this.radios[i].parentNode, "rating_hover");
+ this.setRating(this.selectedIndex);
+ },
+
+ click : function(ev, index)
+ {
+ if(this.enabled==false) return;
+ for(var i = 0; i<this.radios.length; i++)
+ this.radios[i].checked = (i == index);
+ this.selectedIndex = index;
+ this.setRating(index);
+ var requestOptions = Object.extend(
+ {
+ ID : this.options.ListID+"_c"+index,
+ EventTarget : this.options.ListName+"$c"+index
+ },this.options);
+ var request = new Prado.CallbackRequest(requestOptions.EventTarget, requestOptions);
+ if(request.dispatch()==false)
+ Event.stop(ev);
+ },
+
+ setRating: function(index)
+ {
+ for(var i = 0; i<this.radios.length; i++)
+ {
+ var action = i <= index ? 'addClassName' : 'removeClassName'
+ Element[action](this.radios[i].parentNode, "rating_selected");
+ }
+ this.setCaption(index);
+ },
+
+ setCaption : function(index)
+ {
+ var value = index > -1 ? this.radios[index].value : this.options.caption;
+ var caption = $(this.options.CaptionID);
+ if(caption) caption.innerHTML = value;
+ $(this.options.ListName).title = value;
+ },
+
+ setEnabled : function(value)
+ {
+ this.enabled = value;
+ for(var i = 0; i<this.radios.length; i++)
+ {
+ var action = value ? 'removeClassName' : 'addClassName'
+ Element[action](this.radios[i].parentNode, "rating_disabled");
+ Element.removeClassName(this.radios[i].parentNode, "rating_hover");
+ }
+ }
+},
+{
+ratings : {},
+register : function(rating)
+{
+ Prado.WebUI.TRatingList.ratings[rating.options.ListID] = rating;
+},
+
+setEnabled : function(id,value)
+{
+ Prado.WebUI.TRatingList.ratings[id].setEnabled(value);
+},
+
+setRating : function(id,value)
+{
+ Prado.WebUI.TRatingList.ratings[id].setRating(value);
+ Prado.WebUI.TRatingList.ratings[id].selectedIndex = value;
+}
+});
+
diff --git a/framework/Web/Javascripts/js/debug/prado.js b/framework/Web/Javascripts/js/debug/prado.js
index 122a5640..a455a0dd 100644
--- a/framework/Web/Javascripts/js/debug/prado.js
+++ b/framework/Web/Javascripts/js/debug/prado.js
@@ -1924,14 +1924,14 @@ if (navigator.appVersion.match(/\bMSIE\b/))
/**
* @class Event extensions.
*/
-Object.extend(Event,
+Object.extend(Event,
{
/**
- * Register a function to be executed when the page is loaded.
- * Note that the page is only loaded if all resources (e.g. images)
+ * Register a function to be executed when the page is loaded.
+ * Note that the page is only loaded if all resources (e.g. images)
* are loaded.
- *
- * Example: Show an alert box with message "Page Loaded!" when the
+ *
+ * Example: Show an alert box with message "Page Loaded!" when the
* page finished loading.
* <code>
* Event.OnLoad(function(){ alert("Page Loaded!"); });
@@ -1939,18 +1939,18 @@ Object.extend(Event,
*
* @param {Function} function to execute when page is loaded.
*/
- OnLoad : function (fn)
+ OnLoad : function (fn)
{
// opera onload is in document, not window
- var w = document.addEventListener &&
+ var w = document.addEventListener &&
!window.addEventListener ? document : window;
Event.observe(w,'load',fn);
},
/**
* @param {Event} a keyboard event
- * @return {Number} the Unicode character code generated by the key
- * that was struck.
+ * @return {Number} the Unicode character code generated by the key
+ * that was struck.
*/
keyCode : function(e)
{
@@ -1959,64 +1959,65 @@ Object.extend(Event,
/**
* @param {String} event type or event name.
- * @return {Boolean} true if event type is of HTMLEvent, false
+ * @return {Boolean} true if event type is of HTMLEvent, false
* otherwise
*/
isHTMLEvent : function(type)
{
- var events = ['abort', 'blur', 'change', 'error', 'focus',
- 'load', 'reset', 'resize', 'scroll', 'select',
+ var events = ['abort', 'blur', 'change', 'error', 'focus',
+ 'load', 'reset', 'resize', 'scroll', 'select',
'submit', 'unload'];
return events.include(type);
},
/**
* @param {String} event type or event name
- * @return {Boolean} true if event type is of MouseEvent,
+ * @return {Boolean} true if event type is of MouseEvent,
* false otherwise
*/
isMouseEvent : function(type)
{
- var events = ['click', 'mousedown', 'mousemove', 'mouseout',
+ var events = ['click', 'mousedown', 'mousemove', 'mouseout',
'mouseover', 'mouseup'];
return events.include(type);
},
/**
- * Dispatch the DOM event of a given <tt>type</tt> on a DOM
- * <tt>element</tt>. Only HTMLEvent and MouseEvent can be
- * dispatched, keyboard events or UIEvent can not be dispatch
+ * Dispatch the DOM event of a given <tt>type</tt> on a DOM
+ * <tt>element</tt>. Only HTMLEvent and MouseEvent can be
+ * dispatched, keyboard events or UIEvent can not be dispatch
* via javascript consistently.
* For the "submit" event the submit() method is called.
* @param {Object} element id string or a DOM element.
* @param {String} event type to dispatch.
*/
- fireEvent : function(element,type)
+ fireEvent : function(element,type,canBubble)
{
+ canBubble = (typeof(canBubble) == undefined) ? true : canBubble;
element = $(element);
if(type == "submit")
return element.submit();
if(document.createEvent)
- {
+ {
if(Event.isHTMLEvent(type))
{
var event = document.createEvent('HTMLEvents');
- event.initEvent(type, true, true);
+ event.initEvent(type, canBubble, true);
}
else if(Event.isMouseEvent(type))
{
- var event = document.createEvent('MouseEvents');
+ var event = document.createEvent('MouseEvents');
if (event.initMouseEvent)
{
- event.initMouseEvent(type,true,true,
- document.defaultView, 1, 0, 0, 0, 0, false,
+ event.initMouseEvent(type,canBubble,true,
+ document.defaultView, 1, 0, 0, 0, 0, false,
false, false, false, 0, null);
}
else
{
// Safari
// TODO we should be initialising other mouse-event related attributes here
- event.initEvent(type, true, true);
+ event.initEvent(type, canBubble, true);
}
}
element.dispatchEvent(event);
@@ -3471,7 +3472,7 @@ Prado.WebUI.DefaultButton.prototype =
if(defaultButton)
{
this.triggered = true;
- $('PRADO_POSTBACK_TARGET').value = this.options.EventTarget;
+ $('PRADO_POSTBACK_TARGET').value = this.options.EventTarget;
Event.fireEvent(defaultButton, this.options['Event']);
Event.stop(ev);
}
@@ -3525,66 +3526,37 @@ Object.extend(Prado.WebUI.TTextHighlighter,
obj.parentNode.className = "copycode";
}
});
-
-
-Prado.WebUI.TRatingList = Class.create();
-Prado.WebUI.TRatingList.prototype =
-{
- selectedIndex : -1,
- initialize : function(options)
+
+Prado.WebUI.TCheckBoxList = Base.extend(
+{
+ constructor : function(options)
{
- this.options = options;
- this.element = $(options['ID']);
- Element.addClassName(this.element,options.cssClass);
- this.radios = document.getElementsByName(options.field);
- for(var i = 0; i<this.radios.length; i++)
+ for(var i = 0; i<options.ItemCount; i++)
{
- Event.observe(this.radios[i].parentNode, "mouseover", this.hover.bindEvent(this,i));
- Event.observe(this.radios[i].parentNode, "mouseout", this.recover.bindEvent(this,i));
- Event.observe(this.radios[i].parentNode, "click", this.click.bindEvent(this, i));
- }
- this.caption = CAPTION();
- this.element.appendChild(this.caption);
- this.selectedIndex = options.selectedIndex;
- this.setRating(this.selectedIndex);
- },
-
- hover : function(ev,index)
- {
- for(var i = 0; i<this.radios.length; i++)
- this.radios[i].parentNode.className = (i<=index) ? "rating_hover" : "";
- this.setCaption(index);
- },
-
- recover : function(ev,index)
- {
- for(var i = 0; i<=index; i++)
- Element.removeClassName(this.radios[i].parentNode, "rating_hover");
- this.setRating(this.selectedIndex);
- },
-
- click : function(ev, index)
- {
- for(var i = 0; i<this.radios.length; i++)
- this.radios[i].checked = (i == index);
- this.selectedIndex = index;
- this.setRating(index);
- if(isFunction(this.options.onChange))
- this.options.onChange(this,index);
- },
-
- setRating: function(index)
- {
- for(var i = 0; i<=index; i++)
- this.radios[i].parentNode.className = "rating_selected";
- this.setCaption(index);
- },
-
- setCaption : function(index)
+ var checkBoxOptions = Object.extend(
+ {
+ ID : options.ListID+"_c"+i,
+ EventTarget : options.ListName+"$c"+i
+ }, options);
+ new Prado.WebUI.TCheckBox(checkBoxOptions);
+ }
+ }
+});
+
+Prado.WebUI.TRadioButtonList = Base.extend(
+{
+ constructor : function(options)
{
- this.caption.innerHTML = index > -1 ?
- this.radios[index].value : this.options.caption;
+ for(var i = 0; i<options.ItemCount; i++)
+ {
+ var radioButtonOptions = Object.extend(
+ {
+ ID : options.ListID+"_c"+i,
+ EventTarget : options.ListName+"$c"+i
+ }, options);
+ new Prado.WebUI.TRadioButton(radioButtonOptions);
+ }
}
-}
+});
diff --git a/framework/Web/Javascripts/prado/activecontrols3.js b/framework/Web/Javascripts/prado/activecontrols3.js
index 315ead78..68ea3cf3 100644
--- a/framework/Web/Javascripts/prado/activecontrols3.js
+++ b/framework/Web/Javascripts/prado/activecontrols3.js
@@ -49,6 +49,24 @@ Prado.WebUI.TActiveCheckBox = Class.extend(Prado.WebUI.CallbackControl,
Prado.WebUI.TActiveRadioButton = Class.extend(Prado.WebUI.TActiveCheckBox);
+Prado.WebUI.TActiveCheckBoxList = Base.extend(
+{
+ constructor : function(options)
+ {
+ for(var i = 0; i<options.ItemCount; i++)
+ {
+ var checkBoxOptions = Object.extend(
+ {
+ ID : options.ListID+"_c"+i,
+ EventTarget : options.ListName+"$c"+i
+ }, options);
+ new Prado.WebUI.TActiveCheckBox(checkBoxOptions);
+ }
+ }
+});
+
+Prado.WebUI.TActiveRadioButtonList = Prado.WebUI.TActiveCheckBoxList;
+
/**
* TActiveTextBox control, handles onchange event.
*/
@@ -199,19 +217,17 @@ Prado.WebUI.TTimeTriggeredCallback = Base.extend(
register : function(timer)
{
- this.timers[timer.options.ID] = timer;
+ Prado.WebUI.TTimeTriggeredCallback.timers[timer.options.ID] = timer;
},
start : function(id)
{
- if(this.timers[id])
- this.timers[id].startTimer();
+ Prado.WebUI.TTimeTriggeredCallback.timers[id].startTimer();
},
stop : function(id)
{
- if(this.timers[id])
- this.timers[id].stopTimer();
+ Prado.WebUI.TTimeTriggeredCallback.timers[id].stopTimer();
}
});
@@ -339,12 +355,11 @@ Prado.WebUI.TValueTriggeredCallback = Base.extend(
register : function(timer)
{
- this.timers[timer.options.ID] = timer;
+ Prado.WebUI.TValueTriggeredCallback.timers[timer.options.ID] = timer;
},
stop : function(id)
{
- if(this.timers[id])
- this.timers[id].stopObserving();
+ Prado.WebUI.TValueTriggeredCallback.timers[id].stopObserving();
}
});
diff --git a/framework/Web/Javascripts/prado/controls.js b/framework/Web/Javascripts/prado/controls.js
index 8595b5fd..76ff828c 100644
--- a/framework/Web/Javascripts/prado/controls.js
+++ b/framework/Web/Javascripts/prado/controls.js
@@ -220,7 +220,7 @@ Prado.WebUI.DefaultButton.prototype =
if(defaultButton)
{
this.triggered = true;
- $('PRADO_POSTBACK_TARGET').value = this.options.EventTarget;
+ $('PRADO_POSTBACK_TARGET').value = this.options.EventTarget;
Event.fireEvent(defaultButton, this.options['Event']);
Event.stop(ev);
}
@@ -274,3 +274,36 @@ Object.extend(Prado.WebUI.TTextHighlighter,
obj.parentNode.className = "copycode";
}
});
+
+
+Prado.WebUI.TCheckBoxList = Base.extend(
+{
+ constructor : function(options)
+ {
+ for(var i = 0; i<options.ItemCount; i++)
+ {
+ var checkBoxOptions = Object.extend(
+ {
+ ID : options.ListID+"_c"+i,
+ EventTarget : options.ListName+"$c"+i
+ }, options);
+ new Prado.WebUI.TCheckBox(checkBoxOptions);
+ }
+ }
+});
+
+Prado.WebUI.TRadioButtonList = Base.extend(
+{
+ constructor : function(options)
+ {
+ for(var i = 0; i<options.ItemCount; i++)
+ {
+ var radioButtonOptions = Object.extend(
+ {
+ ID : options.ListID+"_c"+i,
+ EventTarget : options.ListName+"$c"+i
+ }, options);
+ new Prado.WebUI.TRadioButton(radioButtonOptions);
+ }
+ }
+}); \ No newline at end of file
diff --git a/framework/Web/Javascripts/ratings/blocks.css b/framework/Web/Javascripts/ratings/blocks.css
index 2bf2e904..63cb7c2b 100644
--- a/framework/Web/Javascripts/ratings/blocks.css
+++ b/framework/Web/Javascripts/ratings/blocks.css
@@ -6,24 +6,36 @@
{
display: none;
}
+
.TRatingList_blocks td
{
- width: 17px;
- height: 18px;
- background-image: url(blocks_blank.gif);
+ width: 18px;
+ height: 9px;
+ padding: 1px;
+}
+
+.TRatingList_blocks td.rating
+{
+ background-image: url(blocks_combined.png);
background-repeat: no-repeat;
cursor: pointer;
+ background-position: 1px 0px;
}
.TRatingList_blocks td.rating_selected
{
- background-image: url(blocks_selected.gif);
+ background-position: 1px -100px;
}
.TRatingList_blocks td.rating_hover
{
- background-image: url(blocks_hover.gif);
+ background-position: 1px -200px;
}
.TRatingList_blocks td.rating_half
{
- background-image: url(blocks_half.gif);
+ background-position: 1px -300px;
}
+
+.TRatingList_blocks td.rating_disabled
+{
+ cursor: default !important;
+} \ No newline at end of file
diff --git a/framework/Web/Javascripts/ratings/blocks.png b/framework/Web/Javascripts/ratings/blocks.png
index 16a2b249..923cda09 100644
--- a/framework/Web/Javascripts/ratings/blocks.png
+++ b/framework/Web/Javascripts/ratings/blocks.png
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/blocks_blank.gif b/framework/Web/Javascripts/ratings/blocks_blank.gif
deleted file mode 100644
index a68d0e94..00000000
--- a/framework/Web/Javascripts/ratings/blocks_blank.gif
+++ /dev/null
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/blocks_blank.png b/framework/Web/Javascripts/ratings/blocks_blank.png
new file mode 100644
index 00000000..d5004d2d
--- /dev/null
+++ b/framework/Web/Javascripts/ratings/blocks_blank.png
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/blocks_combined.png b/framework/Web/Javascripts/ratings/blocks_combined.png
new file mode 100644
index 00000000..57c07672
--- /dev/null
+++ b/framework/Web/Javascripts/ratings/blocks_combined.png
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/blocks_half.gif b/framework/Web/Javascripts/ratings/blocks_half.gif
deleted file mode 100644
index 4cff0148..00000000
--- a/framework/Web/Javascripts/ratings/blocks_half.gif
+++ /dev/null
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/blocks_half.png b/framework/Web/Javascripts/ratings/blocks_half.png
new file mode 100644
index 00000000..344aa207
--- /dev/null
+++ b/framework/Web/Javascripts/ratings/blocks_half.png
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/blocks_hover.gif b/framework/Web/Javascripts/ratings/blocks_hover.gif
deleted file mode 100644
index 58ad7495..00000000
--- a/framework/Web/Javascripts/ratings/blocks_hover.gif
+++ /dev/null
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/blocks_selected.gif b/framework/Web/Javascripts/ratings/blocks_selected.gif
deleted file mode 100644
index f91873e2..00000000
--- a/framework/Web/Javascripts/ratings/blocks_selected.gif
+++ /dev/null
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/blocks_selected.png b/framework/Web/Javascripts/ratings/blocks_selected.png
new file mode 100644
index 00000000..dfdb6889
--- /dev/null
+++ b/framework/Web/Javascripts/ratings/blocks_selected.png
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/default.css b/framework/Web/Javascripts/ratings/default.css
index c15a36bd..cf8f7558 100644
--- a/framework/Web/Javascripts/ratings/default.css
+++ b/framework/Web/Javascripts/ratings/default.css
@@ -6,24 +6,36 @@
{
display: none;
}
+
.TRatingList_default td
{
- width: 17px;
+ width: 18px;
height: 18px;
- background-image: url(default_blank.gif);
+ padding: 0;
+}
+
+.TRatingList_default td.rating
+{
+ background-image: url(default_combined.png);
background-repeat: no-repeat;
cursor: pointer;
+ background-position: 0px 0px;
}
.TRatingList_default td.rating_selected
{
- background-image: url(default_selected.gif);
+ background-position: 0px -100px;
}
.TRatingList_default td.rating_hover
{
- background-image: url(default_hover.gif);
+ background-position: 0px -200px;
}
.TRatingList_default td.rating_half
{
- background-image: url(default_half.gif);
+ background-position: 0px -300px;
}
+
+.TRatingList_default td.rating_disabled
+{
+ cursor: default !important;
+} \ No newline at end of file
diff --git a/framework/Web/Javascripts/ratings/default.png b/framework/Web/Javascripts/ratings/default.png
new file mode 100644
index 00000000..f9f380a9
--- /dev/null
+++ b/framework/Web/Javascripts/ratings/default.png
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/default_blank.gif b/framework/Web/Javascripts/ratings/default_blank.gif
deleted file mode 100644
index 4e6fda3c..00000000
--- a/framework/Web/Javascripts/ratings/default_blank.gif
+++ /dev/null
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/default_blank.png b/framework/Web/Javascripts/ratings/default_blank.png
new file mode 100644
index 00000000..f857ff17
--- /dev/null
+++ b/framework/Web/Javascripts/ratings/default_blank.png
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/default_combined.png b/framework/Web/Javascripts/ratings/default_combined.png
new file mode 100644
index 00000000..1756f912
--- /dev/null
+++ b/framework/Web/Javascripts/ratings/default_combined.png
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/default_half.gif b/framework/Web/Javascripts/ratings/default_half.gif
deleted file mode 100644
index 7cecf0ec..00000000
--- a/framework/Web/Javascripts/ratings/default_half.gif
+++ /dev/null
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/default_half.png b/framework/Web/Javascripts/ratings/default_half.png
new file mode 100644
index 00000000..6c826054
--- /dev/null
+++ b/framework/Web/Javascripts/ratings/default_half.png
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/default_hover.gif b/framework/Web/Javascripts/ratings/default_hover.gif
deleted file mode 100644
index ad0cd28a..00000000
--- a/framework/Web/Javascripts/ratings/default_hover.gif
+++ /dev/null
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/default_selected.gif b/framework/Web/Javascripts/ratings/default_selected.gif
deleted file mode 100644
index a19ab39f..00000000
--- a/framework/Web/Javascripts/ratings/default_selected.gif
+++ /dev/null
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/default_selected.png b/framework/Web/Javascripts/ratings/default_selected.png
new file mode 100644
index 00000000..e40d6b04
--- /dev/null
+++ b/framework/Web/Javascripts/ratings/default_selected.png
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/ratings.js b/framework/Web/Javascripts/ratings/ratings.js
index e6fd97ba..04ebd31d 100644
--- a/framework/Web/Javascripts/ratings/ratings.js
+++ b/framework/Web/Javascripts/ratings/ratings.js
@@ -1,60 +1,123 @@
-Prado.WebUI.TRatingList = Class.create();
-Prado.WebUI.TRatingList.prototype =
+Prado.WebUI.TRatingList = Base.extend(
{
selectedIndex : -1,
+ enabled : true,
- initialize : function(options)
+ constructor : function(options)
{
- this.options = options;
- this.element = $(options['ID']);
- Element.addClassName(this.element,options.cssClass);
- this.radios = document.getElementsByName(options.field);
- for(var i = 0; i<this.radios.length; i++)
+ var cap = $(options.CaptionID);
+ this.options = Object.extend(
{
- Event.observe(this.radios[i].parentNode, "mouseover", this.hover.bindEvent(this,i));
- Event.observe(this.radios[i].parentNode, "mouseout", this.recover.bindEvent(this,i));
- Event.observe(this.radios[i].parentNode, "click", this.click.bindEvent(this, i));
- }
- this.caption = CAPTION();
- this.element.appendChild(this.caption);
- this.selectedIndex = options.selectedIndex;
+ caption : cap ? cap.innerHTML : ''
+ }, options || {});
+
+ Prado.WebUI.TRatingList.register(this);
+ this._init();
+ this.selectedIndex = options.SelectedIndex;
this.setRating(this.selectedIndex);
},
-
+
+ _init: function(options)
+ {
+ Element.addClassName($(this.options.ListID),this.options.Style);
+ var radios = document.getElementsByName(this.options.ListName);
+ this.radios = new Array();
+ var index=0;
+ for(var i = 0; i<radios.length; i++)
+ {
+ var node = radios[i].parentNode;
+ if(node.tagName.toLowerCase()=='td')
+ {
+ this.radios.push(radios[i]);
+ Event.observe(node, "mouseover", this.hover.bindEvent(this,index));
+ Event.observe(node, "mouseout", this.recover.bindEvent(this,index));
+ Event.observe(node, "click", this.click.bindEvent(this, index));
+ index++;
+ Element.addClassName(node,"rating");
+ }
+ }
+ },
+
hover : function(ev,index)
{
+ if(this.enabled==false) return;
for(var i = 0; i<this.radios.length; i++)
- this.radios[i].parentNode.className = (i<=index) ? "rating_hover" : "";
+ {
+ var action = i <= index ? 'addClassName' : 'removeClassName'
+ Element[action](this.radios[i].parentNode,"rating_hover");
+ }
this.setCaption(index);
},
-
+
recover : function(ev,index)
{
+ if(this.enabled==false) return;
for(var i = 0; i<=index; i++)
Element.removeClassName(this.radios[i].parentNode, "rating_hover");
this.setRating(this.selectedIndex);
},
-
+
click : function(ev, index)
{
+ if(this.enabled==false) return;
for(var i = 0; i<this.radios.length; i++)
this.radios[i].checked = (i == index);
this.selectedIndex = index;
this.setRating(index);
- if(isFunction(this.options.onChange))
- this.options.onChange(this,index);
+ var requestOptions = Object.extend(
+ {
+ ID : this.options.ListID+"_c"+index,
+ EventTarget : this.options.ListName+"$c"+index
+ },this.options);
+ var request = new Prado.CallbackRequest(requestOptions.EventTarget, requestOptions);
+ if(request.dispatch()==false)
+ Event.stop(ev);
},
-
+
setRating: function(index)
{
- for(var i = 0; i<=index; i++)
- this.radios[i].parentNode.className = "rating_selected";
+ for(var i = 0; i<this.radios.length; i++)
+ {
+ var action = i <= index ? 'addClassName' : 'removeClassName'
+ Element[action](this.radios[i].parentNode, "rating_selected");
+ }
this.setCaption(index);
},
-
+
setCaption : function(index)
{
- this.caption.innerHTML = index > -1 ?
- this.radios[index].value : this.options.caption;
+ var value = index > -1 ? this.radios[index].value : this.options.caption;
+ var caption = $(this.options.CaptionID);
+ if(caption) caption.innerHTML = value;
+ $(this.options.ListName).title = value;
+ },
+
+ setEnabled : function(value)
+ {
+ this.enabled = value;
+ for(var i = 0; i<this.radios.length; i++)
+ {
+ var action = value ? 'removeClassName' : 'addClassName'
+ Element[action](this.radios[i].parentNode, "rating_disabled");
+ Element.removeClassName(this.radios[i].parentNode, "rating_hover");
+ }
}
-} \ No newline at end of file
+},
+{
+ratings : {},
+register : function(rating)
+{
+ Prado.WebUI.TRatingList.ratings[rating.options.ListID] = rating;
+},
+
+setEnabled : function(id,value)
+{
+ Prado.WebUI.TRatingList.ratings[id].setEnabled(value);
+},
+
+setRating : function(id,value)
+{
+ Prado.WebUI.TRatingList.ratings[id].setRating(value);
+ Prado.WebUI.TRatingList.ratings[id].selectedIndex = value;
+}
+}); \ No newline at end of file
diff --git a/framework/Web/Javascripts/ratings/stars1.png b/framework/Web/Javascripts/ratings/stars1.png
deleted file mode 100644
index e4dd3c25..00000000
--- a/framework/Web/Javascripts/ratings/stars1.png
+++ /dev/null
Binary files differ
diff --git a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php
index f70a6407..b18d0d0d 100644
--- a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php
+++ b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php
@@ -43,9 +43,9 @@ class TActiveCheckBoxList extends TCheckBoxList implements IActiveControl, ICall
*/
public function __construct()
{
- parent::__construct();
$this->setAdapter(new TActiveListControlAdapter($this));
$this->setAutoPostBack(true);
+ parent::__construct();
}
/**
@@ -57,13 +57,20 @@ class TActiveCheckBoxList extends TCheckBoxList implements IActiveControl, ICall
}
/**
- * No client class for this control.
- * This method overrides the parent implementation.
- * @return null no javascript class name.
+ * @return string javascript client-side control class name.
*/
protected function getClientClassName()
{
- return null;
+ return 'Prado.WebUI.TActiveCheckBoxList';
+ }
+
+ /**
+ * Registers the javascript code for initializing the active control.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getPostBackOptions());
}
/**
@@ -72,7 +79,9 @@ class TActiveCheckBoxList extends TCheckBoxList implements IActiveControl, ICall
*/
protected function createRepeatedControl()
{
- return new TActiveCheckBox;
+ $control = new TActiveCheckBox;
+ $control->getAdapter()->setBaseActiveControl($this->getActiveControl());
+ return $control;
}
/**
diff --git a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
index 58b65486..8e637719 100644
--- a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
+++ b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php
@@ -105,6 +105,14 @@ class TActiveControlAdapter extends TControlAdapter
}
/**
+ * @param TBaseActiveControl change base active control
+ */
+ public function setBaseActiveControl($control)
+ {
+ $this->_baseActiveControl=$control;
+ }
+
+ /**
* @return TBaseActiveControl Common active control options.
*/
public function getBaseActiveControl()
diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
index 3eb57ec7..f971228f 100644
--- a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
+++ b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php
@@ -38,9 +38,9 @@ class TActiveRadioButtonList extends TRadioButtonList implements IActiveControl,
*/
public function __construct()
{
- parent::__construct();
$this->setAdapter(new TActiveListControlAdapter($this));
$this->setAutoPostBack(true);
+ parent::__construct();
}
/**
@@ -52,13 +52,20 @@ class TActiveRadioButtonList extends TRadioButtonList implements IActiveControl,
}
/**
- * No client class for this control.
- * This method overrides the parent implementation.
- * @return null no javascript class name.
+ * @return string javascript client-side control class name.
*/
protected function getClientClassName()
{
- return null;
+ return 'Prado.WebUI.TActiveRadioButtonList';
+ }
+
+ /**
+ * Registers the javascript code for initializing the active control.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getPostBackOptions());
}
/**
@@ -67,7 +74,9 @@ class TActiveRadioButtonList extends TRadioButtonList implements IActiveControl,
*/
protected function createRepeatedControl()
{
- return new TActiveRadioButton;
+ $control = new TActiveRadioButton;
+ $control->getAdapter()->setBaseActiveControl($this->getActiveControl());
+ return $control;
}
/**
diff --git a/framework/Web/UI/ActiveControls/TActiveRatingList.php b/framework/Web/UI/ActiveControls/TActiveRatingList.php
new file mode 100644
index 00000000..1ce49a0c
--- /dev/null
+++ b/framework/Web/UI/ActiveControls/TActiveRatingList.php
@@ -0,0 +1,240 @@
+<?php
+
+class TActiveRatingList extends TActiveRadioButtonList
+{
+ private $_ratingImages = array();
+
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setRepeatDirection(TRepeatDirection::Horizontal);
+ }
+
+ /**
+ * @return boolean whether the items in the column can be edited. Defaults to false.
+ */
+ public function getReadOnly()
+ {
+ return $this->getViewState('ReadOnly',false);
+ }
+
+ public function setRepeatLayout($value)
+ {
+ if($value!==TRepeatLayout::Table)
+ throw new TInvalidDataValueException('ratinglist_table_layout_only');
+ else
+ parent::setRepeatLayout($value);
+ }
+
+ /**
+ * @param boolean whether the items in the column can be edited
+ */
+ public function setReadOnly($value)
+ {
+ $this->setViewState('ReadOnly',TPropertyValue::ensureBoolean($value),false);
+ }
+
+ public function getRating()
+ {
+ return $this->getViewState('Rating',0);
+ }
+
+ public function setRating($value)
+ {
+ $this->setViewState('Rating', TPropertyValue::ensureFloat($value),0);
+ }
+
+ public function setSelectedIndex($value)
+ {
+ $canUpdate = $this->getActiveControl()->getEnableUpdate();
+ $this->getActiveControl()->setEnableUpdate(false);
+ parent::setSelectedIndex($value);
+ $this->getActiveControl()->setEnableUpdate($canUpdate);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->callClientFunction('setRating',$value);
+ }
+
+ protected function callClientFunction($func,$value)
+ {
+ $client = $this->getPage()->getCallbackClient();
+ $code = $this->getClientClassName().'.'.$func;
+ $client->callClientFunction($code,array($this,$value));
+ }
+
+ /**
+ * @return string caption text.
+ */
+ public function getCaptionID()
+ {
+ return $this->getViewState('CaptionID', '');
+ }
+
+ /**
+ * @param string caption text
+ */
+ public function setCaptionID($value)
+ {
+ $this->setViewState('CaptionID', $value, '');
+ }
+
+ public function setEnabled($value)
+ {
+ parent::setEnabled($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->callClientFunction('setEnabled',$value);
+ }
+
+ /**
+ * @param string set the rating style
+ */
+ public function setRatingStyle($value)
+ {
+ $this->setViewState('RatingStyle', $value, 'default');
+ }
+
+ /**
+ * @return TRatingListStyle current rating style
+ */
+ public function getRatingStyle()
+ {
+ return $this->getViewState('RatingStyle', 'default');
+ }
+
+ public function setHalfRatingLimit($value)
+ {
+ $this->setViewState('HalfRating',
+ TPropertyValue::ensureArray($value), array(0.3, 0.7));
+ }
+
+ public function getHalfRatingLimit()
+ {
+ return $this->getViewState('HalfRating', array(0.3, 0.7));
+ }
+
+ protected function getRatingStyleCssClass()
+ {
+ return 'TRatingList_'.$this->getRatingStyle();
+ }
+
+ protected function getPostBackOptions()
+ {
+ $options = parent::getPostBackOptions();
+ $options['Style'] = $this->getRatingStyleCssClass();
+ $options['CaptionID'] = $this->getCaptionControl();
+ $options['SelectedIndex'] = $this->getSelectedIndex();
+ return $options;
+ }
+
+ /**
+ * Registers the javascript code for initializing the active control.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ if($this->getReadOnly()===false)
+ parent::renderClientControlScript($writer);
+ }
+
+ protected function getCaptionControl()
+ {
+ if(($id=$this->getCaptionID())!=='')
+ {
+ if($control=$this->getParent()->findControl($id))
+ {
+ if($control->getVisible(true))
+ return $control->getClientID();
+ }
+ else
+ return $id;
+ }
+ return '';
+ }
+
+ protected function publishRatingListStyle($style)
+ {
+ $cs = $this->getPage()->getClientScript();
+ $stylesheet = 'System.Web.Javascripts.ratings.'.$style;
+ if(($cssFile=Prado::getPathOfNamespace($stylesheet,'.css'))===null)
+ throw new TConfigurationException('ratinglist_stylesheet_not_found',$style);
+ $url = $this->publishFilePath($cssFile);
+ if(!$cs->isStyleSheetFileRegistered($style))
+ $cs->registerStyleSheetFile($style, $url);
+ return $url;
+ }
+
+ protected function publishRatingListImages($style, $fileExt='.png')
+ {
+ $images['blank'] = "System.Web.Javascripts.ratings.{$style}_blank";
+ $images['selected'] = "System.Web.Javascripts.ratings.{$style}_selected";
+ $images['half'] = "System.Web.Javascripts.ratings.{$style}_half";
+ $images['combined'] = "System.Web.Javascripts.ratings.{$style}_combined";
+ $files = array();
+ foreach($images as $type => $image)
+ {
+ if(($file=Prado::getPathOfNamespace($image, $fileExt))===null)
+ throw TConfigurationException('ratinglist_image_not_found',$image);
+ $files[$type] = $this->publishFilePath($file);
+ }
+ return $files;
+ }
+
+ public function render($writer)
+ {
+ if($this->getReadOnly())
+ {
+ $writer->addAttribute('class', $this->getRatingStyleCssClass());
+ $writer->addAttribute('title', $this->getRating());
+ }
+ parent::render($writer);
+ }
+
+ /**
+ * @param THtmlWriter writer
+ */
+ public function onPreRender($param)
+ {
+ parent::onPreRender($param);
+
+ $this->publishRatingListStyle($this->getRatingStyle());
+ $this->_ratingImages = $this->publishRatingListImages($this->getRatingStyle());
+ }
+
+ public function renderItem($writer,$repeatInfo,$itemType,$index)
+ {
+ if($this->getReadOnly())
+ $this->renderStaticRating($writer, $repeatInfo, $itemType, $index);
+ else
+ parent::renderItem($writer, $repeatInfo, $itemType, $index);
+ }
+
+ protected function renderStaticRating($writer, $repeatInfo, $itemType, $index)
+ {
+ $image = new TImage;
+ $image->setImageUrl($this->_ratingImages[$this->getRatingImageType($index)]);
+ $image->setAlternateText($this->getRating());
+ $image->render($writer);
+ }
+
+ protected function getRatingImageType($index)
+ {
+ $rating = floatval($this->getRating());
+ $int = intval($rating);
+ $limit = $this->getHalfRatingLimit();
+ if($index < $int || ($rating < $index+1 && $rating > $index+$limit[1]))
+ return 'selected';
+ if($rating >= $index+$limit[0] && $rating <= $index+$limit[1])
+ return 'half';
+ return 'blank';
+ }
+
+ /**
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TRatingList';
+ }
+}
+
+?> \ No newline at end of file
diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php
index 59df8f7c..0b118495 100644
--- a/framework/Web/UI/WebControls/TButton.php
+++ b/framework/Web/UI/WebControls/TButton.php
@@ -58,6 +58,22 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr
}
/**
+ * @return boolean whether to render javascript.
+ */
+ public function getEnableClientScript()
+ {
+ return $this->getViewState('EnableClientScript',true);
+ }
+
+ /**
+ * @param boolean whether to render javascript.
+ */
+ public function setEnableClientScript($value)
+ {
+ $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
+ }
+
+ /**
* Adds attribute name-value pairs to renderer.
* This overrides the parent implementation with additional button specific attributes.
* @param THtmlWriter the writer used for the rendering purpose
@@ -72,7 +88,7 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr
$writer->addAttribute('value',$this->getText());
if($this->getEnabled(true))
{
- if($this->needPostBackScript())
+ if($this->needPostBackScript() && $this->getEnableClientScript())
$this->renderClientControlScript($writer);
}
else if($this->getEnabled()) // in this case, parent will not render 'disabled'
diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php
index 2b9fd6b7..fefc9331 100644
--- a/framework/Web/UI/WebControls/TCheckBox.php
+++ b/framework/Web/UI/WebControls/TCheckBox.php
@@ -337,6 +337,22 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
}
/**
+ * @return boolean whether to render javascript.
+ */
+ public function getEnableClientScript()
+ {
+ return $this->getViewState('EnableClientScript',true);
+ }
+
+ /**
+ * @param boolean whether to render javascript.
+ */
+ public function setEnableClientScript($value)
+ {
+ $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
+ }
+
+ /**
* Renders a label beside the checkbox.
* @param THtmlWriter the writer for the rendering purpose
* @param string checkbox id
@@ -375,8 +391,13 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
$writer->addAttribute('disabled','disabled');
$page=$this->getPage();
- if($this->getEnabled(true) && $this->getAutoPostBack() && $page->getClientSupportsJavaScript())
+ if($this->getEnabled(true)
+ && $this->getEnableClientScript()
+ && $this->getAutoPostBack()
+ && $page->getClientSupportsJavaScript())
+ {
$this->renderClientControlScript($writer);
+ }
if(($accesskey=$this->getAccessKey())!=='')
$writer->addAttribute('accesskey',$accesskey);
@@ -419,7 +440,6 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
$options['EventTarget'] = $this->getUniqueID();
return $options;
}
-
}
/**
diff --git a/framework/Web/UI/WebControls/TCheckBoxList.php b/framework/Web/UI/WebControls/TCheckBoxList.php
index 89357b55..09b771eb 100644
--- a/framework/Web/UI/WebControls/TCheckBoxList.php
+++ b/framework/Web/UI/WebControls/TCheckBoxList.php
@@ -106,16 +106,6 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont
}
/**
- * Gets the name of the javascript class responsible for performing postback for this control.
- * This method overrides the parent implementation.
- * @return string the javascript class name
- */
- protected function getClientClassName()
- {
- return 'Prado.WebUI.TCheckBoxList';
- }
-
- /**
* @return TTextAlign the alignment of the text caption, defaults to TTextAlign::Right.
*/
public function getTextAlign()
@@ -296,6 +286,7 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont
$repeatedControl->setChecked($item->getSelected());
$repeatedControl->setAttribute('value',$item->getValue());
$repeatedControl->setEnabled($this->_isEnabled && $item->getEnabled());
+ $repeatedControl->setEnableClientScript(false);
$repeatedControl->renderControl($writer);
}
@@ -389,6 +380,14 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont
$this->setAccessKey($accessKey);
$this->setTabIndex($tabIndex);
}
+ //checkbox skipped the client control script in addAttributesToRender
+ if($this->getEnabled(true)
+ && $this->getEnableClientScript()
+ && $this->getAutoPostBack()
+ && $this->getPage()->getClientSupportsJavaScript())
+ {
+ $this->renderClientControlScript($writer);
+ }
}
/**
@@ -400,6 +399,30 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont
{
return $this->getSelectedValue();
}
+
+ /**
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TCheckBoxList';
+ }
+
+ /**
+ * Gets the post back options for this checkbox.
+ * @return array
+ */
+ protected function getPostBackOptions()
+ {
+ $options['ListID'] = $this->getClientID();
+ $options['ValidationGroup'] = $this->getValidationGroup();
+ $options['CausesValidation'] = $this->getCausesValidation();
+ $options['ListName'] = $this->getUniqueID();
+ $options['ItemCount'] = $this->getItemCount();
+ return $options;
+ }
}
?> \ No newline at end of file
diff --git a/framework/Web/UI/WebControls/TImageButton.php b/framework/Web/UI/WebControls/TImageButton.php
index ad5d7bf0..3e96abdc 100644
--- a/framework/Web/UI/WebControls/TImageButton.php
+++ b/framework/Web/UI/WebControls/TImageButton.php
@@ -76,6 +76,22 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
}
/**
+ * @return boolean whether to render javascript.
+ */
+ public function getEnableClientScript()
+ {
+ return $this->getViewState('EnableClientScript',true);
+ }
+
+ /**
+ * @param boolean whether to render javascript.
+ */
+ public function setEnableClientScript($value)
+ {
+ $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
+ }
+
+ /**
* Adds attribute name-value pairs to renderer.
* This overrides the parent implementation with additional button specific attributes.
* @param THtmlWriter the writer used for the rendering purpose
@@ -87,8 +103,12 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
$writer->addAttribute('type','image');
if(($uniqueID=$this->getUniqueID())!=='')
$writer->addAttribute('name',$uniqueID);
- if($this->getEnabled(true))
+ if($this->getEnabled(true)
+ && $this-canCauseValidation()
+ && $this->getEnableClientScript())
+ {
$this->renderClientControlScript($writer);
+ }
else if($this->getEnabled()) // in this case, parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
parent::addAttributesToRender($writer);
@@ -99,12 +119,9 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
*/
protected function renderClientControlScript($writer)
{
- if($this->canCauseValidation())
- {
- $writer->addAttribute('id',$this->getClientID());
- $cs = $this->getPage()->getClientScript();
- $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions());
- }
+ $writer->addAttribute('id',$this->getClientID());
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions());
}
/**
diff --git a/framework/Web/UI/WebControls/TLinkButton.php b/framework/Web/UI/WebControls/TLinkButton.php
index d7586bde..ffa83d02 100644
--- a/framework/Web/UI/WebControls/TLinkButton.php
+++ b/framework/Web/UI/WebControls/TLinkButton.php
@@ -65,6 +65,22 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler, IButtonC
}
/**
+ * @return boolean whether to render javascript.
+ */
+ public function getEnableClientScript()
+ {
+ return $this->getViewState('EnableClientScript',true);
+ }
+
+ /**
+ * @param boolean whether to render javascript.
+ */
+ public function setEnableClientScript($value)
+ {
+ $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
+ }
+
+ /**
* Adds attribute name-value pairs to renderer.
* This overrides the parent implementation with additional button specific attributes.
* @param THtmlWriter the writer used for the rendering purpose
@@ -80,7 +96,7 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler, IButtonC
// may be overwritten in the following
parent::addAttributesToRender($writer);
- if($this->getEnabled(true))
+ if($this->getEnabled(true) && $this->getEnableClientScript())
{
$this->renderLinkButtonHref($writer);
$this->renderClientControlScript($writer);
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php
index 7576154e..056a8548 100644
--- a/framework/Web/UI/WebControls/TListControl.php
+++ b/framework/Web/UI/WebControls/TListControl.php
@@ -106,6 +106,22 @@ abstract class TListControl extends TDataBoundControl
}
/**
+ * @return boolean whether to render javascript.
+ */
+ public function getEnableClientScript()
+ {
+ return $this->getViewState('EnableClientScript',true);
+ }
+
+ /**
+ * @param boolean whether to render javascript.
+ */
+ public function setEnableClientScript($value)
+ {
+ $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
+ }
+
+ /**
* Adds attributes to renderer.
* @param THtmlWriter the renderer
*/
@@ -117,8 +133,12 @@ abstract class TListControl extends TDataBoundControl
$writer->addAttribute('multiple','multiple');
if($this->getEnabled(true))
{
- if($this->getAutoPostBack() && $page->getClientSupportsJavaScript())
+ if($this->getAutoPostBack()
+ && $this->getEnableClientScript()
+ && $page->getClientSupportsJavaScript())
+ {
$this->renderClientControlScript($writer);
+ }
}
else if($this->getEnabled())
$writer->addAttribute('disabled','disabled');
diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php
index dac194b7..9b6bf794 100644
--- a/framework/Web/UI/WebControls/TRadioButton.php
+++ b/framework/Web/UI/WebControls/TRadioButton.php
@@ -234,6 +234,22 @@ class TRadioButton extends TCheckBox
}
/**
+ * @return boolean whether to render javascript.
+ */
+ public function getEnableClientScript()
+ {
+ return $this->getViewState('EnableClientScript',true);
+ }
+
+ /**
+ * @param boolean whether to render javascript.
+ */
+ public function setEnableClientScript($value)
+ {
+ $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
+ }
+
+ /**
* Renders a radiobutton input element.
* @param THtmlWriter the writer for the rendering purpose
* @param string checkbox id
@@ -254,8 +270,13 @@ class TRadioButton extends TCheckBox
$writer->addAttribute('disabled','disabled');
$page=$this->getPage();
- if($this->getEnabled(true) && $this->getAutoPostBack() && $page->getClientSupportsJavaScript())
+ if($this->getEnabled(true)
+ && $this->getEnableClientScript()
+ && $this->getAutoPostBack()
+ && $page->getClientSupportsJavaScript())
+ {
$this->renderClientControlScript($writer);
+ }
if(($accesskey=$this->getAccessKey())!=='')
$writer->addAttribute('accesskey',$accesskey);
diff --git a/framework/Web/UI/WebControls/TRadioButtonList.php b/framework/Web/UI/WebControls/TRadioButtonList.php
index b314b963..97328c73 100644
--- a/framework/Web/UI/WebControls/TRadioButtonList.php
+++ b/framework/Web/UI/WebControls/TRadioButtonList.php
@@ -53,16 +53,6 @@ class TRadioButtonList extends TCheckBoxList
}
/**
- * Gets the name of the javascript class responsible for performing postback for this control.
- * This method overrides the parent implementation.
- * @return string the javascript class name
- */
- protected function getClientClassName()
- {
- return 'Prado.WebUI.TRadioButtonList';
- }
-
- /**
* Loads user input data.
* This method is primarly used by framework developers.
* @param string the key that can be used to retrieve data from the input data collection
@@ -97,6 +87,16 @@ class TRadioButtonList extends TCheckBoxList
{
throw new TNotSupportedException('radiobuttonlist_selectedindices_unsupported');
}
+
+ /**
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TRadioButtonList';
+ }
}
?> \ No newline at end of file
diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php
index ad6de40c..588830f0 100644
--- a/framework/Web/UI/WebControls/TTextBox.php
+++ b/framework/Web/UI/WebControls/TTextBox.php
@@ -76,6 +76,22 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
}
/**
+ * @return boolean whether to render javascript.
+ */
+ public function getEnableClientScript()
+ {
+ return $this->getViewState('EnableClientScript',true);
+ }
+
+ /**
+ * @param boolean whether to render javascript.
+ */
+ public function setEnableClientScript($value)
+ {
+ $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
+ }
+
+ /**
* Adds attribute name-value pairs to renderer.
* This method overrides the parent implementation with additional textbox specific attributes.
* @param THtmlWriter the writer used for the rendering purpose
@@ -138,8 +154,13 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
$isEnabled=$this->getEnabled(true);
if(!$isEnabled && $this->getEnabled()) // in this case parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
- if($isEnabled && $this->getAutoPostBack() && $page->getClientSupportsJavaScript())
+ if($isEnabled
+ && $this->getEnableClientScript()
+ && $this->getAutoPostBack()
+ && $page->getClientSupportsJavaScript())
+ {
$this->renderClientControlScript($writer);
+ }
parent::addAttributesToRender($writer);
}
diff --git a/tests/FunctionalTests/active-controls/protected/pages/RatingList.page b/tests/FunctionalTests/active-controls/protected/pages/RatingList.page
new file mode 100644
index 00000000..190e6020
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/RatingList.page
@@ -0,0 +1,72 @@
+<com:THead/>
+<com:TForm>
+<style>
+ body
+ {
+ background-color: pink
+ }
+</style>
+<com:TLabel ID="label1" Text="Rate It:" />
+<com:TActiveRatingList ID="list1" CaptionID="label1" RatingStyle="blocks" OnCallback="list1_oncallback">
+ <com:TListItem Text="1 Star" />
+ <com:TListItem Text="2 Star" />
+ <com:TListItem Text="3 Star" />
+ <com:TListItem Text="4 Star" />
+ <com:TListItem Text="5 Star" />
+ <prop:ActiveControl.ClientSide
+ OnLoading="Element.show('status')"
+ OnComplete="Element.hide('status')" />
+</com:TActiveRatingList>
+
+
+<com:TActiveRatingList ID="list2" Rating="3.5" RatingStyle="blocks" ReadOnly="true">
+ <com:TListItem Text="1 Star" />
+ <com:TListItem Text="2 Star" />
+ <com:TListItem Text="3 Star" />
+ <com:TListItem Text="4 Star" />
+ <com:TListItem Text="5 Star" />
+</com:TActiveRatingList>
+
+<br />
+
+<com:TActiveRatingList RepeatColumns="5">
+ <com:TListItem Text="1 Star" />
+ <com:TListItem Text="2 Star" />
+ <com:TListItem Text="3 Star" />
+ <com:TListItem Text="4 Star" />
+ <com:TListItem Text="5 Star" />
+ <com:TListItem Text="6 Star" />
+ <com:TListItem Text="7 Star" />
+ <com:TListItem Text="8 Star" />
+ <com:TListItem Text="9 Star" />
+ <com:TListItem Text="10 Star" />
+ <prop:ActiveControl.ClientSide
+ OnLoading="Element.show('status')"
+ OnComplete="Element.hide('status')" />
+</com:TActiveRatingList>
+
+
+<com:TActiveRatingList ID="list3" Rating="3.5" ReadOnly="true">
+ <com:TListItem Text="1 Star" />
+ <com:TListItem Text="2 Star" />
+ <com:TListItem Text="3 Star" />
+ <com:TListItem Text="4 Star" />
+ <com:TListItem Text="5 Star" />
+</com:TActiveRatingList>
+
+<br />
+
+ <div id="status" style="margin:1em; padding:0.5em;
+ text-align:center;
+ background-color:#900;
+ color:white; display: none;
+ position: absolute; right: 0; top: 0">
+ Loading...
+ </div>
+
+<com:TActiveButton ID="button1" Text="Enable List" OnClick="button1_clicked" />
+<com:TActiveButton ID="button2" Text="Set Index 3" OnClick="button2_clicked" />
+
+<com:TJavascriptLogger />
+
+</com:TForm> \ No newline at end of file
diff --git a/tests/FunctionalTests/active-controls/protected/pages/RatingList.php b/tests/FunctionalTests/active-controls/protected/pages/RatingList.php
new file mode 100644
index 00000000..d31b6166
--- /dev/null
+++ b/tests/FunctionalTests/active-controls/protected/pages/RatingList.php
@@ -0,0 +1,22 @@
+<?php
+
+class RatingList extends TPage
+{
+ function list1_oncallback($sender, $param)
+ {
+ $sender->Enabled=false;
+ }
+
+ function button1_clicked($sender, $param)
+ {
+ $this->list1->Enabled = true;
+ }
+
+ function button2_clicked($sender, $param)
+ {
+ $this->list1->SelectedIndex=3;
+ $this->list1->Enabled=false;
+ }
+}
+
+?> \ No newline at end of file