-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
50 lines (40 loc) · 1.32 KB
/
index.js
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
var DerbyElList = require('derby-el-list');
var _ = require('lodash');
module.exports = Tabs;
function Tabs() {}
Tabs.prototype.view = __dirname + '/views';
Tabs.prototype.style = __dirname + '/styles';
Tabs.prototype.name = 'tabs';
Tabs.prototype.components = [];
require('./operations');
require('./actions');
Tabs.prototype.init = function(model) {
var self = this;
var tabs = this.getAttribute('tab');
var selectedIndex = this.getAttribute('selectedTab') || 0;
if (tabs) {
this._assignPositions(tabs);
this.model.set('selectedTab', selectedIndex);
_.each(tabs, function (tab, index) {
if(tab.hasOwnProperty('hide')) {
var context = self.parent.context;
var attribute = model.get('tab.' + index + '.hide');
var segments = (
attribute.expression &&
attribute.expression.pathSegments(context)
);
if (segments) {
model.scope('').ref(model._at + '.tabs.' + index + '.hide', segments.join('.'), {updateIndices: true});
} else {
model.set('tabs.' + index + '.hide', tab.hide);
}
}
});
}
this.tabHeaders = new DerbyElList();
this.tabContents = new DerbyElList();
};
Tabs.prototype.create = function(model) {
var selectedIndex = this.getAttribute('selectedTab') || 0;
this._setTabUnderline(selectedIndex);
};