-
Notifications
You must be signed in to change notification settings - Fork 0
/
nested-includer.html
59 lines (50 loc) · 1.82 KB
/
nested-includer.html
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
<script>
NestedIncluderBehavior = {
properties: {
inContentMode: {
type: Boolean,
value: false,
notify: true
},
inEditMode: {
type: Boolean,
value: false,
notify: true
},
parentId: {
type: String,
notify: true
},
innercomponents: {
type: Object,
notify: true
},
path: {
type: String,
notify: true
}
},
ready: function() {
this._handleCssGrids();
},
_handleCssGrids: function() {
var contentDivs = Polymer.dom(this.root).querySelectorAll('content-slot');
for(var i =0 ; i < contentDivs.length; i++) {
var cssGrid = document.createElement('css-grid'),
contentDivId = contentDivs[i].getAttribute('id'),
path = this.path + this.id + '/components/' + contentDivId + '/',
rawcomponents = !!this.innercomponents ? JSON.stringify(this.innercomponents[contentDivId]) : '{}';
cssGrid.setAttribute('path', path);
if(this.inEditMode) {
cssGrid.setAttribute('in-edit-mode', this.inEditMode);
cssGrid.addDragEvents();
}
if(this.inContentMode) {
cssGrid.setAttribute('in-content-mode', this.inContentMode);
}
cssGrid.setAttribute('rawcomponents', rawcomponents);
Polymer.dom(this.root).insertBefore(cssGrid, contentDivs[i]);
}
}
}
</script>