-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnx-grid.html
More file actions
152 lines (132 loc) · 6.16 KB
/
nx-grid.html
File metadata and controls
152 lines (132 loc) · 6.16 KB
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
<link rel="import" href="nx-grid-component.html">
<dom-module id="nx-grid">
<style include="iron-flex iron-flex-factors">
.header{
padding: 10px 0px 10px 10px;
background-color: var(--paper-grey-100);
color: var(--paper-grey-600);
}
paper-item {
--paper-item: {
cursor: pointer;
};
}
.sublist paper-item {
padding-left: 30px;
}
</style>
<template>
<content id="primary" select="items[type=primary]"></content>
<content id="secondary" select="items[type=secondary]"></content>
<content select="template[type=primary]"></content>
<content select="template[type=secondary]"></content>
<div class="horizontal-section">
<div class="header layout horizontal">
<!-- Head primary Level 1 -->
<template is="dom-repeat" as="itemConfigPrimary" items="{{config.primary}}">
<div class$="{{itemConfigPrimary.width}}">{{itemConfigPrimary.label}}
<!-- width:{{itemConfigPrimary.width}} -->
</div>
</template>
</div>
<paper-menu attr-for-item-title="label" multi>
<template is="dom-repeat" as="itemPrimary" items="{{data}}">
<paper-submenu label$="{{index}}">
<paper-item on-tap="_getBind" on-dblclick="_getBind" data="{{itemPrimary}}" class="menu-trigger">
<template is="dom-repeat" as="configPrimary" items="{{config.primary}}">
<div data="{{itemPrimary}}" class$="{{configPrimary.width}}">
{{_getItemPrimary(itemPrimary,configPrimary)}}
<!-- width:{{configPrimary.width}} -->
</div>
</template>
</paper-item>
<paper-menu class="menu-content sublist">
<paper-item>
<!-- Head secondary -->
<template is="dom-repeat" as="itemConfigSecondary" items="{{config.secondary}}">
<div class$="{{itemConfigSecondary.width}}">
{{itemConfigSecondary.label}}
<!-- width:{{itemConfigSecondary.width}} -->
</div>
</template>
</paper-item>
<template is="dom-repeat" as="itemSecondary" items="{{_getDataSub(itemPrimary,config.sub)}}">
<paper-item on-tap="_getBind" on-dblclick="_getBind" data="{{itemSecondary}}">
<template is="dom-repeat" as="configSecondary" items="{{config.secondary}}">
<div class$="{{configSecondary.width}}" data="{{itemSecondary}}">
{{_getItemSecondary(itemSecondary,configSecondary)}}
<!-- width:{{configSecondary.width}} -->
</div>
</template>
<paper-item>
</template>
<paper-item class="testclass">
<nx-grid-component temp="{{tempSecondary}}"></nx-grid-component>
</paper-item>
</paper-menu>
</paper-submenu>
</template>
</paper-menu>
<div>
<nx-grid-component temp="{{tempPrimary}}"></nx-grid-component>
</div>
</div>
</template>
<script>
var nxGridRender = [];
Polymer({
is:'nx-grid',
behaviors:[Polymer.Templatizer],
properties:{
seleted:{
type:Object,
notify:true
},
config:{
type:Object
}
},
ready:function(){
var templatePrimary = Polymer.dom(this).querySelector('template[type=primary]');
this.tempPrimary = templatePrimary;
var templateSecondary = Polymer.dom(this).querySelector('template[type=secondary]');
this.tempSecondary = templateSecondary;
var config = {primary:[],secondary:[]};
var items = Polymer.dom(this.$.primary).getDistributedNodes();
var lists = Polymer.dom(items[0]).querySelectorAll('list');
for (var i = 0; i < lists.length; i++) {
var configPointer = {
item:lists[i].getAttribute('item'),
label:lists[i].getAttribute('label'),
width:lists[i].getAttribute('width')
};
config.primary.push(configPointer);
}
var items2 = Polymer.dom(this.$.secondary).getDistributedNodes();
var lists2 = Polymer.dom(items2[0]).querySelectorAll('list');
for (var i = 0; i < lists2.length; i++) {
var configPointer2 = {
item:lists2[i].getAttribute('item'),
label:lists2[i].getAttribute('label'),
width:lists2[i].getAttribute('width')
};
config.secondary.push(configPointer2);
}
config.sub = Polymer.dom(this.$.secondary).getDistributedNodes()[0].getAttribute('item');
this.config = config;
},
_getItemPrimary:function(item,config){
return item[config.item];
},
_getDataSub:function(item,sub){
return item[sub];
},
_getItemSecondary:function(item,config){
return item[config.item];
},
_getBind:function(e){
this.fire('nx-grid-'+e.type, {data: e.target.data});
}
});
</script>
</dom-module>