From 37c9cac197c788e7bdb0aa9b454a199068d2f18e Mon Sep 17 00:00:00 2001 From: "ctrlaltca@gmail.com" <> Date: Sun, 15 May 2011 16:26:11 +0000 Subject: TTabPanel: correctly calculate the current active TTabView index when one or more items are not visible; ensure at least one TTabView is always visible, also if the current one has just being hidden. fixes #324 --- .../Javascripts/source/prado/controls/tabpanel.js | 43 ++++++++++++++-------- framework/Web/UI/WebControls/TTabPanel.php | 17 ++++++--- 2 files changed, 40 insertions(+), 20 deletions(-) (limited to 'framework') diff --git a/framework/Web/Javascripts/source/prado/controls/tabpanel.js b/framework/Web/Javascripts/source/prado/controls/tabpanel.js index c46a5fea..363b5271 100644 --- a/framework/Web/Javascripts/source/prado/controls/tabpanel.js +++ b/framework/Web/Javascripts/source/prado/controls/tabpanel.js @@ -14,38 +14,51 @@ Prado.WebUI.TTabPanel.prototype = this.hiddenField = $(options.ID+'_1'); this.activeCssClass = options.ActiveCssClass; this.normalCssClass = options.NormalCssClass; - var length = options.Views.length; - for(var i = 0; iregisterPradoScript('tabpanel'); $code="new $className($options);"; $cs->registerEndScript("prado:$id", $code); - $cs->registerHiddenField($id.'_1',$this->getActiveViewIndex()); + // ensure an item is always active and visible + $index = $this->getActiveViewIndex(); + if(!$this->getViews()->itemAt($index)->Visible) + $index=0; + $cs->registerHiddenField($id.'_1', $index); $page->registerRequiresPostData($this); $page->registerRequiresPostData($id."_1"); } @@ -435,13 +439,16 @@ class TTabPanel extends TWebControl implements IPostBackDataHandler $options['ID']=$this->getClientID(); $options['ActiveCssClass']=$this->getActiveTabCssClass(); $options['NormalCssClass']=$this->getTabCssClass(); - $viewIDs=array(); + $views=''; foreach($this->getViews() as $view) { - if($view->getVisible()) - $viewIDs[]=$view->getClientID(); + if($views!='') + $views.=', '; + $views.= '"'.$view->getClientID().'":'.($view->getVisible() ? '1': '0' ); } - $options['Views']='[\''.implode('\',\'',$viewIDs).'\']'; + + $options['Views']='{'.$views.='}'; + $viewIDs=array(); return $options; } -- cgit v1.2.3