-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZPile.js
52 lines (49 loc) · 1.72 KB
/
ZPile.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
51
52
var compose = require('ksf/utils/compose');
var delegateGetSet = require('./utils/delegateGetSet');
var Full = require('./layout/Full');
var ZPileLayout = require('./layout/ZPile');
var IncrementalContainer = require('./IncrementalContainer');
// empile des composants en 'top' mais leur impose le 'width'
// incrémental
module.exports = compose(function ZPile() {
this._container = new IncrementalContainer();
this._verticalLayouter = new Full('vertical');
this._horizontalLayouter = new Full('horizontal');
this._zLayouter = new ZPileLayout();
}, {
content: function(content) {
this._verticalLayouter.content(content);
this._horizontalLayouter.content(content);
this._zLayouter.content(content.map(function(cmp, index) {
return {
key: index+'',
cmp: cmp,
};
}));
this._container.content(content);
return this;
},
add: function(key, cmp, beforeKey) {
this._verticalLayouter.add(key, cmp);
this._horizontalLayouter.add(key, cmp);
this._zLayouter.add(key, cmp, beforeKey);
this._container.add(key, cmp);
return cmp;
},
remove: function(key) {
var cmp = this._container.remove(key);
this._verticalLayouter.remove(key);
this._horizontalLayouter.remove(key);
this._zLayouter.remove(key);
return cmp;
},
width: delegateGetSet('_horizontalLayouter', 'size'),
height: delegateGetSet('_verticalLayouter', 'size'),
depth: delegateGetSet('_zLayouter', 'size'),
left: delegateGetSet('_horizontalLayouter', 'position'),
top: delegateGetSet('_verticalLayouter', 'position'),
zIndex: delegateGetSet('_zLayouter', 'position'),
parentNode: delegateGetSet('_container', 'parentNode'),
containerVisible: delegateGetSet('_container', 'containerVisible'),
visible: delegateGetSet('_container', 'visible'),
});