From 97869b581fc2af1724dbf07652533f7d2ded9371 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Fri, 10 Jan 2014 19:27:47 +0100 Subject: Optimization: avoid duplicate creation of T*CheckBoxList, T*RadioButtonList js items --- .../source/prado/activecontrols/activecontrols3.js | 2 +- framework/Web/UI/ActiveControls/TActiveCheckBoxList.php | 17 ++++++++++++++++- .../Web/UI/ActiveControls/TActiveRadioButtonList.php | 17 ++++++++++++++++- framework/Web/UI/WebControls/TCheckBoxList.php | 10 +++++++++- framework/Web/UI/WebControls/TRadioButtonList.php | 10 +++++++++- 5 files changed, 51 insertions(+), 5 deletions(-) diff --git a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js index 3e8ec309..907d930e 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js @@ -50,7 +50,7 @@ Prado.WebUI.TActiveCheckBox = jQuery.klass(Prado.WebUI.CallbackControl, Prado.WebUI.TActiveRadioButton = jQuery.klass(Prado.WebUI.TActiveCheckBox); -Prado.WebUI.TActiveCheckBoxList = jQuery.extend( +Prado.WebUI.TActiveCheckBoxList = jQuery.klass(Prado.WebUI.Control, { onInit : function(options) { diff --git a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php index 9d42862e..ea174c94 100644 --- a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php +++ b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php @@ -76,7 +76,7 @@ class TActiveCheckBoxList extends TCheckBoxList implements IActiveControl, ICall */ protected function createRepeatedControl() { - $control = new TActiveCheckBox; + $control = new TActiveCheckBoxListItem; $control->getAdapter()->setBaseActiveControl($this->getActiveControl()); return $control; } @@ -126,3 +126,18 @@ class TActiveCheckBoxList extends TCheckBoxList implements IActiveControl, ICall } } +class TActiveCheckBoxListItem extends TActiveCheckBox +{ + /** + * Override client implementation to avoid emitting the javascript + * + * @param THtmlWriter the writer for the rendering purpose + * @param string checkbox id + * @param string onclick js + */ + protected function renderInputTag($writer,$clientID,$onclick) + { + TCheckBox::renderInputTag($writer,$clientID,$onclick); + } +} + diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php index 17e0b431..84a71951 100644 --- a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php +++ b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php @@ -77,7 +77,7 @@ class TActiveRadioButtonList extends TRadioButtonList implements IActiveControl, */ protected function createRepeatedControl() { - $control = new TActiveRadioButton; + $control = new TActiveRadioButtonItem; $control->getAdapter()->setBaseActiveControl($this->getActiveControl()); return $control; } @@ -128,3 +128,18 @@ class TActiveRadioButtonList extends TRadioButtonList implements IActiveControl, } + +class TActiveRadioButtonItem extends TActiveRadioButton +{ + /** + * Override client implementation to avoid emitting the javascript + * + * @param THtmlWriter the writer for the rendering purpose + * @param string checkbox id + * @param string onclick js + */ + protected function renderInputTag($writer,$clientID,$onclick) + { + TRadioButton::renderInputTag($writer,$clientID,$onclick); + } +} \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TCheckBoxList.php b/framework/Web/UI/WebControls/TCheckBoxList.php index 16e6b7f5..029b6c89 100644 --- a/framework/Web/UI/WebControls/TCheckBoxList.php +++ b/framework/Web/UI/WebControls/TCheckBoxList.php @@ -72,7 +72,7 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont */ protected function createRepeatedControl() { - return new TCheckBox; + return new TCheckBoxItem; } /** @@ -499,3 +499,11 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont } +class TCheckBoxItem extends TCheckBox { + /** + * Override client implementation to avoid emitting the javascript + */ + protected function renderClientControlScript($writer) + { + } +} diff --git a/framework/Web/UI/WebControls/TRadioButtonList.php b/framework/Web/UI/WebControls/TRadioButtonList.php index bead3582..3afe3ec2 100644 --- a/framework/Web/UI/WebControls/TRadioButtonList.php +++ b/framework/Web/UI/WebControls/TRadioButtonList.php @@ -47,7 +47,7 @@ class TRadioButtonList extends TCheckBoxList */ protected function createRepeatedControl() { - return new TRadioButton; + return new TRadioButtonItem; } /** @@ -97,3 +97,11 @@ class TRadioButtonList extends TCheckBoxList } } +class TRadioButtonItem extends TRadioButton { + /** + * Override client implementation to avoid emitting the javascript + */ + protected function renderClientControlScript($writer) + { + } +} -- cgit v1.2.3