zhuguifei
2026-03-10 2c1fd10c6fbabb8e9f0e9f07fe66fb36c008e883
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*
    1.样式皮肤
    2.关闭按钮
    3.滚动条(多的时候)
    4.下拉选择项(多的时候)
*/
/**
    @name Edo.navigators.TabBar
    @class
    @typeName tabbar
    @description tab切换器
    @extend Edo.navigators.ToggleBar
*/
Edo.navigators.TabBar = function(config){
    Edo.navigators.TabBar.superclass.constructor.call(this);     
    
};
 
Edo.navigators.TabBar.extend(Edo.navigators.ToggleBar,{
    /**
        @name Edo.navigators.TabBar#defaultHeight
        @property
        @default 22
    */
    defaultHeight: 25,
    /**
        @name Edo.navigators.TabBar#border
        @property
        @default [1,1,1,1]
    */
    border: [1,1,1,1],
    /**
        @name Edo.navigators.TabBar#padding
        @property
        @default [2,5,2,5]
    */
    padding: [2,5,2,5],
    /**
        @name Edo.navigators.TabBar#width
        @property
        @default '100%'
    */
    width: '100%',
    /**
        @name Edo.navigators.TabBar#verticalAlign
        @property
        @default 'bottom'
    */
    verticalAlign: 'bottom',
    /**
        @name Edo.navigators.TabBar#horizontalGap
        @property
        @default 2
    */
    horizontalGap: 3,
    /**
        @name Edo.navigators.TabBar#minHeight
        @property
        @default 17
    */
    minHeight: 17,
    
    selectedCls: 'e-tabbar-selected',  
    itemCls: 'e-tabbar-item',   //这个本来是为了做button的加粗效果,现在缓一缓,后续在做.主要是button的动态生成获取坐标,破坏了样式影响性!这是一个"框架级"的"严重"问题.
    
    //selectedIndex: -1,
    
    /**
        @name Edo.navigators.TabBar#position
        @property
        @type String        
        @default top (left, top, right, bottom)
        @description tabbar位置
    */    
    position: 'top',
    
    _setPosition: function(value){        
        if(this.position != value){
            this.position = value;
            switch(value){
            case 'top':
                this.verticalAlign = 'bottom';
            break;
            case 'bottom':
                this.verticalAlign = 'top';
            break;
            case 'left':
                this.horizontalAlign = 'right';
            break;
            case 'right':
                this.horizontalAlign = 'left';
            break;
            }
 
            this.changeProperty('position', this.position);
            this.relayout('position', this);
        }
    },
 
    getInnerHtml: function(sb){
        this.elCls += ' e-tabbar'; 
        this.elCls += ' e-tabbar-' + this.position;
        
        Edo.navigators.TabBar.superclass.getInnerHtml.call(this, sb);
        sb[sb.length] = '<div class="e-tabbar-line"></div>';
    },
    createChildren: function(el){
        Edo.navigators.TabBar.superclass.createChildren.call(this, el);
        this.stripEl = Edo.util.Dom.append(this.scrollEl, '<div class="e-tabbar-line-strip"></div>');
        this.lineEl = this.scrollEl.nextSibling;        
    },
    syncSize: function(){    //设置组件尺寸,并设置容器子元素的所有尺寸!
        Edo.navigators.TabBar.superclass.syncSize.call(this);                
        
        //this.doSyncLine.defer(100, this);
        this.doSyncLine();
    },
    doSyncLine: function(){
        var box = this._getBox(true);
        var scrollBox = Edo.util.Dom.getBox(this.scrollEl);
        
        var selBox = this.selectedItem ? this.selectedItem._getBox(true) : {x:0,y:0,width:0,height:0,right:0,bottom:0};
        switch(this.position){
        case "top":
            selBox.x += 1;
            selBox.y = selBox.bottom - 1;
            selBox.width -= 2;
            selBox.height = 1;
            
            box.y = scrollBox.bottom-1;
            box.height = 5;//box.bottom - scrollBox.bottom;
        break;
        case "bottom":
            selBox.x += 1;
            selBox.width -= 2;
            selBox.height = 1;
                            
            box.height = scrollBox.y - box.y +1;                
        break;
        case "left":
            selBox.x = selBox.right - 1;
            selBox.width = 1;
            selBox.y += 1;
            selBox.height -= 2;
            
            box.x = scrollBox.right-1;
            box.width = 5;//box.right - scrollBox.right; 
        break;
        case "right":                
            selBox.y += 1;
            selBox.height -= 2;
            selBox.width = 1;
            
            //box.x = selBox.right-1;
            box.width =  scrollBox.x - box.x+1; 
            
            
        }
        Edo.util.Dom.setBox(this.stripEl, {
            x: selBox.x,
            y: selBox.y,
            width: selBox.width,
            height: selBox.height
        });
        
        Edo.util.Dom.setBox(this.lineEl, box);
    },
    addChildAt: function(){
        var a = arguments[1];
        if(this.position == 'top' || this.position == 'bottom'){
            a.height = "100%";
            //a.autoHeight = false;
        }else{
            a.width = "100%";
            //a.autoWidth = false;
        }
        var c = Edo.navigators.TabBar.superclass.addChildAt.apply(this, arguments);      
        c.addCls('e-tabbar-item');
        return c;
    }
});
 
Edo.navigators.TabBar.regType('tabbar');