summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--framework/Web/Javascripts/source/prado/controls/tabpanel.js43
-rw-r--r--framework/Web/UI/WebControls/TTabPanel.php17
2 files changed, 40 insertions, 20 deletions
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; i<length; i++)
+ var i = 0;
+ for(var index in options.Views)
{
- var item = options.Views[i];
- var element = $(item+'_0');
- if (element)
+ var element = $(index+'_0');
+ if (options.Views[index])
{
- Event.observe(element, "click", this.elementClicked.bindEvent(this,item));
+ Event.observe(element, "click", this.elementClicked.bindEvent(this,index));
}
+ if(element)
+ {
+ if(this.hiddenField.value == i)
+ {
+ element.className=this.activeCssClass;
+ $(index).show();
+ }
+ else
+ {
+ element.className=this.normalCssClass;
+ $(index).hide();
+ }
+ }
+ i++;
}
},
elementClicked : function(event,viewID)
{
- var length = this.views.length;
- for(var i = 0; i<length; i++)
+ var i = 0;
+ for(var index in this.views)
{
- var item = this.views[i];
- if ($(item))
+ if ($(index))
{
- if(item == viewID)
+ if(index == viewID)
{
- $(item+'_0').className=this.activeCssClass;
- $(item).show();
+ $(index+'_0').className=this.activeCssClass;
+ $(index).show();
this.hiddenField.value=i;
}
else
{
- $(item+'_0').className=this.normalCssClass;
- $(item).hide();
+ $(index+'_0').className=this.normalCssClass;
+ $(index).hide();
}
}
+ i++;
}
}
};
diff --git a/framework/Web/UI/WebControls/TTabPanel.php b/framework/Web/UI/WebControls/TTabPanel.php
index 63710e56..e17008ba 100644
--- a/framework/Web/UI/WebControls/TTabPanel.php
+++ b/framework/Web/UI/WebControls/TTabPanel.php
@@ -412,7 +412,11 @@ class TTabPanel extends TWebControl implements IPostBackDataHandler
$cs->registerPradoScript('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;
}