a31f0660
root
sevc-controllet i...
|
1
2
3
4
5
6
7
8
9
10
11
12
|
<link rel="import" href="../../bower_components/polymer/polymer.html" />
<link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html">
<link rel="import" href="../../bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="../../bower_components/iron-icons/hardware-icons.html">
<link rel="import" href="../../bower_components/iron-icons/iron-icons.html">
<link rel="import" href="../../bower_components/paper-material/paper-material.html" />
<link rel="import" href="../../bower_components/paper-input/paper-input.html">
|
256ece27
Renato De Donato
new controllet
|
13
14
|
<script type="text/javascript" src="../../bower_components/jsdatachecker/jsdatachecker.min.js"></script>
|
a31f0660
root
sevc-controllet i...
|
15
16
17
18
19
20
|
<dom-module id="items-vslider-controllet">
<template>
<style is="custom-style">
paper-icon-button{
|
256ece27
Renato De Donato
new controllet
|
21
|
/*color: #FFFFFF;*/
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
22
23
|
height: 32px;/*48*/
width: 32px;/*48*/
|
a31f0660
root
sevc-controllet i...
|
24
25
26
27
28
29
30
31
|
padding: 0px;
margin: 0px;
--paper-icon-button-ink-color: white;
}
#items_vslider_container{
display: flex;
flex-direction: column;
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
32
|
height: 100%;
|
a31f0660
root
sevc-controllet i...
|
33
34
35
36
37
38
39
40
41
42
43
|
width: 172px;
background-color: #E0E0E0;
}
#div_datalets_container {
position: relative;
margin-bottom: 16px;
}
.arrow-up{
background-color: #2196F3;
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
44
|
padding-left: 70px;/*62*/
|
a31f0660
root
sevc-controllet i...
|
45
46
47
48
|
}
.arrow-down{
background-color: #2196F3;
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
49
|
padding-left: 70px;
|
a31f0660
root
sevc-controllet i...
|
50
51
52
53
54
|
}
.content-card{
position: relative;
float: left;/*firefox*/
|
a31f0660
root
sevc-controllet i...
|
55
56
57
58
59
60
61
62
|
margin : 16px 16px 0px 16px;
padding: 8px;
height: 124px;
width: 124px;
cursor: pointer;
background-color: #FFFFFF;
}
|
256ece27
Renato De Donato
new controllet
|
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
.content-card-disabled{
position: relative;
float: left;/*firefox*/
margin : 16px 16px 0px 16px;
padding: 8px;
height: 124px;
width: 124px;
cursor: pointer;
background-color: #FFFFFF;
opacity: 0.5;
pointer-events:none;
}
|
a31f0660
root
sevc-controllet i...
|
77
|
img{
|
a31f0660
root
sevc-controllet i...
|
78
79
80
81
82
83
84
85
86
|
width: 100%;
}
.legend {
position: absolute;
left: 0;
bottom: 16px;
padding: 8px;
width: 124px;
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
87
|
color: #000000;
|
cc0a0122
Renato De Donato
new scatter + dat...
|
88
|
background-color: rgba(158, 158, 158, 0.8);/*9E*/
|
256ece27
Renato De Donato
new controllet
|
89
90
|
/*background-color: #B6B6B6;*/
/*opacity: 0.9;*/
|
a31f0660
root
sevc-controllet i...
|
91
92
93
|
z-index: 1;
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 16px;
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
94
95
|
line-height: 16px;
font-weight: 700;
|
a31f0660
root
sevc-controllet i...
|
96
97
98
|
}
.legend.selected {
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
99
|
color: #FFFFFF;
|
256ece27
Renato De Donato
new controllet
|
100
101
|
background-color: #2196F3;
opacity: 0.9;
|
cc0a0122
Renato De Donato
new scatter + dat...
|
102
|
|
256ece27
Renato De Donato
new controllet
|
103
104
|
/*background: black;*/
/*color: #2196F3;*/
|
a31f0660
root
sevc-controllet i...
|
105
106
107
|
}
#items_vslider_search{
|
79627d7e
Renato De Donato
controllet ln
|
108
109
110
|
/*height: 48px;*/
/*padding: 0px 8px;*/
padding: 4px 8px 4px 8px;
|
a31f0660
root
sevc-controllet i...
|
111
112
113
114
115
|
background-color: #B6B6B6;
--paper-input-container-focus-color: #2196F3;
}
.search{
|
256ece27
Renato De Donato
new controllet
|
116
|
/*color: #FFFFFF*/
|
a31f0660
root
sevc-controllet i...
|
117
118
119
|
}
.clear {
|
0ff13705
root
suggested dataset...
|
120
121
122
|
width: 24px;
height: 24px;
padding: 0px 4px;
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
123
|
color: #F44336;
|
0ff13705
root
suggested dataset...
|
124
|
--paper-icon-button-ink-color: #FFFFFF;
|
a31f0660
root
sevc-controllet i...
|
125
126
127
128
129
130
131
|
}
</style>
<iron-ajax auto handle-as="json" url={{dataletsListUrl}} on-response="_getDatalets"></iron-ajax>
<paper-material id="items_vslider_container" elevation="5">
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
132
|
<paper-input id="items_vslider_search" value={{filter}} no-label-float label="">
|
a31f0660
root
sevc-controllet i...
|
133
|
<iron-icon class="search" icon="search" prefix></iron-icon>
|
0ff13705
root
suggested dataset...
|
134
|
<paper-icon-button class="clear" suffix on-click="_clearInput" icon="clear" tabindex="0"></paper-icon-button>
|
a31f0660
root
sevc-controllet i...
|
135
136
137
138
139
140
141
142
|
</paper-input>
<div class="arrow-up">
<paper-icon-button on-click="_onPrevClick" icon="hardware:keyboard-arrow-up"></paper-icon-button>
</div>
<div id="div_datalets_container" class="flex">
<template is="dom-repeat" items="{{filteredDatalets}}">
|
256ece27
Renato De Donato
new controllet
|
143
|
<paper-material id={{item.imageName}} elevation="1" class$="{{item.class}}" on-click="_selectDatalet">
|
ac237fdd
Renato De Donato
controllet ln
|
144
|
<div class="legend">{{_getChartName(item.imageName)}}</div>
|
a31f0660
root
sevc-controllet i...
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
<div><img src={{item.imageUrl}}></div>
</paper-material>
</template>
</div>
<div class="arrow-down">
<paper-icon-button on-click="_onNextClick" icon="hardware:keyboard-arrow-down"></paper-icon-button>
</div>
</paper-material>
</template>
<script>
Polymer({
is : 'items-vslider-controllet',
properties : {
dataletsListUrl : {
type : String,
value : undefined
},
selectedDatalet : {
type : String,
value : undefined
},
|
e0e4a976
Renato De Donato
data-sevc-control...
|
176
177
178
179
180
|
preselectedDatalet : {
type : String,
value : undefined
},
|
a31f0660
root
sevc-controllet i...
|
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
datalets : {
type : Array,
value : []
},
filteredDatalets : {
type : Array,
value : []
},
filter : {
type : String,
value : "",
observer : '_filterDatalets'
}
|
256ece27
Renato De Donato
new controllet
|
196
|
|
a31f0660
root
sevc-controllet i...
|
197
198
199
200
201
202
203
|
},
listeners: {
'dom-change': '_onDomChange'
},
ready : function() {
|
a31f0660
root
sevc-controllet i...
|
204
205
206
207
|
$(this.$.div_datalets_container).perfectScrollbar();
},
attached : function() {
|
256ece27
Renato De Donato
new controllet
|
208
|
// if(this.preselectedDatalet)
|
20f33314
Renato De Donato
preselect strikes...
|
209
|
// this._preselectDatalet();
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
210
211
212
213
|
this._translate();
},
|
256ece27
Renato De Donato
new controllet
|
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
// _preselectDatalet : function(){
// this.async(function() {
// var dataletCard = document.getElementById(this.preselectedDatalet);
// dataletCard.elevation = "5";
// dataletCard.getElementsByClassName("legend")[0].className = dataletCard.getElementsByClassName("legend")[0].className + " selected";
// this.selectedDatalet = this.preselectedDatalet;
//
// this.fire('items-vslider-controllet_selected-datalet', {datalet: this.selectedDatalet});
// this.preselectedDatalet = undefined;
// }, 300);
// },
preselectDatalet : function(preselectedDatalet){
var dataletCard = document.getElementById(preselectedDatalet);
dataletCard.elevation = "5";
dataletCard.getElementsByClassName("legend")[0].className = dataletCard.getElementsByClassName("legend")[0].className + " selected";
this.selectedDatalet = preselectedDatalet;
this.fire('items-vslider-controllet_selected-datalet', {datalet: this.selectedDatalet});
},
reset : function() {
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
236
237
238
239
240
241
242
|
if(this.selectedDatalet != undefined && (document.getElementById(this.selectedDatalet) != null)){
var dataletCard = document.getElementById(this.selectedDatalet);
dataletCard.elevation = "1";
dataletCard.getElementsByClassName("legend")[0].className = dataletCard.getElementsByClassName("legend")[0].className.replace(" selected", "");
}
this.selectedDatalet = undefined;
this.filter = "";
|
a53fbbed
Renato De Donato
select-dataset ne...
|
243
244
|
this.fire('items-vslider-controllet_selected-datalet', {datalet: undefined});
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
245
246
247
248
|
},
_translate : function(){
this.$.items_vslider_search.setAttribute("label", ln["search_" + ln["localization"]]);
|
a31f0660
root
sevc-controllet i...
|
249
250
251
252
253
254
255
256
257
|
},
_clearInput : function() {
this.$.items_vslider_search.value = "";
},
_getDatalets : function(e){
var datalets = new Array();
for(var i=0; i < e.detail.response.length; i++){
|
256ece27
Renato De Donato
new controllet
|
258
259
260
261
262
263
264
|
var datalet = {
imageName : e.detail.response[i].name.replace("-datalet", ""),
imageUrl : e.detail.response[i].url + e.detail.response[i].name + ".png",
inputTypes : this._getInputTypes(e.detail.response[i].idm.inputs.input),
class : "content-card"
};
|
17da8e08
Renato De Donato
hidden preview da...
|
265
266
|
if(e.detail.response[i].type != "hidden")
datalets.push(datalet);
|
a31f0660
root
sevc-controllet i...
|
267
268
269
|
}
this.datalets = datalets;
|
256ece27
Renato De Donato
new controllet
|
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
/**/this.filteredDatalets = datalets;
},
_getInputTypes : function(inputs){
var inputTypes = [];
for(var i=0; i < inputs.length; i++) {
if(inputs[i].selection != "?" /*&& inputs[i].selection != "*"*/)
inputTypes.push(inputs[i].type);
}
return inputTypes;
},
setEnabledDatalets : function(fields){
var dataTypes = [];
for(var i=0; i < fields.length; i++)
dataTypes.push(fields[i].type);
this.async(function() {
// console.log(DataTypeHierarchy.canConvert("TEXT", "NUMBER"));
// console.log(DataTypeHierarchy.canConvert("NUMBER", "TEXT"));
for(var i=0; i < this.datalets.length; i++) {
if(!this._enebled(this.datalets[i].inputTypes, dataTypes))
this.datalets[i]["class"] = "content-card-disabled";
else
this.datalets[i]["class"] = "content-card";
}
this._filterDatalets();
}, 1);//remove async
},
_enebled : function(inputTypes, dataTypes){
if((inputTypes.indexOf("NUMBER") > -1) && !(dataTypes.indexOf("NUMBER") > -1))
return false;
return true;
|
a31f0660
root
sevc-controllet i...
|
306
307
|
},
|
256ece27
Renato De Donato
new controllet
|
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
// _enebled : function(dataTypes, inputTypes){
// var enabled = true;
// for(var i=0; i < inputTypes.length; i++) {
// var canConvert = false;
// for(var j=0; j < dataTypes.length; j++) {
// if(DataTypeHierarchy.canConvert(dataTypes[j], inputTypes[i])) {
// canConvert = true;
// break;
// }
// }
// if(!canConvert)
// enabled = false;
// }
// return enabled;
// },
|
a31f0660
root
sevc-controllet i...
|
324
325
326
327
|
_filterDatalets : function(){
var datalets = new Array();
for(var i=0; i < this.datalets.length; i++){
var datalet = this.datalets[i];
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
328
|
var imageName = this._getChartName(datalet.imageName).toLowerCase();
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
329
|
if(imageName.indexOf(this.filter.toLowerCase()) > -1)
|
a31f0660
root
sevc-controllet i...
|
330
331
332
|
datalets.push(datalet);
}
|
256ece27
Renato De Donato
new controllet
|
333
334
335
336
|
this.filteredDatalets = [];
this.async(function() {
this.filteredDatalets = datalets;
}, 0);
|
a31f0660
root
sevc-controllet i...
|
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
|
$("#div_datalets_container").animate({ scrollTop: 0}, 0);
},
_onDomChange : function() {
if(this.selectedDatalet != undefined ){
for(var i=0; i < this.filteredDatalets.length; i++){
var datalet = this.filteredDatalets[i];
var dataletCard = document.getElementById(datalet.imageName);
dataletCard.elevation = "1";
dataletCard.getElementsByClassName("legend")[0].className = dataletCard.getElementsByClassName("legend")[0].className.replace("selected", "");
}
if(document.getElementById(this.selectedDatalet) != null){
var dataletCard = document.getElementById(this.selectedDatalet);
dataletCard.elevation = "5";
dataletCard.getElementsByClassName("legend")[0].className = dataletCard.getElementsByClassName("legend")[0].className + " selected";
}
}
},
_selectDatalet : function(e){
if(this.selectedDatalet != undefined && (document.getElementById(this.selectedDatalet) != null)){
var dataletCard = document.getElementById(this.selectedDatalet);
dataletCard.elevation = "1";
dataletCard.getElementsByClassName("legend")[0].className = dataletCard.getElementsByClassName("legend")[0].className.replace(" selected", "");
}
|
e0e4a976
Renato De Donato
data-sevc-control...
|
367
|
if (e.currentTarget.id != this.selectedDatalet) {
|
a31f0660
root
sevc-controllet i...
|
368
369
370
371
372
373
374
375
376
377
|
e.currentTarget.elevation = "5";
e.currentTarget.getElementsByClassName("legend")[0].className = e.currentTarget.getElementsByClassName("legend")[0].className + " selected";
this.selectedDatalet = e.currentTarget.id;
}
else
this.selectedDatalet = undefined;
this.fire('items-vslider-controllet_selected-datalet', {datalet: this.selectedDatalet});
},
|
20f33314
Renato De Donato
preselect strikes...
|
378
|
|
a31f0660
root
sevc-controllet i...
|
379
380
381
382
383
384
|
_getImageUrl : function(index){
return this.datalets[index].imageUrl;
},
_onPrevClick : function() {
|
a31f0660
root
sevc-controllet i...
|
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
|
var container = $("#div_datalets_container");
var h = container.height();
var dataletPerPage = parseInt(h/156);
var scroll = $("#div_datalets_container").scrollTop()-156*dataletPerPage;
var diff = scroll % 156;
// scroll += 156-diff;
scroll -= diff;
$("#div_datalets_container").animate({ scrollTop: scroll}, 300);
},
_onNextClick : function() {
var container = $("#div_datalets_container");
var h = container.height();
var dataletPerPage = parseInt(h/156);
var scroll = $("#div_datalets_container").scrollTop()+156*dataletPerPage;
var diff = scroll % 156;
scroll -= diff;
$("#div_datalets_container").animate({ scrollTop: scroll}, 300);
},
|
ac237fdd
Renato De Donato
controllet ln
|
407
408
409
410
|
_getChartName: function(key) {
return ln[key + "_" +ln["localization"]];
}
|
a31f0660
root
sevc-controllet i...
|
411
412
413
414
415
416
417
418
419
420
421
|
// _resize : function(){
// var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - 16;
// h = h - 64 - 8; //height with page scroller
// $("#items_vslider_container").height(h);
// }
});
</script>
</dom-module>
|