diff options
author | ctrlaltca@gmail.com <> | 2011-05-15 16:26:11 +0000 |
---|---|---|
committer | ctrlaltca@gmail.com <> | 2011-05-15 16:26:11 +0000 |
commit | 37c9cac197c788e7bdb0aa9b454a199068d2f18e (patch) | |
tree | d5ae847ae47b333c2e18072bf48a80a6c1963a96 /framework/Web/Javascripts/source | |
parent | 1182306a0d95ce5da1b9177f96595b4a612f6cdc (diff) |
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
Diffstat (limited to 'framework/Web/Javascripts/source')
-rw-r--r-- | framework/Web/Javascripts/source/prado/controls/tabpanel.js | 43 |
1 files changed, 28 insertions, 15 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++;
}
}
};
|