Blame view

controllets/items-vslider-controllet/items-vslider-controllet.html 11.8 KB
a31f0660   root   sevc-controllet i...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  <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">
  
  <dom-module id="items-vslider-controllet">
  
      <template>
  
          <style is="custom-style">
              paper-icon-button{
                  color: #FFFFFF;
fb05b400   Renato De Donato   controllet 2.0, n...
20
21
                  height: 32px;/*48*/
                  width: 32px;/*48*/
a31f0660   root   sevc-controllet i...
22
23
24
25
26
27
28
29
                  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...
30
                  height: 100%;
a31f0660   root   sevc-controllet i...
31
32
33
34
35
36
37
38
39
40
41
                  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...
42
                  padding-left: 70px;/*62*/
a31f0660   root   sevc-controllet i...
43
44
45
46
              }
  
              .arrow-down{
                  background-color: #2196F3;
fb05b400   Renato De Donato   controllet 2.0, n...
47
                  padding-left: 70px;
a31f0660   root   sevc-controllet i...
48
49
50
51
52
              }
  
              .content-card{
                  position: relative;
                  float: left;/*firefox*/
a31f0660   root   sevc-controllet i...
53
54
55
56
57
58
59
60
61
                  margin : 16px 16px 0px 16px;
                  padding: 8px;
                  height: 124px;
                  width: 124px;
                  cursor: pointer;
                  background-color: #FFFFFF;
              }
  
              img{
a31f0660   root   sevc-controllet i...
62
63
64
65
66
67
68
69
70
                  width: 100%;
              }
  
              .legend {
                  position: absolute;
                  left: 0;
                  bottom: 16px;
                  padding: 8px;
                  width: 124px;
fb05b400   Renato De Donato   controllet 2.0, n...
71
                  color: #000000;
cc0a0122   Renato De Donato   new scatter + dat...
72
73
                  background-color: rgba(158, 158, 158, 0.8);/*9E*/
                  /*background-color: rgba(182, 182, 182, 0.9);/!*B&*!/*/
a31f0660   root   sevc-controllet i...
74
75
76
                  z-index: 1;
                  font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
                  font-size: 16px;
fb05b400   Renato De Donato   controllet 2.0, n...
77
78
                  line-height: 16px;
                  font-weight: 700;
a31f0660   root   sevc-controllet i...
79
80
81
              }
  
              .legend.selected {
a31f0660   root   sevc-controllet i...
82
                  background-color: #2196F3;
cc0a0122   Renato De Donato   new scatter + dat...
83
                  /*background-color: rgba(33, 150, 243, 0.8);*/
fb05b400   Renato De Donato   controllet 2.0, n...
84
                  color: #FFFFFF;
cc0a0122   Renato De Donato   new scatter + dat...
85
  
a31f0660   root   sevc-controllet i...
86
87
88
              }
  
              #items_vslider_search{
79627d7e   Renato De Donato   controllet ln
89
90
91
                  /*height: 48px;*/
                  /*padding: 0px 8px;*/
                  padding: 4px 8px 4px 8px;
a31f0660   root   sevc-controllet i...
92
93
94
95
96
97
98
99
100
                  background-color: #B6B6B6;
                  --paper-input-container-focus-color: #2196F3;
              }
  
              .search{
                  color: #FFFFFF
              }
  
              .clear {
0ff13705   root   suggested dataset...
101
102
103
                  width: 24px;
                  height: 24px;
                  padding: 0px 4px;
fb05b400   Renato De Donato   controllet 2.0, n...
104
                  color: #F44336;
0ff13705   root   suggested dataset...
105
                  --paper-icon-button-ink-color: #FFFFFF;
a31f0660   root   sevc-controllet i...
106
107
108
109
110
111
112
              }
          </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...
113
              <paper-input id="items_vslider_search" value={{filter}} no-label-float label="">
a31f0660   root   sevc-controllet i...
114
                  <iron-icon class="search" icon="search" prefix></iron-icon>
0ff13705   root   suggested dataset...
115
                  <paper-icon-button class="clear" suffix on-click="_clearInput" icon="clear" tabindex="0"></paper-icon-button>
a31f0660   root   sevc-controllet i...
116
117
118
119
120
121
122
123
124
              </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}}">
                      <paper-material id={{item.imageName}} elevation="1" class='content-card' on-click="_selectDatalet">
ac237fdd   Renato De Donato   controllet ln
125
                          <div class="legend">{{_getChartName(item.imageName)}}</div>
a31f0660   root   sevc-controllet i...
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
153
154
155
156
                          <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...
157
158
159
160
161
                  preselectedDatalet : {
                      type  : String,
                      value : undefined
                  },
  
a31f0660   root   sevc-controllet i...
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
                  datalets : {
                      type  : Array,
                      value : []
                  },
  
                  filteredDatalets : {
                      type  : Array,
                      value : []
                  },
  
                  filter : {
                      type  : String,
                      value : "",
                      observer : '_filterDatalets'
                  }
              },
  
              listeners: {
                  'dom-change': '_onDomChange'
              },
  
              ready : function() {
a31f0660   root   sevc-controllet i...
184
185
186
187
                  $(this.$.div_datalets_container).perfectScrollbar();
              },
  
              attached : function() {
e0e4a976   Renato De Donato   data-sevc-control...
188
189
190
191
                  if(this.preselectedDatalet){
                      this._preselectDatalet();
                      this.preselectedDatalet = undefined;
                  }
fb05b400   Renato De Donato   controllet 2.0, n...
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
  
                  this._translate();
              },
  
              _reset : function() {
                  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 = "";
              },
  
              _translate : function(){
                  this.$.items_vslider_search.setAttribute("label", ln["search_" + ln["localization"]]);
a31f0660   root   sevc-controllet i...
208
209
210
211
212
213
214
215
216
217
              },
  
              _clearInput : function() {
                  this.$.items_vslider_search.value = "";
              },
  
              _getDatalets : function(e){
                  var datalets = new Array();
                  for(var i=0; i < e.detail.response.length; i++){
                      var datalet = { imageName : e.detail.response[i].name.replace("-datalet", ""), imageUrl : e.detail.response[i].url + e.detail.response[i].name + ".png" };
17da8e08   Renato De Donato   hidden preview da...
218
219
                      if(e.detail.response[i].type != "hidden")
                          datalets.push(datalet);
a31f0660   root   sevc-controllet i...
220
221
222
223
224
225
226
227
228
229
                  }
  
                  this.datalets = datalets;
                  this.filteredDatalets = datalets;
              },
  
              _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...
230
                      var imageName = this._getChartName(datalet.imageName).toLowerCase();
cc0a0122   Renato De Donato   new scatter + dat...
231
232
  //                    console.log(imageName);
  //                    console.log(this.filter);
fb05b400   Renato De Donato   controllet 2.0, n...
233
                      if(imageName.indexOf(this.filter.toLowerCase()) > -1)
a31f0660   root   sevc-controllet i...
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
                          datalets.push(datalet);
                  }
  
                  this.filteredDatalets = datalets;
  
                  $("#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...
268
                  if (e.currentTarget.id != this.selectedDatalet) {
a31f0660   root   sevc-controllet i...
269
270
271
272
273
274
275
276
277
278
                      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});
              },
  
e0e4a976   Renato De Donato   data-sevc-control...
279
280
281
282
283
284
285
286
              _preselectDatalet : 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});
              },
a31f0660   root   sevc-controllet i...
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
  
              _getImageUrl : function(index){
                  return this.datalets[index].imageUrl;
              },
  
              _onPrevClick : 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 += 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
316
317
318
319
              _getChartName: function(key) {
                  return ln[key + "_" +ln["localization"]];
              }
  
a31f0660   root   sevc-controllet i...
320
321
322
323
324
325
326
327
328
329
330
  //            _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>