/* RSence
* Copyright 2008 Riassence Inc.
* http://riassence.com/
*
* You should have received a copy of the GNU General Public License along
* with this software package. If not, contact licensing@riassence.com
*/
/*** = Description
** HTabView
**
**
***/
HTabView = HView.extend({
/** = Description
* draw function
*
**/
draw: function(){
var _isDrawn = this.drawn;
this.base();
if(!_isDrawn){
var i=0,_styles = [
['overflow','auto']
];
for(i;i<_styles.length;i++){
this.setStyle(_styles[i][0],_styles[i][1]);
}
this.hide();
}
}
});
/** = Description
* HTab
*
**/
HTab = HControl.extend({
componentName: "tab",
componentBehaviour: ['view','control','tab'],
refreshOnValueChange: true,
refreshOnLabelChange: false,
controlDefaults: (HControlDefaults.extend({
constructor: function(_ctrl){
this.tabInit(_ctrl);
},
tabInit: function(_ctrl){
_ctrl.tabs = [];
_ctrl.tabLabels = [];
_ctrl.tabLabelBounds = [];
_ctrl.tabLabelStrings = [];
}
})),
rightmostPx: 0,
selectIdx: -1,
// overridden in the template
tabLabelHeight: 20,
// overridden in the template
tabLabelLeftEdge: 4,
// overridden in the template
tabLabelRightEdge: 4,
// overridden in the template
fontStyle: 'font-family:Arial,sans-serif;font-size:13px;',
tabLabelHTMLPrefix1: '
',
tabLabelHTMLSuffix: '
',
tabLabelParentElem: 'label',
tabLabelElementTagName: 'div',
tabLabelAlign: 'left',
tabLabelFillBg: false,
tabTriggerLink: true,
tabLabelNoHTMLPrefix: false,
/** = Description
* refreshValue function
*
**/
refreshValue: function(){
var _value = this.value;
if(typeof _value === 'number'){
var _index = parseInt(_value,10);
if(_index=_labelBounds[0]){
this.selectTab(i);
return;
}
}
}
}
},
/** = Description
* removeTab function
*
* = Parameters
* +_tabIdx+::
*
**/
removeTab: function(_tabIdx){
var _selIdx = this.selectIdx,
_tabViewId = this.tabs[_tabIdx],
_tabLabelElemId = this.tabViews[_tabIdx];
this.tabs.splice(_tabIdx,1);
this.tabLabels.splice(_tabIdx,1);
this.tabLabelBounds.splice(_tabIdx,1);
this.tabLabelStrings.splice(_tabIdx,1);
if(_tabIdx===_selIdx){
this.selectIdx=-1;
if(_tabIdx===0&&this.tabs.length===0){
this.selectTab(-1);
}
else if(_tabIdx===(this.tabs.length-1)){
this.selectTab(_tabIdx-1);
}
else{
this.selectTab(_tabIdx);
}
}
else if(_tabIdx<_selIdx){
this.selectIdx--;
}
ELEM.del(_tabLabelElemId);
HSystem.views[_tabViewId].die();
}
});
/** = Description
* HTabItem is a wrapper for creating tabs as subviews when using JSONRenderer.
* rect is ignored
* parent is the HTab instance
* options may contain the following:
* select: true|false, passed on to addTab
* label: true|false, passed on to addTab
*
* = Returns
* a new HTabView instance returned by addTab
*
**/
HTabItem = {
nu: function(_rect, _parent, _options){
return _parent.addTab( _options.label, _options.select );
}
};