-
Notifications
You must be signed in to change notification settings - Fork 6
/
containerView.js
39 lines (32 loc) · 1.01 KB
/
containerView.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
/**
## ContainerView
A base constructor for gaffa Views that can hold child views.
All Views that inherit from ContainerView will have:
someView.views.content
*/
var createSpec = require('spec-js'),
View = require('./view'),
ViewContainer = require('./viewContainer'),
Property = require('./property');
function ContainerView(viewDescription){
this.views = this.views || {};
this.views.content = new ViewContainer(this.views.content);
this.on('bind', function(){
for(var key in this.views){
var viewContainer = this.views[key];
if(viewContainer instanceof ViewContainer){
viewContainer.bind(this);
}
}
});
}
ContainerView = createSpec(ContainerView, View);
ContainerView.prototype.renderChildren = new Property({
update: function(view, value){
for(var key in view.views){
view.views[key][value ? 'render' : 'derender']();
}
},
value: true
});
module.exports = ContainerView;