HT for Web TabView Manual

Index


Overview

The HT for Web provides a tab component class ht.widget.TabView, which renders multiple components in the form of a tab, tab supports for drag-and-drop and close features, the view component of the tab corresponds to the components for the HT framework, or HTML native components, subcomponent set position to absolute for absolute positioning.

Each TabView component object is built with a tabview.getTabModel() tab model container, and the tab model container is ht.dataModel type, can be deleted from the model container ht.Tab type page sign object, ht.Tab object stores information such as the view, text, and icon for the tab.

The selection of the tab is actually the control of the SelectionModel selection model for the tabView.getTabModel() container, which allows you to add listening and control options to the selected model, but TabView provides a more direct function interface, most of the cases without the SelectionModel.

Tab

ht.Tab tab type has the following tab-related property functions:

TabView

Tab component class ht.widget.TabView main configurable properties and functions are as follows:

The example creates two TabView objects with the tabPosition position top and bottom

function init(){                              
    tabView1 = createTabView();
    tabView2 = createTabView();
    splitView = new ht.widget.SplitView(tabView1, tabView2, 'v');

    tabView1.setTabPosition('right-vertical');
    tabView2.setTabPosition('bottom');
    tabView2.select('SUN FLOWER');

    view = splitView.getView();            
    view.className = 'main';
    document.body.appendChild(view);    
    window.addEventListener('resize', function (e) {
        splitView.invalidate();
    }, false);                         

}    

function createTabView(){
    var tabView = new ht.widget.TabView();
    tabView.setSelectBackground('#D26911');
    tabView.setTabBackground('#F5F5F5');                 
    tabView.setLabelColor('#333333');     

    add(tabView, 'TURQUOISE', '#1ABC9C').setDisabled(true);
    add(tabView, 'PETER RIVER', '#3498DB', true).setIcon('search');
    add(tabView, 'AMETHYST', '#9B59B6');
    add(tabView, 'WET ASPHALT', '#34495E').setClosable(true);
    add(tabView, 'SUN FLOWER', '#F1C40F');
    add(tabView, 'CLOUDS', '#ECF0F1').setIcon('edit');
    add(tabView, 'ALIZARIN', '#E74C3C').setIcon('settings');  

    return tabView;
}            

function add(tabView, name, color, selected){
    // create view
    var div = document.createElement('div');
    div.style.background = color;

    // create tab
    var tab = new ht.Tab();
    tab.setName(name);
    tab.setView(div);

    // add to model
    var tabModel = tabView.getTabModel();
    tabModel.add(tab);
    if(selected){
        tabModel.getSelectionModel().setSelection(tab);
    }
    return tab;
} 

Welcome to contact us service@hightopo.com